예제 #1
0
 /// <summary>
 /// Insert the given object into the database.
 /// </summary>
 /// <param name="insertFactory">Factory used to create the command.</param>
 /// <param name="domainObj">Domain object to insert</param>
 public void Add(IInsertFactory <TDomainObject> insertFactory,
                 TDomainObject domainObj)
 {
     using (DbCommand command = insertFactory.ConstructInsertCommand(db, domainObj))
     {
         db.ExecuteNonQuery(command);
         insertFactory.SetNewID(db, command, domainObj);
     }
 }
예제 #2
0
        /// <summary>
        /// Insert the given object into the database.
        /// </summary>
        /// <param name="insertFactory">Factory used to create the command.</param>
        /// <param name="domainObj">Domain object to insert</param>
        public void Add(IInsertFactory <TDomainObject> insertFactory,
                        TDomainObject domainObj)
        {
            //using (var cmd = db.GetStoredProcCommand("LastIdInsert"))
            //{
            //    db.AddInParameter(cmd, "PTableName", DbType.String, "Testing");
            //    db.AddInParameter(cmd, "Pseed", DbType.Int32, 200);
            //    db.AddInParameter(cmd, "PIncrement", DbType.Int32, 1);
            //    db.AddInParameter(cmd, "PUpdateDate", DbType.DateTime, DateTime.Now);
            //    db.ExecuteNonQuery(cmd);
            //}

            using (DbCommand command = insertFactory.ConstructInsertCommand(db, domainObj))
            {
                db.ExecuteNonQuery(command);
                insertFactory.SetNewID(db, command, domainObj);
            }
        }