views:

41

answers:

1

I'm having a table which contains userId, regBy, regDate and so many..

I need a out of regDate, regBy and count(userId).

How can a query this using LINQ..

+2  A: 

From what I understand, you want to group by two fields, regDate and regBy. In that case, the select statement looks something like this:

    var myQuery = from User myUser in myContext.Users
                  group myUser by new { regDate = myUser.regDate , regBy = myUser.regBy } into g
                  select new
                  {
                      regDate = g.Key.regDate,
                      regBy = g.Key.regBy,
                      Count = g.Count()
                  };
Vedran
this is not working.. count is 1
santose
Are you sure you have records with the same regDate and regBy? Could you give me some sample data
Vedran