Exemple #1
0
        public override void UpdateBatBuilder(IWhereGroup where, IList <IProperty> disabled = null)
        {
            var propertys = MySqlDBbatBuilder <T> .FilterUpdateProperty(_mapper, disabled);

            this._sqltext = new StringBuilder();
            this._sqltext.Append($"update {this._mapper.TableName} set {string.Join(",", propertys)}  {(where == null ? string.Empty : where.ToString())}");
        }
Exemple #2
0
        public override T SelectSingle(IWhereGroup wheres, IEnumerable <Polymerize> polymerizes, IList <IProperty> disable)
        {
            IList <T> list = new List <T>();

            this.Select(list, 1, wheres, polymerizes, disable, null);
            return(list.SingleOrDefault());
        }
Exemple #3
0
        public override T SelectSingle <K>(IWhereGroup wheres, JoinType join, IEnumerable <IProperty> disable)
        {
            IList <T> list = new List <T>();

            this.Select <K>(list, 1, wheres, join, disable);
            return(list.SingleOrDefault());
        }
Exemple #4
0
        public override int PagingByList(IList <T> entitys, IPaing paing, IWhereGroup wheres, IList <ISorting> sortin = null, IList <IProperty> disabled = null)
        {
            object rownum, s = null;

            if (wheres != null)
            {
                var d     = new DynamicHandlerCompiler <object>();
                var itmes = wheres.GetCreaterDynamicClassPropertys();
                var type  = d.CreaterAnonEntity("anonClass", itmes);
                s = Activator.CreateInstance(type, CreaterDynamicClassProperty.GetValues(itmes));
            }
            this.BatBuilder.SelectBatBuilder(wheres, new Polymerize[] { new Polymerize(this.Mapper.PrimaryKey, PolymerizeType.Count, "a") });
            this.ExecuteScalar(s, out rownum);
            paing.SetCount((int)rownum);
            if (paing.PageNum > 1)
            {
                var p = SqlDBbatBuilder <T> .FilterProperty(this.Mapper, disabled);

                sortin = SqlDBbatBuilder <T> .InitiSorting(this.Mapper, sortin);

                var str = new StringBuilder($"select  * from  ");
                str.Append($"(select  top({paing.PageNumber * paing.Showline})  {string.Join(",", p)}, row_number() over(order by {string.Join(",", sortin)} ) as row  from {this.Mapper.TableName}    ");
                str.Append($"{(wheres == null ? string.Empty : wheres.ToString())}) as paging ");
                str.Append($"where row>{paing.Showline * (paing.PageNumber - 1)}");
                var bar = new SqlDBbatBuilder <T>(this.Mapper);
                bar.Additional(str.ToString(), wheres);
                this.Execute(entitys, bar, s);
            }
            else
            {
                this.Select(entitys, wheres, disabled, sortin);
            }
            return(paing.Count);
        }
Exemple #5
0
        public IEnumerable <T> GetList(IWhereGroup where, int num = -1)
        {
            var es = new List <T>();

            this.DbService.Select(es, num, where, null, null, null);
            return(es);
        }
Exemple #6
0
        public IEnumerable <T> GetList <TForeign>(IWhereGroup where, int num, JoinType join, IEnumerable <IProperty> disabled, IList <ISorting> Sorting) where TForeign : DataEntity, new()
        {
            var es = new List <T>();

            this.DbService.Select <TForeign>(es, num, where, join, disabled, Sorting);
            return(es);
        }
Exemple #7
0
        public override dynamic Update(T entity, IWhereGroup where, IList <IProperty> disabled = null)
        {
            int rownum;

            this.BatBuilder.UpdateBatBuilder(where, disabled);
            this.ExecuteNonQuery(entity, out rownum);
            return(rownum);
        }
Exemple #8
0
        public override dynamic Update(T entity, IList <UpdateProperty> propertys, IWhereGroup where)
        {
            int rownum;

            this.BatBuilder.UpdateBatBuilder(where, propertys);
            this.ExecuteNonQuery(entity, out rownum);
            return(rownum);
        }
Exemple #9
0
        public override dynamic Delete(IWhereGroup where)
        {
            if (where == null)
            {
                throw new DbExecuteException("删除命令 条件参数不可以为空");
            }
            int rownum;

            this.BatBuilder.DeleteBatBuilder(where);
            this.ExecuteNonQuery(null, out rownum);
            return(rownum);
        }
Exemple #10
0
        public override void SelectBatBuilder <K>(IWhereGroup where, int num, JoinType Type, IEnumerable <IProperty> disabled, IList <ISorting> sortin)
        {
            sortin = InitiSorting(this._mapper, sortin);
            var kMapper      = (IEntityMapper <K>)EntityMapperCacheManager.GetMapperCacheManager()[typeof(K).Name].Value;
            var fok          = (from t in _mapper.Relevances where t.Type == typeof(K) select t).SingleOrDefault();
            var relevanceStr = string.Empty;

            this._propertys = FilterProperty <K>(this._mapper, kMapper, fok, Type, out relevanceStr);
            this._sqltext   = new StringBuilder();
            this._sqltext.Append($"select  {(num > 0 ? $" top({num})" : string.Empty) }   {string.Join(",", this._propertys)} ");
            this._sqltext.Append($"from {relevanceStr}  {(where == null ? string.Empty : where.ToString())}");
            this._sqltext.Append(sortin == null ? string.Empty : $" order by {string.Join(",", sortin)} ");
        }
