在这样的背景下,我研究了如何将一些linq扩展到sql类
public partial class aspnet_User
{
MainDataContext _dc = new MainDataContext();
public MainDataContext DataContext
{
get
{
return _dc;
}
set
{
_dc = value;
}
}
public static aspnet_User GetUser(Guid guid)
{
//Here I load the user and associated child tables.
//I set the datacontext for the aspnet_User with the local DC here
}
//_dc.SubmitChanges()
public SaveUser()
所以,这是我采用的设计结构,它似乎对我的案例很有效。我的部分问题是我正在使用这个内置的成员结构,并试图添加到它,这比重新创建自己的成员结构更容易,但有一定的局限性。诚然,对象接口的确切组合并不理想,因为有些功能是跨数据库表分层的,无论好坏。
我的问题是,对于一些子对象,例如aspnet_成员资格,我还使用它自己的DC扩展了它。但是,目前还没有一种机制可以让我在不手动设置的情况下更新所有孩子的DC。
我希望看到各种需要最少编码的设计解决方案,能够以某种优雅的方式解决这个问题。
此外,任何关于物体分层的详细和具体的建议都值得赞赏。这可能是一箭双雕。