Archive | .Net Issues RSS feed for this section

Change Target Framework on a Class Library (Visual Studios 2008)

Ok so this is a quick one but annoys the hell of of me. Basically I am working with a 2.0 class library project and I wanted to use Linq. Now you would think when you “upgrade” the project to 3.5 using the wizard, the target framework would follow. Well, you are stupid. Now for [...]

Leave a comment Continue Reading →

Cannot Resolve Method, Can’t Infer Return Type, and Funcs

So ran into this today and the answer was actually a lot easier to understand than I thought it would be. Say you want to order a list of objects by a number. Seems simple. Now if you have been paying attention you would know I like using Funcs. Func<SomeClass, Int32> orderByNumber = currentClass => [...]

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 →