示例#1
0
        public virtual int RowCount()
        {
            string cmtext = query.RowCount();

            using (CommanderBase commander = DBContext.CreateCommander())
            {
                var o = commander.Scaller(cmtext);
                if (o != null)
                {
                    return(Convert.ToInt32(o));
                }
                else
                {
                    return(0);
                }
            }
        }
示例#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);
                }
            }
        }
示例#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);
                }
            }
        }
示例#4
0
        public virtual int RowCountWithSrc(string srcClm, string srcValue)
        {
            string cmtext = query.RowCountWithSrc(srcClm);

            using (CommanderBase commander = DBContext.CreateCommander())
            {
                var o = commander.Scaller(cmtext, new List <DbParameter>()
                {
                    commander.SetParametr(srcClm, srcValue)
                });

                if (o != null)
                {
                    return(Convert.ToInt32(o));
                }
                else
                {
                    return(0);
                }
            }
        }