Contact.Where
("it.MiddleName IS NOT NULL").OrderBy("it.LastName");
You can also do something like the following, which returns an entity type:
private AdventureWorksEntities productSalesContext;
string qry = @"SELECT VALUE Contact FROM AdventureWorksEntities.Contact";
ObjectQuery
con = new ObjectQuery(qry, productSalesContext);
Likewise, you can create and use an ObjectQueryclass with parameters:
private AdventureWorksEntities productSalesContext;
string qry = @"SELECT VALUE Contact FROM AdventureWorksEntities.Contact WHERE
Contact.LastName = @lastname AND Contat.FirstName = @fn";
ObjectQuery con = new ObjectQuery(qry, productSalesContext);
con.Parameters.Add(new ObjectParameter("ln","Klein"));
con.Parameters.Add(new ObjectParameter("fn","Jason"));
You can also use an ObjectQuery class to return primitive and anonymous types, and you can shape
the results:
private AdventureWorksEntities productSalesContext;
ObjectQuery con = salesPerson.Include("SalesOrderHeader
.SalesOrderDetail");
340
Appendix B: LINQ to Entities: The ADO.
Pages:
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527