LINQ to sql return group by results from method
Posted
by petebob796
on Stack Overflow
See other posts from Stack Overflow
or by petebob796
Published on 2010-03-25T12:22:11Z
Indexed on
2010/03/25
12:23 UTC
Read the original article
Hit count: 266
linq-to-sql
How do I create a method to return the results of a group by in LINQ to sql such as the one below:
internal SomeTypeIDontKnow GetDivisionsList(string year)
{
var divisions = from p in db.cm_SDPs
where p.acad_period == year
group p by new
{
p.Division
} into g
select new
{
g.Key.Division
};
return divisions;
}
I can't seem to define a correct return type. I think it is because it's an anonymous type but haven't got my head around it yet. Do I need to convert it to a list or something?
The results would just be used for filling a combo box.
© Stack Overflow or respective owner