Contents tagged with C#
-
My "Ah-Ha!" Moment With LINQ
I'm currently working on a set of web services that will be consumed by iPhone and Android devices. Given how often the web services will be called in a relatively short period of time, the data access for the web services has proven to be a very important aspect of the project. In choosing the technology stack for implementation, I opted for LINQ to SQL as it was something I had dabbled with in the past and wanted to learn more about in a real environment. The query optimization happening behind the scenes was something that I had an appreciation for.
Once I completed the implementation of the web services we noticed a performance bottleneck on one of the calls. LINQ to SQL was doing all it could to help us in this situation but the nature of the required response was simply too heavy on the database to expect any real performance from any query. We ended up being able to cache the data we were querying against which would help tremendously.
What I was expecting was a large re-write of code to accommodate my new source of data. Instead, using LINQ, I was able to simply change the from statement in my LINQ query and get the results I needed. Essentially, when building the cache, I create a Listcollection for the objects I'll need to query against and subsequently return to the mobile device. The results of that general query are stored in cache. When I need to perform a query against that cached collection, I have a LINQ query, which I used previously to query the database tables, that now uses the cached collection as it's data source. Which is really a fancy way of saying the "from" statement in the LINQ query. There were no ugly nested loops with various comparison statements needed.
Going from querying a database to querying a local in-memory collection was beyond trivial with LINQ. After getting it up and working, I fell back into my chair in amazement. -
Book Review: ASP.NET MVC in Action
I've had the pleasure of being able to review ASP.NET MVC in Action in it's early access form. If you've not heard of this program, Manning has a program called MEAP (Manning Early Access Program) which allows you to purchase the book before it's published and gain access to it in PDF form as the author makes the chapters available. In this case, I've been reading parts of the book nearly a year before it will be physically published in Sept 2009. I highly recommend checking that out, as I've participated a number of times. In fact, I purchased C# in Depth, 2nd edition over the weekend in MEAP. I have access to the 1st edition via PDF, access to the 2nd edition in PDF, and will receive a hard copy when the 2nd edition is published. An excellent way to receive books in my opinion. Anyway, on to my review of ASP.NET MVC in Action.