开发者

How do i work with EF4 using this table structure

开发者 https://www.devze.com 2023-03-14 10:41 出处:网络
I have a common table to store Comments on my system like this: id<- PK Text <- user content userId

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消