Skip to main content

Posts

Showing posts with the label group by multiple columns in linq to sql c#

group by multiple columns in linq to sql

Today's I have a requirement to  group multiple columns in linq to sql which are given below. The below  UserUsage table have  AParty_Subscriber,  ProductService,  NetworkID and  Unit columns. I am going to filter UserUsage table using  group by multiple columns. i.e. List < UserUsage > userUsages = ( from a in use                                              group a by new {                                                         a.AParty_Subscriber,               ...

group by multiple columns in linq to sql c#

This is basically used for " How to Group By multiple columns in LINQ to SQL? " [ Route ( "API/Use/GetUsageAlerts/{UserID}/{AccountID}" )] public IEnumerable < UsageAlerts > GetUsageAlerts( int UserID, int AccountID) {        DALUse ObjDalUse = new DALUse ();        Mapper mapper = new Mapper ();        List < UsageAlerts > usedAlerts = mapper.MapDALUsageAlerts2BAL(ObjDalUse.getAllUsageAlerts(UserID, AccountID));       List < UsageAlerts > userUsages = ( from used in usedAlerts                                group used by used.ProductServiceId into res                                select new UsageAlerts   ...