Exemple #11
0
        public override void SelectBatBuilder(IWhereGroup where, int num, IEnumerable <Polymerize> polymerizes, IList <ISorting> sortin, IList <IProperty> disabled)
        {
            string polymerizeText;

            sortin          = InitiSorting(this._mapper, sortin);
            this._propertys = MySqlDBbatBuilder <T> .FilterProperty(_mapper, polymerizes, disabled ?? new List <IProperty>(), out polymerizeText);

            this._sqltext = new StringBuilder();
            this._sqltext.Append($"select  {(num > 0 ? $" top({num})" : string.Empty) } {polymerizeText} {string.Join(",", this._propertys)} ");
            this._sqltext.Append($"from {this._mapper.TableName} {(where == null ? string.Empty : where.ToString())}");
            this._sqltext.Append(sortin == null ? string.Empty : $" order by {string.Join(",", sortin)} ");
            this._sqltext.Append(polymerizes == null ? string.Empty : $" group by {string.Join(",", this._propertys)} ");
        }
Exemple #12
0
        public override void ScalarBatBuilder <K>(IWhereGroup where, int num, JoinType Type, IEnumerable <Polymerize> polymerizes, IEnumerable <IProperty> disabled, IList <ISorting> sortin)
        {
            sortin = InitiSorting(this._mapper, sortin);
            var kMapper      = (IEntityMapper <K>)EntityMapperCacheManager.GetMapperCacheManager()[typeof(K).Name].Value;
            var fok          = (from t in _mapper.Relevances where t.Type == typeof(K) select t).SingleOrDefault();
            var relevanceStr = string.Empty;

            this._propertys = FilterProperty <K>(this._mapper, kMapper, fok, Type, out relevanceStr, disabled, polymerizes);
            var filed_str      = string.Join(",", this._propertys);
            var polymerizeText = polymerizes == null ? string.Empty : $"{string.Join(",", polymerizes)} {(string.IsNullOrWhiteSpace(filed_str)?string.Empty:",")}";

            this._sqltext = new StringBuilder();
            this._sqltext.Append($"select {string.Join(",", polymerizes)}  ");
            this._sqltext.Append($"from {relevanceStr}  {(where == null ? string.Empty : where.ToString())}");
            this.where = where;
        }
Exemple #13
0
        public override void SelectBatBuilder <K1, K2>(IWhereGroup where, int num, JoinType Type, IEnumerable <IProperty> disabled, IList <ISorting> sortin)
        {
            sortin = InitiSorting(this._mapper, sortin);
            var mp           = EntityMapperCacheManager.GetMapperCacheManager();
            var k1Mapper     = (IEntityMapper <K1>)mp[typeof(K1).Name].Value;
            var k2Mapper     = (IEntityMapper <K2>)mp[typeof(K2).Name].Value;
            var FK           = (from t in _mapper.Relevances where t.Type == typeof(K1) || t.Type == typeof(K2) select t).ToArray();
            var relevanceStr = string.Empty;

            this._propertys = FilterProperty <K1, K2>(this._mapper, k1Mapper, k2Mapper, FK, Type, out relevanceStr, disabled);
            var filed_str = string.Join(",", this._propertys);

            this._sqltext = new StringBuilder();
            this._sqltext.Append($"select  {(num > 0 ? $" top({num})" : string.Empty) }   {string.Join(",", this._propertys)} ");
            this._sqltext.Append($"from {relevanceStr}  {(where == null ? string.Empty : where.ToString())}");
            this._sqltext.Append(sortin == null ? string.Empty : $" order by {string.Join(",", sortin)} ");
            this.where = where;
        }
