2
我想提出一个新的,映射实体,看起来像这样:我可以将EF实体映射到具有多态外键的两个表吗?
public class PathedItem
{
public long Id { get; set; } // from the Items table
public string Name { get; set; } // from the Items table
public string Path { get; set; } // from the Paths table
}
的问题是,Path
是在不同的表比其他项目,这些表中的一个具有多态外键。这里是我的表:
CREATE TABLE Items (
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](255) NOT NULL)
CREATE TABLE Paths (
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[Path] [nvarchar](255) NOT NULL,
[ItemId] [bigint] NOT NULL,
[ItemType] [int] NOT NULL)
微软对映射实体两个表(here和here)HOWTO文档,但他们似乎依靠正常的外键。
有什么方法可以将Paths.ItemId
映射到Items.Id
,然后在连接中硬编码的值吗?
这是一个不错的主意,谢谢! – ladenedge 2011-02-03 14:56:51