我有4个表格:
CREATE TABLE [Languages]
(
[Id] INTEGER IDENTITY(1,1) NOT NULL,
[Code] NVARCHAR(10) NOT NULL,
PRIMARY KEY ([Id]),
UNIQUE INDEX ([Code])
);
CREATE TABLE [Words]
(
[Id] INTEGER IDENTITY(1,1) NOT NULL,
PRIMARY KEY ([Id])
);
CREATE TABLE [WordTranslations]
(
[Id] INTEGER IDENTITY(1,1) NOT NULL,
[Value] NVARCHAR(100) NOT NULL,
[Word] INTEGER NOT NULL,
[Language] INTEGER NOT NULL,
PRIMARY KEY ([Id]),
FOREIGN KEY ([Word]) REFERENCES [Words] ([Id]),
FOREIGN KEY ([Language]) REFERENCES [Languages] ([Id])
);
CREATE TABLE [Categories]
(
[Id] INTEGER IDENTITY(1,1) NOT NULL,
[Word] INTEGER NOT NULL,
PRIMARY KEY ([Id]),
FOREIGN KEY ([Word]) REFERENCES [Words] ([Id])
);
因此,通过语言关系获得“语言”——和“语言”——和“语言关系”。
与此类似:
SELECT TOP 1 wt.Value
FROM [Categories] AS c
LEFT JOIN [WordTranslations] AS wt ON c.Word = wt.Word
WHERE wt.Language = (
SELECT TOP 1 l.Id
FROM [Languages]
WHERE l.[Code] = N en-US
)
AND c.Id = 1;
从而将Id = 1类的“美国”译文复封。
我的问题是,如何利用以下类别来绘制这一地图:
public class Category
{
public virtual int Id { get; set; }
public virtual IDictionary<string, string> Translations { get; set; }
}
采用上文KLQ的做法,就是:
Category category = session.Get<Category>(1);
string name = category.Translations["en-US"];
现在,“姓名”将包含美国名下的类别名称。
类别按照类别表排列。
你们怎样做,甚至可能这样做?