Building n-Tier ASP.NET Web Forms with Entity Framework<br />Julie Lermanthedatafarm.com<br />jlerman@thedatafarm.com<br /...
Julie Lerman<br />consultant/mentor<br />Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader<br />website<br />t...
Agenda<br />EF Challenges in Web Apps<br />Review WebForm Options with EF<br />EF4 Tools to the Rescue<br />POCOs and Repo...
The ASP.net Spectrum with EF<br />Dynamic Data forEntities<br />ObjectDataSource<br />EntityDataSource<br />MVC<br />ADO.N...
Change Tracking Across Tiers<br />ObjectContext<br />ObjectStateEntry<br />SO1 EntityKey Original ValuesCurrent Values Oth...
SaveChanges Fails Across Post Backs<br />Page Request<br />Post Back #1<br />Post Back #2<br />New Page Class<br />New Pag...
EF4 Changes to the Rescue<br />Foreign Keys<br />Big help for selected list values on postback<br />State Methods<br />App...
What about?<br />Graphs<br />Lazy Loading<br />Returning IQueryables<br />Change<br />Tracking<br />
POCO Basics<br />With or without code gen from EDMX<br />“Convention” will auto-map classes/entities<br />
EF Related Architectural Choices<br />Classes<br />vs.<br />Repositories<br />vs.<br />
Basic Pattern for ASP.NET n-Tier<br />Code Behind<br />Business Logic<br />Repository<br />Transient ObjectContext, Querie...
Julie Lerman<br />consultant/mentor<br />Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader<br />website<br />t...
Your Feedback is Important<br />Please fill out a session evaluation form drop it off at the conference registration desk....
Upcoming SlideShare
Loading in …5
×

Building n-Tier ASP.NET WebForms with Entity Framework 4, Lerman

8,989 views

Published on

New England Code Camp 14 presentation on tips & tricks for using new features in EF4 when building WebForms applications with Entity Framework. by Julie Lerman.

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

No Downloads
Views
Total views
8,989
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Abtract: Creating n-tier applications with Entity Framework got a whole lot easier in .NET 4.0. But if you are using ASP.NET Web Forms, there are still some tricks that you’ll need to know, especially if you are not a fan of using the binding sources, such as EntityDataSource and ObjectDataSource. In this session, you’ll see how to create a bridge between your Web Forms and a repository which serves up Entity Framework entities. You’ll lean some of the tools you’ll need to handle related datasuch as master-detail and foreign key
  • Building n-Tier ASP.NET WebForms with Entity Framework 4, Lerman

    1. 1. Building n-Tier ASP.NET Web Forms with Entity Framework<br />Julie Lermanthedatafarm.com<br />jlerman@thedatafarm.com<br />Twitter @julielerman<br />
    2. 2. Julie Lerman<br />consultant/mentor<br />Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader<br />website<br />theDataFarm.com<br />blog & twitter<br />theDataFarm.com/blog@julielerman<br />book web site<br />LearnEntityFramework.com<br />2nd Edition (EF4) is now available<br />
    3. 3. Agenda<br />EF Challenges in Web Apps<br />Review WebForm Options with EF<br />EF4 Tools to the Rescue<br />POCOs and Repositories<br />Leveraging Foreign Keys<br />Putting it all together<br />
    4. 4. The ASP.net Spectrum with EF<br />Dynamic Data forEntities<br />ObjectDataSource<br />EntityDataSource<br />MVC<br />ADO.NET<br />Data<br />Services<br />Dev<br />WCF<br />n-Tier<br />Architect<br />
    5. 5. Change Tracking Across Tiers<br />ObjectContext<br />ObjectStateEntry<br />SO1 EntityKey Original ValuesCurrent Values Other ∆ Info <br />ObjectStateEntry<br />SO2 EntityKeyOriginal ValuesCurrent ValuesOther ∆ Info <br />detach<br />entities<br />ObjectStateEntry<br />LIA EntityKeyOriginal ValuesCurrent ValuesOther ∆ Info <br />Original Property Values<br />EntityState Values<br />ObjectStateEntry<br />LIB EntityKeyOriginal ValuesCurrent ValuesOther ∆ Info <br />
    6. 6. SaveChanges Fails Across Post Backs<br />Page Request<br />Post Back #1<br />Post Back #2<br />New Page Class<br />New Page Class<br />New Page Class<br />Create New ObjectContext<br />Create NewObjectContext<br />Create NewObjectContext<br />Get Entities<br />Process Request<br />Get Entities<br />Build HTML using Data & ASP.NET Markup<br />Build HTML using Data & ASP.NET Markup<br />Build HTML using Data & ASP.NET Markup<br />Destroy Page and Dependents<br />Destroy Page and Dependents<br />Destroy Page and Dependents<br />
    7. 7. EF4 Changes to the Rescue<br />Foreign Keys<br />Big help for selected list values on postback<br />State Methods<br />ApplyCurrentValues, ApplyOriginalValues<br />ChangeState<br />ChangeRelationshipState (when no FKs)<br />POCO Classes & T4 Generation<br />
    8. 8. What about?<br />Graphs<br />Lazy Loading<br />Returning IQueryables<br />Change<br />Tracking<br />
    9. 9. POCO Basics<br />With or without code gen from EDMX<br />“Convention” will auto-map classes/entities<br />
    10. 10. EF Related Architectural Choices<br />Classes<br />vs.<br />Repositories<br />vs.<br />
    11. 11. Basic Pattern for ASP.NET n-Tier<br />Code Behind<br />Business Logic<br />Repository<br />Transient ObjectContext, Queries<br />CacheEntityKeys, Scalars (inc FKs)<br />Foreign Keys make this <br />approach a possibility<br />Entity Framework<br />
    12. 12. Julie Lerman<br />consultant/mentor<br />Microsoft MVP, INETA Speaker,ASPInsider, MCP, VTdotNET Leader<br />website<br />theDataFarm.com<br />blog & twitter<br />theDataFarm.com/blog@julielerman<br />book web site<br />LearnEntityFramework.com<br />2nd Edition (EF4) is now available<br />
    13. 13. Your Feedback is Important<br />Please fill out a session evaluation form drop it off at the conference registration desk.<br />Thank you!<br />

    ×