I have a class that provide the CRUD operation for an entity.Im using the context as private member accessible for all methods in the class.
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;
}
}
Is this a proper using of context ?? Is it thread safe and concurency safe??
Its a ASP.NET app.