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

            using CommanderBase commander = DBContext.CreateCommander();
            return(commander.NonQuery(cmtext));
        }
Example #2
0
        public virtual (List <M>, bool) GetAll <M>(params string[] column) where M : class, new()
        {
            string cmtext = query.GetAll <M>(column);

            using (CommanderBase commander = DBContext.CreateCommander())
                return(commander.Reader <M>(cmtext));
        }
Example #3
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 #4
0
        public virtual List <T> GetAll(params string[] column)
        {
            string cmtext = query.GetAll(column);

            using (CommanderBase commander = DBContext.CreateCommander())
                return(commander.Reader <T>(cmtext));
        }
Example #5
0
        public virtual bool Delet(int id)
        {
            string cmtext = query.Delete(id.ToString());

            using (CommanderBase commander = DBContext.CreateCommander())
                return(commander.NonQuery(cmtext));
        }
Example #6
0
        public virtual List <T> getFromTo(int from, int to)
        {
            string cmtext = query.getFromTo(from, to);

            using (CommanderBase commander = DBContext.CreateCommander())
                return(commander.Reader <T>(cmtext));
        }
Example #7
0
        public virtual (M, bool) GetWithConditionFist <M>(string condition, params string[] selectColumn) where M : class, new()
        {
            string cmtext = query.Condition <M>(condition, selectColumn);

            using (CommanderBase commander = DBContext.CreateCommander())
            {
                return(commander.ReaderFist <M>(cmtext));
            }
        }
Example #8
0
        public virtual List <T> getFromToWithSrc(int from, int to, string srcClm, string srcValue)
        {
            string cmtext = query.getFromToWithSrc(from, to, srcClm);

            using (CommanderBase commander = DBContext.CreateCommander())
                return(commander.Reader <T>(cmtext, new List <DbParameter> {
                    commander.SetParametr(srcClm, srcValue)
                }));
        }
Example #9
0
        public virtual List <T> GetByColumName(string columName, object value)
        {
            string cmtext = query.GetByColumName(columName);

            using (CommanderBase commander = DBContext.CreateCommander())
                return(commander.Reader <T>(cmtext, new List <DbParameter>()
                {
                    commander.SetParametr(columName, value)
                }));
        }
Example #10
0
        public virtual (M, bool) GetByColumNameFist <M>(string columName, object value, params string[] selectColumn) where M : class, new()
        {
            string cmtext = query.GetByColumName <M>(columName, selectColumn);

            using (CommanderBase commander = DBContext.CreateCommander())
            {
                return(commander.ReaderFist <M>(cmtext, new List <DbParameter>()
                {
                    commander.SetParametr(columName, value)
                }));
            }
        }
Example #11
0
        public virtual bool Update <M>(string[] columns, object[] values, int id) where M : class, new()
        {
            string cmtext = query.Update <M>(id.ToString(), columns);
            var    p      = new List <DbParameter>();

            using (CommanderBase commander = DBContext.CreateCommander())
            {
                for (int i = 0; i < columns.Length; i++)
                {
                    p.Add(commander.SetParametr(columns[i], values[i]));
                }
                return(commander.NonQuery(cmtext, p));
            }
        }
Example #12
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);
                }
            }
        }
Example #13
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 #14
0
        public CommanderBase CreateCommander()
        {
            CommanderBase commander = null;;

            switch (ORMConfig.DbType)
            {
            case DbType.MSSQL:
                commander = new SqlCommander();
                break;

            case DbType.Oracle:
                commander = new OracleCommander();
                break;

            default:
                break;
            }
            return(commander);
        }
Example #15
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);
                }
            }
        }
Example #16
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);
                }
            }
        }