0
是否需要鎖定_userByNameQuery靜態字段是/否和方式?C#靜態字段鎖定
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;
}
}
謝謝你的解釋。 – 2010-08-26 10:43:45