Database Reference
In-Depth Information
Following is the output of the code in Listing 12-6:
All the Related Entities...
*** Chicken Risotto ***
Ingredients
1 Cup White Rice
6 Cups Chicken Broth
Steps
Bring Broth to a boil
Slowly add Broth to Rice
*** Baked Chicken ***
Ingredients
1 lb Chicken
Steps
Bake at 350 for 35 Minutes
After Related Entities are Deleted...
*** Chicken Risotto ***
Ingredients
1 Cup White Rice
6 Cups Chicken Broth
Steps
Bring Broth to a boil
Slowly add Broth to Rice
*** Baked Chicken ***
Ingredients
Steps
How It Works
Of course, there is no real performance benefit using the code in Listing 12-6. What is useful about this approach is that
it deletes all of the related entities without reference to any particular entity type. We could have loaded the second
recipe and simply marked each of the ingredients and steps for deletion, but this code snippet would be specific to
these entities in this model. The method in Listing 12-6 will work across all entity types and delete all related entities.
12-7. Assigning Default Values
Problem
You want to assign default values to the properties of an entity before it is saved to the database.
Solution
Let's say that you have a table similar to the one in Figure 12-9 , which holds information about a purchase order.
The key, PurchaseOrderId , is a GUID, and there are two columns holding the date and time for the creation and last
 
 
Search WWH ::




Custom Search