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)
    });
}
原文地址:https://www.cnblogs.com/wujiangling/p/11606685.html