看了LINQ——Entity Inheritance这一节,发现完全不懂,
有几个问题需要问一下,还请各位大大帮忙。
1:映射继承层次结构是什么?它有什么用,和我下面这段代码定义的有什么区别
[Table(Name = "Employees")]
class Employee
{
[Column(Name = "EmployeeID")]
public int id;
[Column]
public string LastName;
}2:什么是InheritanceMapping,看代码为如下,下面的code type IsDefault 分别怎么解释 // 摘要:
// 映射 LINQ to SQL 应用程序中的继承层次结构。
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public sealed class InheritanceMappingAttribute : Attribute
{
// 摘要:
// 初始化 System.Data.Linq.Mapping.InheritanceMappingAttribute 类的一个新实例。
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public InheritanceMappingAttribute(); // 摘要:
// 获取或设置映射的继承层次结构中的鉴别器代码值。
//
// 返回结果:
// 必须由用户指定。没有默认值。
public object Code { get; set; }
//
// 摘要:
// 获取或设置一个值,该值指示当鉴别器值与指定值不匹配时是否实例化此类型的对象。
//
// 返回结果:
// Default = false.
public bool IsDefault { get; set; }
//
// 摘要:
// 获取或设置层次结构中类的类型。
//
// 返回结果:
// 必须由用户指定。没有默认值。
public Type Type { get; set; }
}
3:鉴别器是什么?在数据库中吗?4:这个Entity Inheritance也是为了映射数据库中的表吗?
有几个问题需要问一下,还请各位大大帮忙。
1:映射继承层次结构是什么?它有什么用,和我下面这段代码定义的有什么区别
[Table(Name = "Employees")]
class Employee
{
[Column(Name = "EmployeeID")]
public int id;
[Column]
public string LastName;
}2:什么是InheritanceMapping,看代码为如下,下面的code type IsDefault 分别怎么解释 // 摘要:
// 映射 LINQ to SQL 应用程序中的继承层次结构。
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public sealed class InheritanceMappingAttribute : Attribute
{
// 摘要:
// 初始化 System.Data.Linq.Mapping.InheritanceMappingAttribute 类的一个新实例。
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public InheritanceMappingAttribute(); // 摘要:
// 获取或设置映射的继承层次结构中的鉴别器代码值。
//
// 返回结果:
// 必须由用户指定。没有默认值。
public object Code { get; set; }
//
// 摘要:
// 获取或设置一个值,该值指示当鉴别器值与指定值不匹配时是否实例化此类型的对象。
//
// 返回结果:
// Default = false.
public bool IsDefault { get; set; }
//
// 摘要:
// 获取或设置层次结构中类的类型。
//
// 返回结果:
// 必须由用户指定。没有默认值。
public Type Type { get; set; }
}
3:鉴别器是什么?在数据库中吗?4:这个Entity Inheritance也是为了映射数据库中的表吗?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货