예제 #1
0
        public new string Visit(System.Linq.Expressions.Expression exp)
        {
            base.Visit(exp);
            var str = IEnumerableHelper.ToString(SqlList.Reverse());

            return(str.Length > 0 ? str : "*");
        }
예제 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DateTime start = this.dtStart.SelectedDate ?? DateTime.Now;
            DateTime end   = this.dtEnd.SelectedDate ?? DateTime.Now;

            System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
            sfd.DefaultExt = "xls";
            sfd.Filter     = "Excel文件(*.xls)|*.xls";
            sfd.Title      = "导出文件路径";
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                DataTable dt      = IEnumerableHelper.ToDataTable <LR.Services.ConsumeDataModel>(this._service.GetExtractList(start, end.AddDays(1)));
                String[]  columns = { "StaffNo", "StaffName", "RoomNo", "RoomName", "Amount", "Admin", "CreateDate", "ModifyDate" };
                String[]  names   = { "员工号", "姓名", "房间号", "房间", "金额", "操作人", "创建时间", "修改时间" };
                DataView  dv      = dt.DefaultView;
                dt = dv.ToTable(true, columns);

                DataRow dr = dt.NewRow();
                dr["RoomName"] = "总计";
                dr["Amount"]   = dt.Compute("sum(Amount)", "");
                dt.Rows.Add(dr);

                for (int i = 0; i < columns.Length; i++)
                {
                    dt.Columns[columns[i]].ColumnName = names[i];
                }

                ExcelHelper.DataTableToExcel(dt, sfd.FileName);
            }
            this.Close();
        }
        public void MergeSortedArrays()
        {
            CollectionAssert.AreEqual(new int[0],
                                      IEnumerableHelper.MergeSortedArrays(new int[0], new int[0]));

            CollectionAssert.AreEqual(new[] { 1 },
                                      IEnumerableHelper.MergeSortedArrays(new[] { 1 }, new int[0]));
            CollectionAssert.AreEqual(new[] { 1 },
                                      IEnumerableHelper.MergeSortedArrays(new int[0], new[] { 1 }));

            CollectionAssert.AreEqual(new[] { 1, 1 },
                                      IEnumerableHelper.MergeSortedArrays(new int[0], new[] { 1, 1 }));
            CollectionAssert.AreEqual(new[] { 1, 1, 1 },
                                      IEnumerableHelper.MergeSortedArrays(new[] { 1 }, new[] { 1, 1 }));

            CollectionAssert.AreEqual(new[] { 1, 1, 2, 2, 3, 3, 4, 4 },
                                      IEnumerableHelper.MergeSortedArrays(new[] { 1, 1, 2, 3, 4, 4 }, new[] { 2, 3 }));

            for (int i = 0; i < 100; ++i)
            {
                for (int j = 0; j < 100; ++j)
                {
                    var firstArray  = InputGenerator.GenerateRandomInts(i);
                    var secondArray = InputGenerator.GenerateRandomInts(i);
                    Array.Sort(firstArray);
                    Array.Sort(secondArray);

                    CollectionAssert.AreEqual(firstArray.Concat(secondArray).OrderBy(v => v).ToArray(),
                                              IEnumerableHelper.MergeSortedArrays(firstArray, secondArray));
                }
            }
        }
    public Task GetById(long id)
    {
        var command    = new SqlCommand(GetByIdCommand);
        var parameters = IEnumerableHelper.ToEnumerable <SqlParameter>(new SqlParameter(GetByIdCommandIdParameter, GetByIdCommandIdParameterType, id));
        var dataTable  = db.ExecuteToDataTable(command, parameters);

        return(DataTableToTask(dataTable)[0]);
    }
예제 #5
0
 private bool CheckCacheData(object data)
 {
     if (data == null)
     {
         return(false);
     }
     if (data.IsCollection() && IEnumerableHelper.IsNullOrEmpty((IEnumerable)data))
     {
         return(false);
     }
     return(true);
 }
