Do I need locking for _userByNameQuery static field Yes/No and way?
public class SomeClass
{
static Func<Entities, string, IQueryable<User>> _userByNameQuery =
CompiledQuery.Compile<Entities, string, IQueryable<User>>
((context, userName) =>
context.Users.Where(u => u.UserName.ToUpper() == userName));
public bool UserNameExists(string userName)
{
userName = userName.ToUpper();
return _userByNameQuery.Invoke(DataContext, userName).Count() > 0;
}
}