Exemplo n.º 1
0
        public virtual int Delete(T obj, DBConnectionWrapper conn, DBTransactionWrapper trans = null)
        {
            if (DeleteCommand == null)
            {
                throw new NotSupportedException("Delete is not support for this [" + typeof(T).FullName + "], make sure you have primary key defined in Entity Metadata for this type.");
            }

            return(DeleteCommand.Execute(ref obj, conn, trans));
        }
Exemplo n.º 2
0
        public virtual T Load(T obj, DBConnectionWrapper conn, DBTransactionWrapper trans = null)
        {
            if (LoadCommand == null)
            {
                throw new NotSupportedException("Load is not support for this [" + typeof(T).FullName + "], make sure you have primary key defined in Entity Metadata for this type.");
            }
            int cnt = LoadCommand.Execute(ref obj, conn, trans);

            if (cnt == 0)
            {
                return(default(T));
            }
            return(obj);
        }
Exemplo n.º 3
0
        public virtual int Update(ref T obj, DBConnectionWrapper conn, DBTransactionWrapper trans = null, params Expression <Func <T, object> >[] targetProperties)
        {
            if (UpdateCommand == null)
            {
                throw new NotSupportedException("Update is not support for this [" + typeof(T).FullName + "], make sure you have primary key defined in Entity Metadata for this type.");
            }

            IDBTableAdapterCommand <T> cmd = UpdateCommand;

            if (targetProperties.Length > 0)
            {
                cmd = CreateUpdateCommand(targetProperties);
            }
            return(cmd.Execute(ref obj, conn, trans));
        }
Exemplo n.º 4
0
 public virtual int Insert(ref T obj, DBConnectionWrapper conn, DBTransactionWrapper trans = null)
 {
     return(InsertCommand.Execute(ref obj, conn, trans));
 }