예제 #6
0
        public void GetNumberOfOrders(List <Pizza> pizzas)
        {
            var toppings = pizzas.Select(p => p.toppings);

            foreach (var topping in toppings)
            {
                if (!_pizzas.Keys.Any(item => IEnumerableHelper.ScrambledEquals(item, topping)))
                {
                    var count = toppings.Count(item => IEnumerableHelper.ScrambledEquals(item, topping));
                    _pizzas.Add(topping, count);
                }
            }
        }
예제 #7
0
        public void 開門位置の書き込みができる()
        {
            // 001:南/上/4
            var context = DiProvider.GetContainer().GetInstance <FieldContext>();

            context.OpenGatePosition.Wind  = Wind.Index.South;
            context.OpenGatePosition.Rank  = Wall.Rank.Upper;
            context.OpenGatePosition.Index = 4;
            var actual   = this.Target.Convert(context);
            var expected = IEnumerableHelper.IEnumerableToString(FileHelper.ReadTextLines(this.GetResourcePath(4, 1, ResourceType.Out)));

            Assert.AreEqual(expected, actual);
        }
예제 #8
0
        /// <summary>
        /// 全ての牌のリストを組み立てます
        /// </summary>
        /// <returns>全ての牌のリスト</returns>
        private static IEnumerable <uint> BuildTiles()
        {
            var numbers    = Enumerable.Range(1, 9);
            var count      = Enumerable.Range(0, 4);
            var kinds      = IEnumerableHelper.GetEnums <Tile.Kind>().Where(k => k != Tile.Kind.Undefined);
            var suitsTiles = kinds.Where(k => k.GetGroup() == Tile.Group.Suits).
                             SelectMany(k => numbers, (k, n) => $"{n}{Tile.JapaneseName.Get(k)}").
                             SelectMany(t => count, (t, c) => t);
            var honoursTiles = kinds.Where(k => k.GetGroup() == Tile.Group.Honours).
                               SelectMany(k => count, (k, i) => Tile.JapaneseName.Get(k));
            var tiles = suitsTiles.Concat(honoursTiles);

            return(tiles.Select(Tile.BuildTile));
        }
예제 #9
0
        public override PointDataSourceBase TryBuild(object data)
        {
            var types = IEnumerableHelper.GetGenericInterfaceArgumentTypes(data, typeof(IDataSource2D <>));

            if (types != null && types.Length > 0)
            {
                Type genericDataSource2DType = typeof(GenericDataSource2D <>).MakeGenericType(types);
                var  result     = Activator.CreateInstance(genericDataSource2DType, data);
                var  dataSource = (PointDataSourceBase)result;
                return(dataSource);
            }

            return(null);
        }
        public override bool TryBuild(object data, out PointDataSourceBase dataSource)
        {
            dataSource = null;

            var types = IEnumerableHelper.GetGenericInterfaceArgumentTypes(data, typeof(IEnumerable <>));

            if (types != null && types.Length == 1)
            {
                Type genericIEnumerableType = typeof(GenericIEnumerableDataSource <>).MakeGenericType(types);
                var  result = Activator.CreateInstance(genericIEnumerableType, data);
                dataSource = (PointDataSourceBase)result;
                return(true);
            }

            return(false);
        }
