Exemple #1
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 #2
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 #3
0
 public abstract int PagingByList <K>(IList <T> entitys, IWhereGroup where, IPaing paing, JoinType Type, IList <ISorting> sortin = null, IList <IProperty> disabled = null) where K : DataEntity, new();
Exemple #4
0
 public abstract int PagingByList(IList <T> entitys, IPaing paing, IWhereGroup wheres, IList <ISorting> sortin = null, IList <IProperty> disabled = null);
Exemple #5
0
 public int PagingByList(IList <T> entitys, IPaing paing, IWhereGroup wheres, IList <ISorting> sortin = null, IList <IProperty> disabled = null)
 {
     return(this.DbService.PagingByList(entitys, paing, wheres, sortin, disabled));
 }
Exemple #6
0
 public int PagingByList <TForeign>(IList <T> entitys, IWhereGroup wheres, IPaing paing, JoinType Type, IList <ISorting> sortin = null, IList <IProperty> disabled = null)
     where TForeign : DataEntity, new()
 {
     return(this.DbService.PagingByList <TForeign>(entitys, wheres, paing, Type, sortin, disabled));
 }