我對我的DAL使用Linq to SQL,並且聽說過有關在Web應用程序中使用靜態方法的各種信息(關於線程/併發問題)。目前,我創建了一個測試DAL,這似乎運行良好。但是,我創建它的方式是否有問題,因爲它是靜態的?適用於Linq To SQL 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 2010-02-10 17:18:43
@ScottE:我從來沒有聽過任何細節(部分爲什麼我決定在這裏問),但我記得看到一篇文章聲稱可能存在一個問題,即一個用戶的數據與其他人混在一起,因爲他們訪問過DAL方法。 – Skoder 2010-02-10 17:34:01