• 一条结合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();

  • 相关阅读:
    kindeditor 创建多个 取值方式
    新浪微博分享平台地址
    thinkphp 直接写SQL
    nginx下禁止目录运行php
    phpcms_v9 同步登陆的BUG
    yii framework 创建项目
    phpcms_v9 关闭debug
    ucenter忘记创始人密码简单解决方法
    XSS 常见手段
    如何在 C 中使用 64 位整数?
  • 原文地址:https://www.cnblogs.com/sky6699/p/4882231.html
Copyright © 2020-2023  润新知