Reputation: 217
I have a common table to store Comments on my system like this:
id <- PK
Text <- user content
userId
createdAt
commentType <- a discriminator, to know which entity is the parent of this comment ie: N: News, A:Articles, and so on...
typeId <- Id of the parent entity
I worked before with this type of structure using nhibernate like this:
mapping.HasMany(x=> x.Comments)
.Cascade.All()
.Inverse()
.Where("commentType='A'")
.KeyColumn("typeId")
How do i work this type of structure on EF4?
Upvotes: 0
Views: 29
Reputation: 11987
i think this tutorial is what you are looking for.
basically you have to create an entity for each kind of descriptor, and the where is housed in the entity, not the mapping.
Upvotes: 2