Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert this to non SQL like LINQ
Message
From
09/10/2014 10:36:42
John Baird
Coatesville, Pennsylvania, United States
 
General information
Forum:
ASP.NET
Category:
LINQ
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01609048
Message ID:
01609051
Views:
60
>Hi all, is the code below rewritable in non SQL like syntax
>
>
>int NumEmployees = 4;
>
>GridView1.DataSource = (from department in dbContext.Department
>                                    where department.Employee.Count > NumEmployees
>                                    orderby department.Name
>                                    select new
>                                    {
>                                        Name = department.Name ,
>                                        Employees = department.Employee // this is a collection.
>                                    }).ToList();
>
>
>just learning LINQ and wondered how to do this in the more dot way e.g obj.Where(x => x.Whatever == Whatever);

Not tested:
dbContext.Department.Where(w=>w.Employee.Count > NumEmployees)
                                    .OrderBy(o=>o.department.Name)
                                    .Select(s => new {Name = s.Department.Name, Employees = s.Department.Employee})
                                    .ToList();
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform