Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LINQ to SQL grouping error in default VS object visualizer

I am trying to use the code below to group employees by department. I get the error

The type '<>f__AnonymousType1' exists in both 'Interview.Web.dll' and 'System.Web.dll'

when trying to enumerate the employees in a department in the default visualizer (the + icon when you hover over the variable name). I can enumerate the departments properly though.

var employees = from emp in db.Employees
                join dep in db.Departments
                    on emp.DepartmentID equals dep.ID
                select new
                            {
                                DepartmentName = dep.Name,
                                EmployeeName = emp.FullName
                            };
var depEmps = employees.GroupBy(de => de.DepartmentName);

If I add a watch on depEmps, the watch window correctly enumerates both collections, and actual code also works properly.

Grouping is something I have always avoided in LINQ, always chickening out by doing it in the DB and including a view in my model, but I suppose I have to deal with it some time.

like image 888
ProfK Avatar asked Aug 06 '26 19:08

ProfK


1 Answers

On closer inspection, I only get the error inspecting the grouping with the default visualizer. Even in a proper watch window, and also in code, the enumerating works properly, so the grouping is working fine, just the visualizer seems a bit funny.

like image 156
ProfK Avatar answered Aug 09 '26 11:08

ProfK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!