/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> protected override void UpdateCachedCommandText(int commandPosition) { var newModificationCommand = ModificationCommands[commandPosition]; if (newModificationCommand.EntityState == EntityState.Added) { if (_bulkInsertCommands.Count > 0 && !CanBeInsertedInSameStatement(_bulkInsertCommands[0], newModificationCommand)) { CachedCommandText.Append(GetBulkInsertCommandText(commandPosition)); _bulkInsertCommands.Clear(); } _bulkInsertCommands.Add(newModificationCommand); LastCachedCommandIndex = commandPosition; } else { CachedCommandText.Append(GetBulkInsertCommandText(commandPosition)); _bulkInsertCommands.Clear(); base.UpdateCachedCommandText(commandPosition); } }
protected override void UpdateCachedCommandText(int commandPosition) { var stringBuilder = new StringBuilder(); var newModificationCommand = ModificationCommands[commandPosition]; if (newModificationCommand.EntityState == EntityState.Added) { if (_batchInsertCommands.Count > 0 && !CanBeInserted(_batchInsertCommands[0], newModificationCommand)) { CachedCommandText.Append(GetBatchInsertCommandText(commandPosition)); _batchInsertCommands.Clear(); } _batchInsertCommands.Add(newModificationCommand); LastCachedCommandIndex = commandPosition; } else if (newModificationCommand.EntityState == EntityState.Deleted) { CachedCommandText.Append(GetBatchDeleteCommandText(commandPosition)); LastCachedCommandIndex = commandPosition; } else { CachedCommandText.Append(GetBatchUpdateCommandText(commandPosition)); LastCachedCommandIndex = commandPosition; } }
protected override void UpdateCachedCommandText(int commandPosition) { var newModificationCommand = ModificationCommands[commandPosition]; if (newModificationCommand.EntityState == EntityState.Added) { if (_bulkInsertCommands.Count > 0 && !(string.Equals(_bulkInsertCommands[0].TableName, newModificationCommand.TableName) && string.Equals(_bulkInsertCommands[0].SchemaName, newModificationCommand.SchemaName))) { CachedCommandText.Append(GetBulkInsertCommandText(commandPosition)); _bulkInsertCommands.Clear(); } _bulkInsertCommands.Add(newModificationCommand); LastCachedCommandIndex = commandPosition; } else { CachedCommandText.Append(GetBulkInsertCommandText(commandPosition)); _bulkInsertCommands.Clear(); base.UpdateCachedCommandText(commandPosition); } }
protected override void UpdateCachedCommandText(int commandIndex) { CachedCommandText = CachedCommandText ?? new StringBuilder(); CachedCommandText.Append("."); }
protected override void UpdateCachedCommandText(int commandIndex) => CachedCommandText.Append(".");
/// <summary> /// 更新缓存命令文本 /// </summary> /// <param name="commandPosition"></param> protected override void UpdateCachedCommandText(int commandPosition) { try { if (Check.IsTraceEnabled(m_oracleLogger?.Logger)) { Trace <DbLoggerCategory.Update> .Write(m_oracleLogger, LogLevel.Trace, OracleTraceTag.Entry, OracleTraceClassName.OracleModificationCommandBatch, OracleTraceFuncName.UpdateCachedCommandText); } new StringBuilder(); // The list of conceptual insert/update/delete // Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ModificationCommandss // in the batch. // 取得待处理的插入/更新/删除行的概念性命令,这意味着你应该对真实的执行命令自己进行组装 ModificationCommand modificationCommand = ModificationCommands[commandPosition]; // 对命令进行组装 if (modificationCommand.EntityState == EntityState.Added) { // Add命令 if (_batchInsertCommands.Count > 0 && !CanBeInserted(_batchInsertCommands.First().Key, modificationCommand)) { CachedCommandText.Append(GetBatchInsertCommandText(commandPosition)); _batchInsertCommands.Clear(); } if (ModificationCommands[commandPosition].ColumnModifications.Where((ColumnModification o) => o.IsRead).ToArray().Length != 0) { _batchInsertCommands.Add(modificationCommand, _cursorPosition); _cursorPosition++; } else { _batchInsertCommands.Add(modificationCommand, 0); } LastCachedCommandIndex = commandPosition; } else if (modificationCommand.EntityState == EntityState.Deleted) { // Delete命令 CachedCommandText.Append(GetBatchDeleteCommandText(commandPosition)); LastCachedCommandIndex = commandPosition; } else { // Update命令 CachedCommandText.Append(GetBatchUpdateCommandText(commandPosition)); LastCachedCommandIndex = commandPosition; } } catch (Exception ex) { if (Check.IsErrorEnabled(m_oracleLogger?.Logger)) { Trace <DbLoggerCategory.Update> .Write(m_oracleLogger, LogLevel.Error, OracleTraceTag.Error, OracleTraceClassName.OracleModificationCommandBatch, OracleTraceFuncName.UpdateCachedCommandText, ex.ToString()); } throw; } finally { if (Check.IsTraceEnabled(m_oracleLogger?.Logger)) { Trace <DbLoggerCategory.Update> .Write(m_oracleLogger, LogLevel.Trace, OracleTraceTag.Exit, OracleTraceClassName.OracleModificationCommandBatch, OracleTraceFuncName.UpdateCachedCommandText); } } }