expression for GroupBy in entity framework -




i have class named employee , 1 method returns list of employee;

public class employee {   public int id { get; set; }   public string name { get; set; }   public string course { get; set; }   public string score { get; set; } } 

and method :

public static list<employee> getemployees() {  var list = new list<employee>();   list.add(new employee { id=1, name="xx", course="c1", score="16"});  list.add(new employee { id=2, name="aa", course="c1", score="17"});  list.add(new employee { id=3, name="bb", course="c1", score="16"});    list.add(new employee { id=4, name="dd", course="c2", score="12"});  list.add(new employee {id=5, name="ee", course="c2", score="13"});    list.add(new employee { id=6, name="ff", course="c3", score="15"});  list.add(new employee { id=7, name="gg", course="c3", score="15"});   return list; } 

i want write query group employee items in list . example following query categorize items score , course;

var list = employeerepository.getstudentdata(); var result = list.groupby(x => new { x.course, x.score }).select(items => items.tolist()).tolist(); 

how wary count of parameter in group clause expressions or other ways know result;

consider should name of parameter categorize user;

maybe next time can :

var result = list.groupby(x => new { x.course, x.score , x.name }).select(items => items.tolist()).tolist(); 

thanks in advance





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -