【发布时间】:2012-04-09 22:56:06
【问题描述】:
我将我的问题引用到 Northwind LINQ to SQL C# 示例(取自 MSDN):
数据库包含一个名为Products 的表,其中有一个名为CategoryID 的字段。
因此,NorthWindDataClasses.designer.cs 文件包含一个名为 Product 的类,该类具有以下数据成员:
private System.Nullable<int> _CategoryID;
还有一个名为 Categories 的表,其中包含以下两个字段:
-
CategoryID。 -
CategoryName.
我想创建一个新类(在我的 Accessor.cs 文件中),其中包含 Product 类中的所有字段,但将有 CategoryName 而不是 _CategoryID。
实现它的最佳方法是什么?
【问题讨论】:
-
为什么?你不能通过 Product.Category.CategoryName 得到你想要的?
-
生成的
Product类不包含公共Category属性吗?
标签: c# linq linq-to-sql northwind