我有兩個班,其來自一個庫,即不能由我來改變:地圖只有一個子屬性
public class EntityInfo
{
public Guid Id { get; set; }
//... some other properties
}
public class MyEntity
{
public Guid MyEntityId { get; set; }
public EntityInfo AnotherEntityInfo { get; set; }
//... some other properties
}
我需要myEntity所與這些列映射到表:
MyEntityId uniqueidentifier,
AnotherEntityId uniqueidentifier -- Here the value of AnotherEntityInfo.Id should be mapped
-- ... some other properties
我不需要映射類型EntityInfo的其他屬性,只是Id。所以它就像是扁平化EntityInfo並只取其Id。再次,我不能更改類MyEntity和EntityInfo
有沒有人知道這樣做的方式?
兩個類到一個表。這是表分裂或複雜類型。這取決於您可以做的主要關鍵要求。也許你可以看看這些關鍵詞。 –