예제 #11
0
        public void 手牌の書き込みができる()
        {
            // 001:全ての風が存在している
            var context = DiProvider.GetContainer().GetInstance <FieldContext>();

            Wind.ForEach((wind) =>
            {
                context.Hands[wind.ToInt()].Add(Tile.BuildTile(Tile.Kind.East));
                context.Hands[wind.ToInt()].Add(Tile.BuildTile(Tile.Kind.West));
                context.Hands[wind.ToInt()].Add(Tile.BuildTile(Tile.Kind.South));
                context.Hands[wind.ToInt()].Add(Tile.BuildTile(Tile.Kind.North));
                context.Hands[wind.ToInt()].Add(Tile.BuildTile(Tile.Kind.Characters, 1));
                context.Hands[wind.ToInt()].Add(Tile.BuildTile(Tile.Kind.Bamboos, 2));
                context.Hands[wind.ToInt()].Add(Tile.BuildTile(Tile.Kind.Circles, 3));
                context.Hands[wind.ToInt()].Add(Tile.BuildTile(Tile.Kind.WhiteDragon));
                context.Hands[wind.ToInt()].Add(Tile.BuildTile(Tile.Kind.GreenDragon));
                context.Hands[wind.ToInt()].Add(Tile.BuildTile(Tile.Kind.RedDragon));
                context.Hands[wind.ToInt()].Add(Tile.BuildTile(Tile.Kind.Characters, 4));
                context.Hands[wind.ToInt()].Add(Tile.BuildTile(Tile.Kind.Bamboos, 5, true));
                context.Hands[wind.ToInt()].Add(Tile.BuildTile(Tile.Kind.Circles, 6));
            });
            var actual   = this.Target.Convert(context);
            var expected = IEnumerableHelper.IEnumerableToString(FileHelper.ReadTextLines(this.GetResourcePath(1, 1, ResourceType.Out)));

            Assert.AreEqual(expected, actual);

            // 002:一部の風のみ存在する
            context = DiProvider.GetContainer().GetInstance <FieldContext>();
            context.Hands[Wind.Index.South.ToInt()].Add(Tile.BuildTile(Tile.Kind.East));
            context.Hands[Wind.Index.South.ToInt()].Add(Tile.BuildTile(Tile.Kind.West));
            context.Hands[Wind.Index.South.ToInt()].Add(Tile.BuildTile(Tile.Kind.South));
            context.Hands[Wind.Index.South.ToInt()].Add(Tile.BuildTile(Tile.Kind.North));
            context.Hands[Wind.Index.South.ToInt()].Add(Tile.BuildTile(Tile.Kind.Characters, 1));
            context.Hands[Wind.Index.South.ToInt()].Add(Tile.BuildTile(Tile.Kind.Bamboos, 2));
            context.Hands[Wind.Index.South.ToInt()].Add(Tile.BuildTile(Tile.Kind.Circles, 3));
            context.Hands[Wind.Index.South.ToInt()].Add(Tile.BuildTile(Tile.Kind.WhiteDragon));
            context.Hands[Wind.Index.South.ToInt()].Add(Tile.BuildTile(Tile.Kind.GreenDragon));
            context.Hands[Wind.Index.South.ToInt()].Add(Tile.BuildTile(Tile.Kind.RedDragon));
            context.Hands[Wind.Index.South.ToInt()].Add(Tile.BuildTile(Tile.Kind.Characters, 4));
            context.Hands[Wind.Index.South.ToInt()].Add(Tile.BuildTile(Tile.Kind.Bamboos, 5, true));
            context.Hands[Wind.Index.South.ToInt()].Add(Tile.BuildTile(Tile.Kind.Circles, 6));
            actual   = this.Target.Convert(context);
            expected = IEnumerableHelper.IEnumerableToString(FileHelper.ReadTextLines(this.GetResourcePath(1, 2, ResourceType.Out)));
            Assert.AreEqual(expected, actual);
        }
예제 #12
0
        /// <summary>
        ///     排序解析入口
        /// </summary>
        /// <param name="lstExp"></param>
        public virtual string Visit(Dictionary <System.Linq.Expressions.Expression, bool> lstExp)
        {
            if (lstExp == null)
            {
                return(null);
            }
            var lst = new List <string>();

            foreach (var keyValue in lstExp)
            {
                Visit(keyValue.Key);
                while (SqlList.Count > 0)
                {
                    lst.Add($"{SqlList.Pop()} {(keyValue.Value ? "ASC" : "DESC")}");
                }
                //SqlList.Push();
            }
            lst.Reverse();
            return(IEnumerableHelper.ToString(lst, ", "));
        }
        private void btnExtract_Click(object sender, EventArgs e)
        {
            if (this.lvwShow.ItemsSource == null)
            {
                Tip p = new Tip("当前账期没有数据 !");
                p.ShowDialog();
                return;
            }
            System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
            sfd.DefaultExt = "xls";
            sfd.Filter     = "Excel文件(*.xls)|*.xls";
            sfd.Title      = "导出文件路径";
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                DataTable dt      = IEnumerableHelper.ToDataTable <RoyaltySettleExpendModel>((IEnumerable <RoyaltySettleExpendModel>) this.lvwShow.ItemsSource);
                String[]  columns = { "StaffNo", "StaffName", "Reservation", "Administration", "Cooperation", "Transcend", "WorkGroup", "Total", "Expend", "Self", "Receiver", "Admin", "ExpandTimeStr" };
                String[]  names   = { "员工号", "姓名", "订房奖励", "管理奖励", "协助奖励", "超越奖励", "工作组管理奖励", "总金额", "是否已发", "是否本人领取", "领取人", "操作人", "领取时间" };


                DataRow dr = dt.NewRow();
                dr["StaffName"]      = "总计";
                dr["Reservation"]    = dt.Compute("sum(Reservation)", "");
                dr["Administration"] = dt.Compute("sum(Administration)", "");
                dr["Cooperation"]    = dt.Compute("sum(Cooperation)", "");
                dr["Transcend"]      = dt.Compute("sum(Transcend)", "");
                dr["WorkGroup"]      = dt.Compute("sum(WorkGroup)", "");
                dr["Total"]          = dt.Compute("sum(Total)", "");
                dt.Rows.Add(dr);

                DataView dv = dt.DefaultView;
                dt = dv.ToTable(true, columns);
                for (int i = 0; i < columns.Length; i++)
                {
                    dt.Columns[columns[i]].ColumnName = names[i];
                }
                ExcelHelper.DataTableToExcel(dt, sfd.FileName);
            }
        }
예제 #14
0
 /// <summary>
 /// 使用可能な風のリストを取得します。
 /// </summary>
 /// <returns>使用可能な風のリスト</returns>
 public IEnumerable <Wind.Index> GetAvailableWinds()
 {
     return(IEnumerableHelper.GetEnums <Wind.Index>().
            Where(w => w != Wind.Index.Undefined).
            Except(this.Players.Select(p => p.Key)));
 }
예제 #15
0
        public void 壁牌の書き込みができる()
        {
            // 001:全ての風が存在している
            var context = DiProvider.GetContainer().GetInstance <FieldContext>();

            Wind.ForEach(wind =>
            {
                Wall.ForEachRank(rank =>
                {
                    context.Walls[wind.ToInt()][rank.ToInt()][0]  = Tile.BuildTile(Tile.Kind.East);
                    context.Walls[wind.ToInt()][rank.ToInt()][1]  = Tile.BuildTile(Tile.Kind.West);
                    context.Walls[wind.ToInt()][rank.ToInt()][2]  = Tile.BuildTile(Tile.Kind.South);
                    context.Walls[wind.ToInt()][rank.ToInt()][3]  = Tile.BuildTile(Tile.Kind.North);
                    context.Walls[wind.ToInt()][rank.ToInt()][4]  = Tile.BuildTile(Tile.Kind.Characters, 1);
                    context.Walls[wind.ToInt()][rank.ToInt()][5]  = Tile.BuildTile(Tile.Kind.Bamboos, 2);
                    context.Walls[wind.ToInt()][rank.ToInt()][6]  = Tile.BuildTile(Tile.Kind.Circles, 3);
                    context.Walls[wind.ToInt()][rank.ToInt()][7]  = Tile.BuildTile(Tile.Kind.WhiteDragon);
                    context.Walls[wind.ToInt()][rank.ToInt()][8]  = Tile.BuildTile(Tile.Kind.GreenDragon);
                    context.Walls[wind.ToInt()][rank.ToInt()][9]  = Tile.BuildTile(Tile.Kind.RedDragon);
                    context.Walls[wind.ToInt()][rank.ToInt()][10] = Tile.BuildTile(Tile.Kind.Characters, 4);
                    context.Walls[wind.ToInt()][rank.ToInt()][11] = Tile.BuildTile(Tile.Kind.Bamboos, 5, true);
                    context.Walls[wind.ToInt()][rank.ToInt()][12] = Tile.BuildTile(Tile.Kind.Circles, 6);
                    context.Walls[wind.ToInt()][rank.ToInt()][13] = Tile.BuildTile(Tile.Kind.East);
                    context.Walls[wind.ToInt()][rank.ToInt()][14] = Tile.BuildTile(Tile.Kind.West);
                    context.Walls[wind.ToInt()][rank.ToInt()][15] = Tile.BuildTile(Tile.Kind.South);
                    context.Walls[wind.ToInt()][rank.ToInt()][16] = Tile.BuildTile(Tile.Kind.North);
                });
            });
            var actual   = this.Target.Convert(context);
            var expected = IEnumerableHelper.IEnumerableToString(FileHelper.ReadTextLines(this.GetResourcePath(2, 1, ResourceType.Out)));

            Assert.AreEqual(expected, actual);

            // 002:一部の風が存在している
            context = DiProvider.GetContainer().GetInstance <FieldContext>();
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][0]  = Tile.BuildTile(Tile.Kind.East);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][1]  = Tile.BuildTile(Tile.Kind.West);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][2]  = Tile.BuildTile(Tile.Kind.South);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][3]  = Tile.BuildTile(Tile.Kind.North);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][4]  = Tile.BuildTile(Tile.Kind.Characters, 1);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][5]  = Tile.BuildTile(Tile.Kind.Bamboos, 2);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][6]  = Tile.BuildTile(Tile.Kind.Circles, 3);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][7]  = Tile.BuildTile(Tile.Kind.WhiteDragon);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][8]  = Tile.BuildTile(Tile.Kind.GreenDragon);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][9]  = Tile.BuildTile(Tile.Kind.RedDragon);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][10] = Tile.BuildTile(Tile.Kind.Characters, 4);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][11] = Tile.BuildTile(Tile.Kind.Bamboos, 5, true);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][12] = Tile.BuildTile(Tile.Kind.Circles, 6);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][13] = Tile.BuildTile(Tile.Kind.East);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][14] = Tile.BuildTile(Tile.Kind.West);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][15] = Tile.BuildTile(Tile.Kind.South);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][16] = Tile.BuildTile(Tile.Kind.North);
            actual   = this.Target.Convert(context);
            expected = IEnumerableHelper.IEnumerableToString(FileHelper.ReadTextLines(this.GetResourcePath(2, 2, ResourceType.Out)));
            Assert.AreEqual(expected, actual);

            // 003:一部の牌のみ存在する
            context = DiProvider.GetContainer().GetInstance <FieldContext>();
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][0]  = Tile.BuildTile(Tile.Kind.East);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][1]  = Tile.BuildTile(Tile.Kind.West);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][2]  = Tile.BuildTile(Tile.Kind.South);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][3]  = Tile.BuildTile(Tile.Kind.North);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][4]  = Tile.BuildTile(Tile.Kind.Characters, 1);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][5]  = Tile.BuildTile(Tile.Kind.Bamboos, 2);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][6]  = Tile.BuildTile(Tile.Kind.Circles, 3);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][7]  = Tile.BuildTile(Tile.Kind.WhiteDragon);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][8]  = Tile.BuildTile(Tile.Kind.GreenDragon);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][9]  = Tile.BuildTile(Tile.Kind.RedDragon);
            context.Walls[Wind.Index.North.ToInt()][Wall.Rank.Upper.ToInt()][10] = Tile.BuildTile(Tile.Kind.Characters, 4);
            actual   = this.Target.Convert(context);
            expected = IEnumerableHelper.IEnumerableToString(FileHelper.ReadTextLines(this.GetResourcePath(2, 3, ResourceType.Out)));
            Assert.AreEqual(expected, actual);
        }
