Suppose one has an entity called SocialContact, which is inherited by
Person, and Person is in turn is inherited by PersonalFriend. (Personal Friend < Person < SocialContact) In order to access the derived entities, one has to use LINQ and the .OfType(Of
derivedtype) property on Entity. For instance,
' get list of SocialContacts and individual SocialContactDimSocialContactsAsList(OfSocialContact) = _
Selectsc).ToListDimSocialContactAsSocialContact = SocialContacts.First' get list of People & individual PersonDimPeopleAsList(OfPerson) = _
Selectp).ToListDimPersonAsPerson = People.First' get list of PersonalFriends & individual PersonalFriendDimPersonalFriendsAsList(OfPersonalFriend) = _
Selectp).ToListDimPersonalFriendAsPersonalFriend = PersonalFriends.First
a. Will this work on my version of VS/.NET/Entity Framework?
b. Where do I place this code in VS 2010/my project and how do I run it?
c. Will it work for all derived entities of all base entities in ANY project? Does it eliminate the need for the .TypeOf() stuff to get at the derived entities?
d. If I associate an entity, say X, with an entity Y, and entity Y1a is derived (directly or indirected) from Y, how will the project and code view and handle the relationship between X and Y1a? (see "QUESTION 2")
e. Is there anything else I should know (I'm not an expert at code-generation tools)?
QUESTION 2: Derived entities and associations with their base entities
If I associate a base entity (i.e., SocialContact) with another (non-derived) entity, say,
Address, how are the derived entities related to it, from a VB-code standpoint? That is, what's the relationship between
Person & Address, PersonalFriend & Address, etc.? (Are they the same as
SocialContact & Address?) Are there any special considerations I have to make, say, when cross-referencing
PersonalFriend and Adress in my code (vs. SocialContact &
Address)--say, when doing "join" queries and stuff?
QUESTION 3: Table-per-Heirarchy and Model-first
I'm using the model-first approach to my project. Can I do table-per-heirarchy inheritance under these conditions? (I know I can do table-per-type.)