예제 #1
0
 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;
 }
예제 #2
0
        /// <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);
        }
예제 #3
0
 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));
 }