Exemplo n.º 1
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public virtual void DetectChanges()
 {
     if (_stateManager.Model[ChangeDetector.SkipDetectChangesAnnotation] == null)
     {
         _changeDetector.DetectChanges(_stateManager);
     }
 }
Exemplo n.º 2
0
 public virtual bool SaveChanges()
 {
     try
     {
         var updatedEntries = changeDetector_.DetectChanges(stateManager_.GetTrackedEntities <object>())
                              .Where(update => update.EntityUpdates.Count() > 0)
                              .Each(update =>
         {
             var sb = new StringBuilder();
             sb.AppendLine($"USE {options_.DatabaseName}");
             sb.AppendLine(updateQueryTranslator_.Translate(update));
             var command = database_.CreateCommand(builder => builder.WithCommandText(sb.ToString()));
             database_.ExecuteCommand(command);
         });
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 ///     Scans the tracked entity instances to detect any changes made to the instance data. <see cref="DetectChanges" />
 ///     is usually called automatically by the context when up-to-date information is required (before
 ///     <see cref="DbContext.SaveChanges()" />
 ///     and when returning change tracking information). You typically only need to call this method if you have disabled
 ///     <see cref="AutoDetectChangesEnabled" />.
 /// </summary>
 public virtual void DetectChanges() => _changeDetector.DetectChanges(_stateManager);