【发布时间】:2009-11-06 19:14:37
【问题描述】:
我有一个为实体提供 CRUD 操作的类。我使用上下文作为类中所有方法可访问的私有成员。
public class CustomerService
{
private CeoPolandEntities context;
public CustomerService()
{
context = new CeoPolandEntities();
}
public bool IsCustomerValid(string userName,string password)
{
Customer customer;
customer = context.CustomerSet.FirstOrDefault(c => c.UserName == userName
&& c.Password == password);
return customer == null ? false : true;
}
public bool IsUserNameValid(string userName)
{
Customer customer;
customer = context.CustomerSet.FirstOrDefault(c => c.UserName == userName);
return customer == null ? true : false;
}
}
这是对上下文的正确使用吗?它是线程安全和并发安全的吗??
它是一个 ASP.NET 应用程序。
【问题讨论】:
标签: c# .net asp.net entity-framework