How do I use group by in LINQ? I want to group by tow filed of table in C# by linq.
            Asked
            
        
        
            Active
            
        
            Viewed 1,614 times
        
    0
            
            
        - 
                    can you provide some code sample? – sarwar026 Apr 23 '12 at 09:52
- 
                    http://msdn.microsoft.com/en-us/library/bb534304.aspx – Arion Apr 23 '12 at 09:55
- 
                    possible duplicate question http://stackoverflow.com/questions/1869001/linq-group-by-multiple-fields-syntax-help – pmtamal Apr 23 '12 at 10:02
1 Answers
1
            var query =
    from t in db.tableName    
    group t by new { t.column1, t.column2 } into g
    select new { g.Key.column1, g.Key.column2 };
 
    
    
        sarwar026
        
- 3,821
- 3
- 26
- 37
 
    