예제 #16
0
        /// <summary>
        ///     查询多条记录
        /// </summary>
        /// <param name="pageSize">每页显示数量</param>
        /// <param name="pageIndex">分页索引</param>
        /// <param name="isDistinct">返回当前条件下非重复数据</param>
        public virtual ISqlParam ToList(int pageSize, int pageIndex, bool isDistinct = false)
        {
            // 不分页
            if (pageIndex == 1)
            {
                ToList(pageSize, isDistinct);
                return(this);
            }

            var strSelectSql   = SelectVisitor.Visit(ExpBuilder.ExpSelect);
            var strWhereSql    = WhereVisitor.Visit(ExpBuilder.ExpWhere);
            var strOrderBySql  = OrderByVisitor.Visit(ExpBuilder.ExpOrderBy);
            var strDistinctSql = isDistinct ? "Distinct " : string.Empty;

            Check.IsTure(string.IsNullOrWhiteSpace(strOrderBySql) && ExpBuilder.SetMap.PhysicsMap.PrimaryFields.Count == 0, "不指定排序字段时,需要设置主键ID");

            strOrderBySql = "ORDER BY " + (string.IsNullOrWhiteSpace(strOrderBySql) ? $"{IEnumerableHelper.ToString(ExpBuilder.SetMap.PhysicsMap.PrimaryFields.Select(o => o.Value.Name))} ASC" : strOrderBySql);
            var strOrderBySqlReverse = strOrderBySql.Replace(" DESC", " [倒序]").Replace("ASC", "DESC").Replace("[倒序]", "ASC");

            if (!string.IsNullOrWhiteSpace(strWhereSql))
            {
                strWhereSql = "WHERE " + strWhereSql;
            }

            Sql.Append(string.Format("SELECT {0}TOP {2} {1} FROM (SELECT TOP {3} * FROM {4} {5} {6}) a  {7}", strDistinctSql, strSelectSql, pageSize, pageSize * pageIndex, DbProvider.KeywordAegis(Name), strWhereSql, strOrderBySql, strOrderBySqlReverse));
            return(this);
        }
