Tag Archives: Select

What Is Readable

So a couple of posts I read recently have been about readability of Linq, more so Linq query expressions versus the Linq methods. Don’t know what I mean? Expression: var result = from knowledge in Sean select knowledge.Linq; As opposed to: var result = Sean.Select(knowledge => knowledge.Linq); Personally I would replace the lambda expression with [...]

Leave a comment Continue Reading →

Beyond the wall

So I never gave a solution to this problem and thought I might do that real fast. If you recall, this was the main sticking point of creating a Func for a select clause: Func<User, EHH??> selectUserID = currentUser => new { currentUser.ID, currentUser.UserName }; Well there is no one solution to this, but there [...]

Leave a comment Continue Reading →

And then you hit the wall.

So as this dynamic nonsense continues, there is a sticking point to how much fun I can have. The wall? Anonymous types and generic declarations. Here’s the old: Func<User, Int32> selectUserID = currentUser => currentUser.UserID; Great if I want to select userIDs, but what if I want UserIDs AND UserNames… Easy right? userList.Select(currentUser => new [...]

Leave a comment Continue Reading →

When is a field not a field?

Ok so for the last few things I’ve been showing a more dynamic approach to linq queries , mostly dealing with collections rather than say linq to sql. Now take the new method: public List<K> SelectFromUserList<K, L>(Func<User, K> selectMethod, Func<User, L> orderBy, List<User> userList) { List<K> userList = new List<K>(); userList = userList.OrderBy(orderBy).Select(selectMethod).ToList(); return userList; [...]

Leave a comment Continue Reading →

Adding to the Select

So in the last post there was something like this: public List<K> SelectUserNameList<K>(Func<User, K> selectMethod, List<User> userList) { return userList.Select(selectMethod, userList).ToList(); } Called by this: List<String> newList = userList.Select(user => user.Name, userList); Ok so what if you want to order something? Well same idea, just another Func. But remember, a Func that can order by [...]

Leave a comment Continue Reading →