我正在使用linq在.NET中工作,我有一些行为可以放在dbml中定义的类中(比如.dbml方法),也可以放在包装dbml类的新类中。
这种情况在应用程序中重复了很多次,我想知道对于这种情况是否有最佳实践。
示例
//Adds methods to the Contact class created in the dbml
public partial class Contact
{
public Contact Load(int Id)
{
//Select and return a loaded Contact Object
}
}
//or
public class ContactWrapper
{
public Contact Load(int Id)
{
//Select and return a loaded Contact Object
}
}
//or some other way that I didn't realize发布于 2012-02-10 04:31:03
我只需创建另一个类部件,就像您在示例中所做的那样。这是扩展生成的类的常见模式。
https://stackoverflow.com/questions/9217763
复制相似问题