This is yet another instance of a simple module example that got out of hand. I have developers that I supervise using Linq to SQL for the first time. I discovered that sometimes they create an excessive amount of code because Linq allows you to easily section off code using "If... Then..." blocks. Because they are new to Linq they may not realize some of the useful techniques.
I wanted to create an interface that allowed a lot of combinations yet still used one single query.
I ended up spending most of the day and writing a few hundred lines of code because I first tried to use one of the various custom controls that provide a drop down with checkboxes (they work but you cannot select ALL and then have all the items selected.).
Once I decided to use the plain old list box (holding down the Ctrl key to select multiple items really isn't that hard for a user to do) I spent a lot of time creating an interface that allowed you to choose any combination. I wanted the code as short and as tight as possible for future use.
I then wanted to show something interesting as a result so I decided to use the DNN core SiteLog. The problem is that there are no core methods to query it. I did not want to do another example where I say "this module is accessing core tables but you should never do this". I also wanted to use Linq so the code was again, as tight and succinct as possible.
I discovered a few techniques and extension methods that allow you to transform Arraylists and IDataReader results that the core methods produce, into formats that can be manipulated using Linq. Note, I am referring to Linq not Linq to SQL.
I posted the final result and source code at this link.