Example #1
0
        public virtual bool Update <M>(M t, int id) where M : class, new()
        {
            string cmtext = query.Update <M>(id.ToString());

            using (CommanderBase commander = DBContext.CreateCommander())
                return(commander.NonQuery(cmtext, commander.SetParametrs(t)));
        }
Example #2
0
        public virtual int Insert(T t)
        {
            string cmtext = query.Insert();

            using (CommanderBase commander = DBContext.CreateCommander())
            {
                var p  = commander.SetParametrs(t);
                var id = commander.Scaller(cmtext, p);
                if (id != null)
                {
                    return(Convert.ToInt32(id));
                }
                else
                {
                    return(0);
                }
            }
        }
Example #3
0
        public virtual (int, bool) Insert <M>(M t, DbTransaction transaction = null) where M : class, new()
        {
            string cmtext = query.Insert <M>();

            using (CommanderBase commander = DBContext.CreateCommander())
            {
                var p = commander.SetParametrs(t);
                var(id, b) = commander.Scaller(cmtext, parameters: p, transaction: transaction);

                if (b && id != null)
                {
                    return(Convert.ToInt32(id), b);
                }
                else
                {
                    return(0, b);
                }
            }
        }