예제 #17
0
 /// <summary>
 ///     将List转换成字符串
 /// </summary>
 /// <param name="lst">要拼接的LIST</param>
 /// <param name="sign">分隔符</param>
 public static string ToString(this IEnumerable lst, string sign = ",")
 {
     return(IEnumerableHelper.ToString(lst, sign));
 }
예제 #18
0
 /// <summary>
 /// 有効な全ての牌種を取得します。
 /// </summary>
 /// <returns>有効な全ての牌種</returns>
 public static IEnumerable <Kind> GetAllValidKinds()
 {
     return(IEnumerableHelper.GetEnums <Kind>()
            .Where(k => k != Kind.Undefined && k != Kind.Empty));
 }
예제 #19
0
 public new string Visit(Expression exp)
 {
     base.Visit(exp);
     return(IEnumerableHelper.ToString(SqlList.Reverse(), " AND "));
 }
예제 #20
0
 /// <summary>
 /// 包含的数字值是否存在
 /// </summary>
 /// <param name="fieldName">字段名称</param>
 /// <param name="lstParamName">多个值</param>
 /// <param name="isNot">true:不存在</param>
 public virtual string In(string fieldName, List <string> lstParamName, bool isNot) => $"{fieldName} {(isNot ? "Not" : "")} IN ({IEnumerableHelper.ToString(lstParamName)})";
예제 #21
0
        public override ISqlParam ToList(int pageSize, int pageIndex, bool isDistinct = false)
        {
            // 不分页
            if (pageIndex == 1)
            {
                ToList(pageSize, isDistinct);
                return(this);
            }

            var strSelectSql  = SelectVisitor.Visit(ExpBuilder.ExpSelect);
            var strWhereSql   = WhereVisitor.Visit(ExpBuilder.ExpWhere);
            var strOrderBySql = OrderByVisitor.Visit(ExpBuilder.ExpOrderBy);

            var strDistinctSql = isDistinct ? "Distinct" : string.Empty;

            if (!string.IsNullOrWhiteSpace(strWhereSql))
            {
                strWhereSql = "WHERE " + strWhereSql;
            }

            Check.IsTure(string.IsNullOrWhiteSpace(strOrderBySql) && (ExpBuilder.SetMap.PhysicsMap.PrimaryFields.Count == 0), "不指定排序字段时,需要设置主键ID");

            strOrderBySql = "ORDER BY " + (string.IsNullOrWhiteSpace(strOrderBySql) ? $"{IEnumerableHelper.ToString(ExpBuilder.SetMap.PhysicsMap.PrimaryFields.Select(o => o.Value.Name), ",")} ASC" : strOrderBySql);

            Sql.Append(string.Format("SELECT {1} FROM (SELECT {0} {1},ROW_NUMBER() OVER({2}) as Row FROM {3} {4}) a WHERE Row BETWEEN {5} AND {6}", strDistinctSql, strSelectSql, strOrderBySql, DbProvider.KeywordAegis(Name), strWhereSql, (pageIndex - 1) * pageSize + 1, pageIndex * pageSize));
            return(this);
        }