Ef数据GroupBy多字段查询Vb.net与c#参考

Dim g = lst.Data.GroupBy(Function(T) New With
                                     {
                                          Key T.mName,
                                          Key T.mUnit,
                                          Key T.mPrice
                                     }).Select(Function(t) New With
                                        {
                                        .mName = t.Key.mName,
                                        .mPrice = t.Key.mPrice,
                                        .mUnit = t.Key.mUnit,
                                        .mValue = t.Sum(Function(i) i.mValue)
                                        })

 

c#版本对照

{
    var g = lst.Data.GroupBy(T => new
    {
        T.mName,
        T.mUnit,
        T.mPrice
    }).Select(t => new
    {
        mName = t.Key.mName,
        mPrice = t.Key.mPrice,
        mUnit = t.Key.mUnit,
        mValue = t.Sum(i => i.mValue)
    });
}

 

posted @ 2019-09-29 11:12  我们的家乡  阅读(421)  评论(0编辑  收藏  举报