0

这是我的查询。

 var query = from sbw in _sbwRepository.Table
                            orderby sbw.CountryId, sbw.StateProvinceId, sbw.Zip, sbw.ShippingMethodId, sbw.From                           
                            select sbw;

如何按“sbw.CountryId”分组?

4

1 回答 1

4

目前尚不清楚您要获得什么结果。例如,您可以只使用:

var query = from sbw in _sbwRepository.Table
            orderby sbw.CountryId, sbw.StateProvinceId, sbw.Zip,
                    sbw.ShippingMethodId, sbw.From                           
            group sbw by sbw.CountryId;

...或者group ... by ... into如果您想在之后做更多的工作,您可以使用。

有关更多示例,请参阅有关分组的 MSDN 页面。

于 2012-10-04T07:25:13.990 回答