2012-06-06

In my previous post, I showed how to take a simple relationship between Customers and an one Detail per customer build that into a relationship that eagerly loaded the customer record when retrieving a Detail record with CodeFirst in EntityFramework.  Now, let’s extend that so that a customer has an Address associated with them. This means, the relationship is as follows:

Detail

    Customer

        Address

Or, using my favorite Sql Manager Tool http://www.sqlmanager.net/ from EMS Database Management Solutions:

 



 

The model is now as follows:

And the code to actually retrieve the data is now as follows (notice the type safe and non type safe include syntax.  Both work, but of course I prefer the type safe.

And the result running it is now:



HTH’s.

Show more