Linq

There are 8 entries for the tag Linq
So in response to some comments on my original post on this topic, I started playing around with some other ideas. I figured it would be cleaner to post code here, rather than the comments. How many variations on the theme can we really have? As suggested in the comments on the previous post: 1: public static string Join1<T>( this IEnumerable<T> items, string delimiter, Func<T,string> converter ) 2: { 3: return string.Join( delimiter, 4: items 5: .Select( converter ) 6: .Where( ......
A couple of weeks ago, I was working on some client side UI elements on one of my projects. I was able to apply some things that I have learned recently (some more recently than others). The problem is that I have a domain object that tracks the selected days of the week. Currently the object uses a List<DayOfWeek> to manage the selections. (This is not exactly the most safe thing because a client could set the list to null. However, that's a different subject.) What I was looking for was an ......
I had the opportunity today to write some more complex LINQ queries. First, I started with a simple group by expression allowing me to subtotal some data for a particular key. Certainly I could have done this in the database. Many would argue that that the database is the expert at these sorts of things, so we should let the expert take care of it. I have a couple of reasons for placing the group by in the LINQ query. First, I don't have a lot of control over the data layer. Second, I can unit test ......
I've have been pretty quiet lately. Actually, I've been quite busy and it turns out that there isn't much new to share. However, this is one thing that comes to mind. A recurring pattern in my UI is selection criteria that can applied to a GridView. It turns out that frequently the same criteria applies to various screens. I use LinqDataSources to bind to DropDownLists for many of the criteria. It is not uncommon to use one controller for every page. Following this approach, I ended up with the same ......
So, I learned something new yesterday. I haven't spent a lot of time in ASPX over the last couple of years, and when I did I didn't really pay attention to what is new. Well, I learned about the nifty DataSourceControl classes. In my case, I decided to use the LinqDataSource control. And I put it to use on a nested GridView with Paging I struggled for more hours than I care to admit to accomplish what I wanted. In the end, I was pleased at just how little code was required. Check out my full article ......

The Load event came to my rescue

While playing with Linq and trying to get it to work with Oracle (Linq to Oracle *sigh*), I struggled with the fact that Linq appears to tightly couple business objects with data/persistence. I found myself pondering this fact and trying different approaches to separate the ObjectContext from EntityContext(s). In Linq, the ObjectContext is the object that you provide with a connection string and has the knowledge to send/receive data to/from your database. The EntityContext(s) are the classes that ......
Well, I have been playing with Linq, specifically with Oracle. First of all, the only way I could find to make this work is to use a third party software, OraDirect.Net by Core Lab. Their product is great. Perhaps that statement is biased by the fact that they are the only one's building a library to support Linq to Sql (as far as I know). There is certainly room for improvement. I've crashed VS a few times because I was trying to force OraDirect to do something it doesn't support. So, error handling ......