Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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)));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 5
0
        public virtual bool Delet(int id)
        {
            string cmtext = query.Delete(id.ToString());

            using (CommanderBase commander = DBContext.CreateCommander())
                return(commander.NonQuery(cmtext));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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)
                }));
        }
Ejemplo n.º 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)
                }));
        }
Ejemplo n.º 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)
                }));
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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);
                }
            }
        }