I guess I'm not quite sure how the Linq inheritance is supposed to work.
I have a "User" entity and I want to have two additional entities called "Creator" and "Assigned" that inherit from the "User" entity (basically they should just have the same exact properties as the User entity) I don't need any additional properties. I can do this just fine in the designer.
The problem is that when I try to associate the inherited entities with another entity - I don't have access to any of the properties from the base entity. Am I not supposed to have access to those to tie to other entities? Seems to me like I should.
-
This sounds more like a relationship rather than inheritance to me. That is all of the entities are users, but some users have a creator relationship to others and some have an assigned relationship. Probably the easiest way to model this is to have a join table for creators and another for assignees. Create foreign key relationships back to the user table from both columns in the join table. When you drag all of these tables onto the designer surface, each user will get createdBy/created and assignee/assigned to entity sets. Your db constraints, I presume, will limit it so that each user only has one creator and a user isn't assigned to more than one other use (or maybe not, depending on your rules).
user table user_id int identity not null primary key user_name varchar .... created_by created_by_id int identity not null primary key creator int not null, FK to user.user_id createe int not null, FK to user.user_id (with a unique index on creator/createe -- or both could be the PK) (constraint creator <> createe) assigned_to assigned_to_id int identity not null primary key owner_id int not null, FK to user.user_id assignee_id int not null, FK to user.user_id (with a unique index on assignee_id -- or not) (constraint owner_id <> assignee_id -- or not)
0 comments:
Post a Comment