aruni
aruni

Reputation: 2752

how to use groupby in mvc?

This is my query .

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

How to groupby "sbw.CountryId" ?

Upvotes: 0

Views: 118

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1499730

It's not clear what results you're trying to get. For example, you could just use:

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

... or you could use group ... by ... into if you want to do more work afterwards.

See the MSDN page on grouping for more examples.

Upvotes: 4

Related Questions