【发布时间】:2011-01-15 09:06:50
【问题描述】:
我正在为我的 DAL 使用 Linq to SQL,并且听说过有关在 Web 应用程序中使用静态方法的各种信息(关于线程/并发问题)。目前,我创建了一个测试 DAL,它似乎运行良好。但是,我创建它的方式有什么问题吗,因为它是静态的?
public static class TestDAL
{
public static bool GetUserAddress(string username)
{
testDBDataContext dbContext = new testDBDataContext();
//Linq code goes here
}
public static void InsertUserNumber(int userID)
{
testDBDataContext dbContext = new testDBDataContext();
//...
dbContext.UserDetails.InsertOnSubmit(nUser);
dbContext.SubmitChanges();
}
//etc... All the methods are created in the same way
}
这种方法适用于 Web 应用程序,还是在生产环境中会出现问题?
谢谢。
【问题讨论】:
-
你听说过关于线程/并发的哪些事情?
-
@ScottE:我从未听说过任何详细信息(部分原因是我决定在这里问),但我记得看到一篇帖子声称可能存在与用户数据混合的问题其他人,因为他们同时访问了 DAL 方法。
标签: asp.net linq-to-sql multithreading data-access-layer static-methods