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); }
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); }
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())} "); }
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)} "); }
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)} "); }
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())}"); }
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())}"); }
public override void DeleteBatBuilder(IWhereGroup where) { this._sqltext = new StringBuilder($"delete {this._mapper.TableName} {(where == null ? string.Empty : where.ToString())}"); }
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; }
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; }