zoukankan      html  css  js  c++  java
  • 一条结合where、group、orderby的linq语法

    DataTable dt = (from x in dsResult.Tables[0].AsEnumerable()

                                    where DataTrans.CBoolean(x["IsChecked"]) == true

                                    group x by new

                                    {

                                        no = x.Field<string>("NO"),

                                        ptno = x.Field<string>("PTNO"),

                                        ver = x.Field<int>("VER"),

                                        kd = x.Field<string>("KD"),

                                        que_da = Convert.ToDateTime(x.Field<DateTime>("QUE_DA").ToString("yyyy/MM/dd"))

                                    } into g

                                    orderby g.Key.no,g.Key.ptno,g.Key.ver,g.Key.kd,g.Key.que_da

                                    select new

                                    {

                                        qty = g.Sum(x => Convert.ToInt32(x["QUE_QTY"])),

                                      stock=g.Sum(x=>Convert.ToInt32(x["STOCK"])),

                                      no=g.Key.no ,

                                      ptno=g.Key.ptno,

                                      ver=g.Key.ver,

                                      kd=g.Key.kd,

                                      que_da=g.Key.que_da

                                    }).ConvertDataTable();

  • 相关阅读:
    正则表达式  语法
    正则表达式  语法
    SQL Server 删除日志文件
    SQL Server 删除日志文件
    C# CLR简介
    C# CLR简介
    理解 C# 项目 csproj 文件格式的本质和编译流程
    理解 C# 项目 csproj 文件格式的本质和编译流程
    De4Dot+Reflector 支持多种反混淆
    De4Dot+Reflector 支持多种反混淆
  • 原文地址:https://www.cnblogs.com/sky6699/p/4882231.html
Copyright © 2011-2022 走看看