如何将类映射到数据库表?
我有类,需要按照Class 1制作数据表
public class EventType { public String Id { get; private set; } public int Severity { get; set; } public EventTypeTemplate Template { get; set; } public IDictionary Params { get; set; } public EventType(string id) { Id = id; Params = new Dictionary(); } }
和二等
public class EventTypeTemplate { public String Id { get; private set; } public int Severity { get; set; } public String Title { get; set; } public String Description { get; set; } public IList Categories { get; private set; } public IList Queries { get; private set; } public EventTypeTemplate(string id) { Id = id;Categories = new List(); Queries = new List(); } }
对于类1(EventType),我创建表作为表名EventType
Column type Id string Severity int
我不知道如何将这些属性输入到表列名称和类型中
public EventTypeTemplate Template { get; set; } public IDictionary Params { get; set; }
对于第二类我创建表名EventTypeTemplate
Column Type Id string Severity int Title string Description string
但我不知道如何将follow属性输入表列名和类型
public IList Categories { get; private set; } public IList Queries { get; private set; }
任何帮助将不胜感激
对于Template
,在EventType
表中,将一个外键添加到EventTypeTemplate
( EventTypeTemplateId ):
EventType --------- Column Type Id string Severity int EventTypeTemplateId int
对于Params
创建一个包含三列的Params
表:
Params ------ Column Type EventTypeId string Key string Value string
对于Categories
创建一个名为Categories
的表:
Categories ---------- EventTypeTemplateId string CategoryName string
对于Queries
创建一个名为Queries
的表:
Queries ---------- EventTypeTemplateId string Query string