Tag Archives: Like

Speaking of Select

So like Where and other fine Extension methods, Select allows you to either give it a lambda expression like so: List<String> newList = userList.Select(user => user.Name); Or List<Int32> newList = userList.Select(user => user.ID); So either you get a list of Names or IDs. What the hell do you care? Well if you are capable of [...]

Leave a comment Continue Reading →

Like versus Contains in Linq

So have to figure this one out. Say you have: private static Expression<Func<User, Boolean>> WhereLikeFirstNameLastNameUserName(String name) { return currentUser => SqlMethods.Like(currentUser.UserName, “%” + name + “%”) || SqlMethods.Like(currentUser.FirstName, “%” + name + “%”) || SqlMethods.Like(currentUser.LastName, “%” + name + “%”); } And private static Expression <Func<User, Boolean>> WhereLikeFirstNameLastNameUserNameWithoutLike(String name) { return currentUser => currentUser.UserName.Contains(name) || [...]

Leave a comment Continue Reading →