如何将类映射到数据库表?
我有课程,需要制作如下数据表 第 1 类
public class EventType
{
public String Id { get; private set; }
public int Severity { get; set; }
public EventTypeTemplate Template { get; set; }
public IDictionary<String, String> Params { get; set; }
public EventType(string id)
{
Id = id;
Params = new Dictionary<string, string>();
}
}
和第二类
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<String> Categories { get; private set; }
public IList<String> Queries { get; private set; }
public EventTypeTemplate(string id)
{
Id = id;Categories = new List<string>();
Queries = new List<string>();
}
}
对于第 1 类(EventType),我创建表 作为表名称 EventType
Column type
Id string
Severity int
我不知道如何将这些属性输入到
public EventTypeTemplate Template { get; set; }
public IDictionary<String, String> Params { get; set; }
第二类的表列名称和类型中 我创建表名称 EventTypeTemplate
Column Type
Id string
Severity int
Title string
Description string
但我不知道如何将以下属性输入表列名称并输入
public IList<String> Categories { get; private set; }
public IList<String> Queries { get; private set; }
任何帮助,我们将不胜感激
I'm have classes and need to make data tables as follow
Class 1
public class EventType
{
public String Id { get; private set; }
public int Severity { get; set; }
public EventTypeTemplate Template { get; set; }
public IDictionary<String, String> Params { get; set; }
public EventType(string id)
{
Id = id;
Params = new Dictionary<string, string>();
}
}
And second class
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<String> Categories { get; private set; }
public IList<String> Queries { get; private set; }
public EventTypeTemplate(string id)
{
Id = id;Categories = new List<string>();
Queries = new List<string>();
}
}
For class 1(EventType) I create the table
As table name EventType
Column type
Id string
Severity int
And I don’t know how to enterprate these property into table column name and type
public EventTypeTemplate Template { get; set; }
public IDictionary<String, String> Params { get; set; }
for second class
I create table name EventTypeTemplate
Column Type
Id string
Severity int
Title string
Description string
But I don’t know how to enterprate follow property into table column name and type
public IList<String> Categories { get; private set; }
public IList<String> Queries { get; private set; }
any help will be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于
Template
,在EventType
表中,向EventTypeTemplate
添加外键 (EventTypeTemplateId):对于
Params
创建一个包含三列的Params
表:对于
Categories
创建一个名为Categories
的表:对于
Queries
code> 创建一个名为Queries
的表:For
Template
, in theEventType
table, add a foreign key to theEventTypeTemplate
(EventTypeTemplateId):For
Params
create aParams
table with three columns:For
Categories
create a table calledCategories
:For
Queries
create a table calledQueries
: