I am facing EntityCommandException when I try to print out LINQ results. This is my code:
var contacts = from c in db.mydata
join r in db.contacts on c.user equals r.user
group c by new { c.user, r.name }
into g
orderby g.Count() descending
select new { name= g.Key.name , counter = g.Count() } ;
foreach (var co in contacts )
{
Console.Write(co.name);
}
The exception is at the foreach line. If in the foreach loop I print Console.Write(co.counter);
, the exception doesn't show up.