Entity Framework - Queries

3,861 views

Published on

Entity Framework - Queries

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,861
On SlideShare
0
From Embeds
0
Number of Embeds
1,665
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Entity Framework - Queries

  1. 1. EF Queries Eyal Vardi CEO E4D Solutions LTD Microsoft MVP Visual C# blog: www.eVardi.com
  2. 2. Agenda LINQ to Entity EDM Entities SQL Conceptu Object Services al Model Mapping Entity Client Provider Storage Model ADO.NET Provider  EF Architecture  Development Approaches  Entity Data Model (EDM)  Object Services  Querying & Loading Entities© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
  3. 3. EF Architecture from c in db.Customers where c.City == "London" Application select new { c.Name, c.Phone } LINQ Query Objects SubmitChanges() Services: Entity Framework - Change tracking EDMX - Concurrency control - Object identity ADO.NET Provider SQL Query Rows SQL or Stored Procs select Name, Phone from customers where city = London SQLServer© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
  4. 4. EF Architecture LINQ to Entities Entity SQL EDM Conceptual Object Services Model Mapping Entity Client Provider Storage ADO.NET Provider Model SQLServer© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
  5. 5. LINQ to Entity EDM Entities SQL Conceptu Object Services al Model Mapping Entity Client Provider Storage Model ADO.NET Provider Querying & Loading Entities© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
  6. 6. Entity SQL & LINQ to Entities  LINQ to Entities - The LINQ dialect that enables typed queries against the model.  Entity SQL - The second way of querying the object model.  Entity SQL is string-based.  Can be used to retrieve data at low level, directly using the Entity Client.© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
  7. 7. Entity SQL Queries  The SqlQuery method on DbSet allows a raw SQL query to be written that will return entity instances.  The returned objects will be tracked by the context just as they would be if there were returned by a LINQ query.  The query is not executed until the results are enumerated© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
  8. 8. SQL Queries for none Entity Types  The results returned from SqlQuery on Database will never be tracked by the context even if the objects are instances of an entity type.© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
  9. 9. Stored Procedures© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
  10. 10. SP Sample© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
  11. 11. Updating Data with SP© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
  12. 12. Functions© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il

×