Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Convert this to non SQL like LINQ
Message
De
09/10/2014 10:36:42
John Baird
Coatesville, Pennsylvanie, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01609048
Message ID:
01609051
Vues:
61
>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();
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform