Database Reference
In-Depth Information
The code in Listing 2-7 produces the following results:
147 Expandable Hydration Pack $19.97 /pack147.jpg
178 Rugged Ranger Duffel Bag $39.97 /pack178.jpg
186 Range Field Pack $98.97 /noimage.jpg
202 Small Deployment Back Pack $29.97 /pack202.jpg
2-7. Splitting a Table Among Multiple Entities
Problem
You have a table with some frequently used fields and a few large, but rarely needed fields. For performance reasons,
you want to avoid needlessly loading these expensive fields on every query. You want to split the table across two or
more entities.
Solution
Let's say that you have a table like the one shown in Figure 2-16 , which holds information about photographs as well
as the bits for both the thumbnail and full-resolution image of the photograph.
Figure 2-16. A Photograph table with a field holding the binary large object (blob) representing the data for the image
To create an entity type that contains the reasonably low-cost and frequently used columns, as well as an entity
type containing the high-cost but rarely used HighResolutionBits column, do the following:
1.
Create a new class in your project that inherits from DbContext.
2.
Create a Photograph POCO entity class using the code in Listing 2-12.
 
 
Search WWH ::




Custom Search