Your SlideShare is downloading. ×
0
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Getting Persistence Ignorant with Entity Framework, Julie Lerman
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Getting Persistence Ignorant with Entity Framework, Julie Lerman

3,584

Published on

New England Code Camp 14 presentation on architecting applications that use ADO.NET Entity Framework with repositories, persistence ignorant classes and unit testing.

New England Code Camp 14 presentation on architecting applications that use ADO.NET Entity Framework with repositories, persistence ignorant classes and unit testing.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,584
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Getting Persistence Ignorant with Entity Framework<br />Julie Lermanthedatafarm.com<br />jlerman@thedatafarm.com<br />Twitter @julielerman<br />
  • 2. Julie Lerman<br />consultant/mentor<br />Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader<br />website<br />theDataFarm.com<br />blog &amp; twitter<br />theDataFarm.com/blog@julielerman<br />book web site<br />LearnEntityFramework.com<br />2nd Edition (EF4) is now available<br />
  • 3. Agenda<br />Background info<br />Restructure simple app<br />Explore complex solution<br />
  • 4. “-ilities”<br />Benefits:<br />Extensibility<br />Adaptability<br />Testability<br />Maintainability<br />Quality <br />Why should You Care?<br />Persistence Ignorance (PI)<br />Future-Proofing your investment<br />Slide courtesy of Stephen Bohlen<br />
  • 5. Persistence Dependence<br />Inherits from System.Data.Objects.ObjectContext<br />var context = new PublishingEntities();<br />var book= (from b in context select books<br /> where bookid=3)<br /> .First();<br />b.Status = “Sent to Printer”;<br />context.SaveChanges();<br />Entity Framework<br />method<br />Persistence Ignorance<br />varbookMgr = new BookManager();<br />var book=bookMgr.GetBook(3);<br />book.Status=“Sent to Printer”;<br />bookMgr.Update(book);<br />*your*<br />class<br />*your*<br />method<br />
  • 6. EF1 &amp; Default EF4 Classes<br />
  • 7. Dependencies<br />
  • 8. ObjectContext Manages Entities<br />POCO<br />“Snapshot”4.0<br />POCO<br />+ Dynamic Runtime Proxy <br />(4.0)<br />EntityObject<br />(3.5 &amp; 4.0)<br />ObjectContext<br />Person Object<br />State info<br />State info<br />Order Object<br />State info<br />Detail Object<br />State info<br />Detail Object<br />State info<br />Order Object<br />State info<br />Detail Object<br />State info<br />Detail Object<br />
  • 9. POCO Basics<br />With or without code generation<br />“Convention” will auto-map classes/entities<br />
  • 10. EF4 POCO Support<br />All entity properties must be represented<br />Hand Code<br />Code Generation with T4 and T4 templates<br />Snapshot<br />ObjectContext does all of the work<br />Lazy Loading<br />Virtual navigation properties<br />Dynamic Runtime Proxies<br />Mark all entity (model) properties as virtual<br />Proxy emulates EntityObject behavior<br />
  • 11. IObjectSet Abstraction<br />IObjectSet<br />Collection-like behavior<br />Add, Attach, Delete, etc.<br />ObjectSet<br />Concrete class<br />Implements IObjectSet<br />Inherits ObjectQuery<br />public class ObjectSet:ObjectQuery,IObjectSet<br />
  • 12. Classes<br />PI/Repositories<br />System.Data.Entity<br />Fake<br />ObjectSet<br />Fake<br />Context &amp; Data A<br />EDM &amp;<br />ObjectContext<br />Fake<br />Context &amp; Data B<br />Unit of Work<br />Class<br />Repositories<br />Class<br />Repositories<br />Class<br />Repositories<br />Class<br />Repositories<br />UI<br />Tests<br />
  • 13. Entity Framework 4<br />Supports POCO<br />Separation of concerns<br />Unit Testing<br />Coming soon:<br />Code First, currently in CTP4, not released<br />
  • 14. Resources<br />msdn.com/data<br />Learnentityframework.com<br />Testability and Entity Framework 4.0,Scott Allen, http://msdn.microsoft.com/en-us/ff714955.aspx<br />Agile Entity Framework 4 Repository: blog series<br />http://thedatafarm.com/blog/data-access/agile-entity-framework-4-repository-part-1-model-and-poco-classes/<br />
  • 15. Julie Lerman<br />consultant/mentor<br />Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader<br />website<br />theDataFarm.com<br />blog &amp; twitter<br />theDataFarm.com/blog@julielerman<br />book web site<br />LearnEntityFramework.com<br />2nd Edition (EF4) is now available<br />
  • 16. Your Feedback is Important<br />Please fill out a session evaluation form drop it off at the conference registration desk.<br />Thank you!<br />

×