private DataBase( ISelectCommand selectCommand, IInsertCommand insertCommand, IDeleteCommand deleteCommand, IUpdateCommand updateCommand, ISqlExecutorWithGeneric sqlExecutor) { this.selectCommand = selectCommand; this.insertCommand = insertCommand; this.deleteCommand = deleteCommand; this.updateCommand = updateCommand; this.sqlExecutor = sqlExecutor; }
/// <summary> /// Generates an insert core command for the given entity, or returns null if such /// command cannot be generated for whatever reasons. /// </summary> internal static IInsertCommand GenerateInsertCommand(this IUberMap map, object entity) { if (entity == null) { return(null); } if (map == null || map.IsDisposed || !map.IsValidated) { return(null); } IInsertCommand cmd = null; int num = map.Schema.Count(x => !x.IsReadOnlyColumn); if (num != 0) { cmd = map.Link.Engine.CreateInsertCommand(map.Link, x => map.Table); var tag = new DynamicNode.Argument("x"); var rec = new Core.Concrete.Record(map.Schema); map.WriteRecord(entity, rec); for (int i = 0; i < rec.Count; i++) { if (rec.Schema[i].IsReadOnlyColumn) { continue; } var node = new DynamicNode.SetMember(tag, rec.Schema[i].ColumnName, rec[i]); cmd.Columns(x => node); node.Dispose(); } tag.Dispose(); rec.Dispose(); } return(cmd); }
public InsertOperation(SqlConnection db, IInsertCommand <T> insertCommand, IInsertInside insertInside) { _insertCommand = insertCommand ?? throw new ArgumentNullException(nameof(insertCommand)); _db = db ?? throw new ArgumentNullException(nameof(db)); _insertInside = insertInside ?? throw new ArgumentNullException(nameof(insertInside)); }