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 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()); }
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()); }
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 IEnumerable <T> GetList(IWhereGroup where, int num = -1) { var es = new List <T>(); this.DbService.Select(es, num, where, null, null, null); return(es); }
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); }
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); }
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); }
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); }
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 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 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; }
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 abstract void SelectBatBuilder(IWhereGroup where, int num, IEnumerable <Polymerize> polymerizes, IList <ISorting> sortin, IList <IProperty> disabled);
public abstract void SelectBatBuilder(IWhereGroup where, IEnumerable <Polymerize> polymerizes);
public abstract void DeleteBatBuilder(IWhereGroup where);
public void Additional(string str, IWhereGroup where) { this._sqltext = this._sqltext ?? new StringBuilder(); this._sqltext.AppendLine(str); this.where = where; }
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 Select(T entity, IWhereGroup wheres, IEnumerable <Polymerize> polymerizes, IList <IProperty> disabled = null, IList <ISorting> sortin = null) { throw new NotImplementedException(); }
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); }
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 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); }
public abstract void UpdateBatBuilder(IWhereGroup where, IList <UpdateProperty> Property);
public abstract void SelectBatBuilder <K>(IWhereGroup where, int num, JoinType Type, IEnumerable <IProperty> disabled, IList <ISorting> sortin);
public abstract void ScalarBatBuilder <K>(IWhereGroup where, int num, JoinType Type, IEnumerable <Polymerize> polymerizes, IEnumerable <IProperty> disabled, IList <ISorting> sortin);
public override void ScalarBatBuilder <K>(IWhereGroup where, int num, JoinType Type, IEnumerable <Polymerize> polymerizes, IEnumerable <IProperty> disabled, IList <ISorting> sortin) { throw new NotImplementedException(); }
public abstract void UpdateBatBuilder(IWhereGroup where, IList <IProperty> disabled = null);
public override void SelectBatBuilder <K1, K2>(IWhereGroup where, int num, JoinType Type, IEnumerable <IProperty> disabled, IList <ISorting> sortin) { throw new NotImplementedException(); }