Database Reference
In-Depth Information
In the C-S mapping section, inside the <EntityContainerMapping> tag, enter the
QueryView code shown in Listing 6-32.
9.
Listing 6-32. QueryView for Mapping the Member Table to the Derived Types Teen, Adult, and Senior
<EntitySetMapping Name="Members">
<QueryView>
select value
case
when m.Age &lt; 20 then
EFRecipesModel.Teen(m.MemberId,m.Name,m.Phone,m.Age)
when m.Age between 20 and 55 then
EFRecipesModel.Adult(m.MemberId,m.Name,m.Phone,m.Age)
when m.Age > 55 then
EFRecipesModel.Senior(m.MemberId,m.Name,m.Phone,m.Age)
end
from EFRecipesModelStoreContainer.Member as m
</QueryView>
</EntitySetMapping>
The resulting model should look like the one in Figure 6-17 .
Figure 6-17. The resulting model with Member and the three derived types: Senior, Adult, and Teen
How It Works
Entity Framework supports only a limited set of conditions when modeling Table per Hierarchy inheritance. In this
recipe, we extended the conditions using QueryView to define our own mappings between the underlying Member
table and the derived types: Senior, Adult, and Teen. This is shown in Listing 6-32.
 
Search WWH ::




Custom Search