Exemple #14
0
        public override int PagingByList <K>(IList <T> entitys, IWhereGroup wheres, IPaing paing, JoinType Type, IList <ISorting> sortin = null, IList <IProperty> disabled = null)

        {
            object rownum, s = null;

            if (wheres != null)
            {
                var d     = new DynamicHandlerCompiler <object>();
                var itmes = wheres.GetCreaterDynamicClassPropertys();
                var type  = d.CreaterAnonEntity("anonClass", itmes);
                s = Activator.CreateInstance(type, CreaterDynamicClassProperty.GetValues(itmes));
            }
            this.BatBuilder.ScalarBatBuilder <K>(wheres, -1, Type, new Polymerize[] { new Polymerize(this.Mapper.PrimaryKey, PolymerizeType.Count, "a", this.Mapper.TableName) }, null, null);
            this.ExecuteScalar(s, out rownum);
            paing.SetCount((int)rownum);
            if (paing.PageNum > 1)
            {
                sortin = SqlDBbatBuilder <T> .InitiSorting(this.Mapper, sortin);

                var kMapper      = (IEntityMapper <K>)EntityMapperCacheManager.GetMapperCacheManager()[typeof(K).Name].Value;
                var fok          = (from t in this.Mapper.Relevances where t.Type == typeof(K) select t).SingleOrDefault();
                var relevanceStr = string.Empty;
                var p            = SqlDBbatBuilder <T> .FilterProperty <K>(this.Mapper, kMapper, fok, Type, out relevanceStr);

                var str = new StringBuilder($"select * from  ");
                str.Append($"(select  top({paing.PageNumber * paing.Showline}) {string.Join(",", p)}, row_number() over(order by {string.Join(",", sortin)} ) as row  from {relevanceStr}    ");
                str.Append($"{(wheres == null ? string.Empty : wheres.ToString())}) as paging ");
                str.Append($"where row>{paing.Showline * (paing.PageNumber - 1)}");
                var bar = new SqlDBbatBuilder <T>(this.Mapper);
                bar.Additional(str.ToString(), wheres);
                this.Execute <K>(entitys, bar, s);
            }
            else
            {
                this.Select <K>(entitys, paing.Showline, wheres, Type, disabled);
            }
            return(paing.Count);
        }
Exemple #15
0
 public abstract void SelectBatBuilder(IWhereGroup where, int num, IEnumerable <Polymerize> polymerizes, IList <ISorting> sortin, IList <IProperty> disabled);
Exemple #16
0
 public abstract void SelectBatBuilder(IWhereGroup where, IEnumerable <Polymerize> polymerizes);
Exemple #17
0
 public abstract void DeleteBatBuilder(IWhereGroup where);
Exemple #18
0
 public void Additional(string str, IWhereGroup where)
 {
     this._sqltext = this._sqltext ?? new StringBuilder();
     this._sqltext.AppendLine(str);
     this.where = where;
 }
Exemple #19
0
 public override void SelectBatBuilder(IWhereGroup where, IEnumerable <Polymerize> polymerizes)
 {
     this._sqltext = new StringBuilder();
     this._sqltext.Append($"select {string.Join(",", polymerizes)}  from { this._mapper.TableName} {(where == null ? string.Empty : where.ToString())} ");
 }
Exemple #20
0
 public override void Select(T entity, IWhereGroup wheres, IEnumerable <Polymerize> polymerizes, IList <IProperty> disabled = null, IList <ISorting> sortin = null)
 {
     throw new NotImplementedException();
 }
Exemple #21
0
 public override void Select(IList <T> entitys, IWhereGroup wheres, IList <IProperty> disabled = null, IList <ISorting> sortin = null)
 {
     this.Select(entitys, -1, wheres, null, disabled, sortin);
 }
Exemple #22
0
 public override void UpdateBatBuilder(IWhereGroup where, IList <UpdateProperty> Property)
 {
     this._sqltext = new StringBuilder($"update {this._mapper.TableName} set {string.Join(",", Property)}  {(where == null ? string.Empty : where.ToString())}");
 }
Exemple #23
0
 public override void DeleteBatBuilder(IWhereGroup where)
 {
     this._sqltext = new StringBuilder($"delete {this._mapper.TableName} {(where == null ? string.Empty : where.ToString())}");
 }
Exemple #24
0
 public override void Select(IList <T> entitys, int num, IWhereGroup wheres, IEnumerable <Polymerize> polymerizes, IList <IProperty> disable, IList <ISorting> sortin)
 {
     this.BatBuilder.SelectBatBuilder(wheres, num, polymerizes, sortin, disable);
     this.ExecuteReader(entitys);
 }
Exemple #25
0
 public abstract void UpdateBatBuilder(IWhereGroup where, IList <UpdateProperty> Property);
Exemple #26
0
 public abstract void SelectBatBuilder <K>(IWhereGroup where, int num, JoinType Type, IEnumerable <IProperty> disabled, IList <ISorting> sortin);
Exemple #27
0
 public abstract void ScalarBatBuilder <K>(IWhereGroup where, int num, JoinType Type, IEnumerable <Polymerize> polymerizes, IEnumerable <IProperty> disabled, IList <ISorting> sortin);
Exemple #28
0
 public override void ScalarBatBuilder <K>(IWhereGroup where, int num, JoinType Type, IEnumerable <Polymerize> polymerizes, IEnumerable <IProperty> disabled, IList <ISorting> sortin)
 {
     throw new NotImplementedException();
 }
Exemple #29
0
 public abstract void UpdateBatBuilder(IWhereGroup where, IList <IProperty> disabled = null);
Exemple #30
0
 public override void SelectBatBuilder <K1, K2>(IWhereGroup where, int num, JoinType Type, IEnumerable <IProperty> disabled, IList <ISorting> sortin)
 {
     throw new NotImplementedException();
 }