Compsoft Flexible Specialists

Compsoft plc

Compsoft Weblog Compsoft Website News Archive Privacy Policy Contact Us  

Thursday, April 23, 2009

Logging all LINQ to SQL queries used in a single page lifecycle

We absolutely love LINQ to SQL here at Compsoft. It's the best ORM we've used and it's made a marked speed increase in both our application development and application performance.

A concern we had initially was the amount of "magic" involved. Occasionally we'd find that LINQ was running rather more queries than we'd expected (the DataLoadOptions weren't always behaving quite as we'd anticipated), or the queries were unexpectedly complicated. Also, with all the ease of data access that LINQ gives you, it's easy to get lazy and forget quite how many trips you're making to the database to generate a single web page.

We felt we needed an easy way to see what was going on under the hood. We didn't want to have to go a long way out of our way to find out which pages took a lot of database effort: we wanted to be warned about this up-front.

So here's what we made: when in debug mode, this appears in the top corner of every page we're working on:

... which expands to this when clicked:

The more queries it takes to make the page, the redder the little "DB hits" box appears, drawing our attention to pages that accidentally take a lot of work to produce.

LINQ to SQL makes it easy to capture this sort of information. The Log property of DataContext is a TextWriter to which all queries are written, together with the values of any query parameters. Setting this to a new StringWriter in the constructor of our application's DataContext catches all the queries it performs.

We typically use one DataContext per page lifecycle, so it would seem it would be sufficient to dump the contents of the log to the page late in the page lifecycle. However there are occasions where we create additional DataContexts for particular tasks, and we want to know what they are up to too.

Here's the solution we came up with:

The data context class for the application inherits from this BaseDataContext class, which lives in our reusable code libraries:

// codesnippet:4963E640-80C0-4577-A2B2-F0F6A8D41E56

public class BaseDataContext : DataContext

{

#if (DEBUG)

    private static TextWriter logWriter;

 

    private static StringBuilder _Logger;

 

    public static StringBuilder Logger

    {

        get { return _Logger; }

        set

        {

            _Logger = value;

            logWriter = new StringWriter(value);

        }

    }

 

    static BaseDataContext()

    {

        BaseDataContext.Logger =

            new StringBuilder();

    }

#endif

 

    public BaseDataContext(string connectionString)

        : base(connectionString)

    {

#if (DEBUG)

        this.Log = logWriter;

#endif

    }

 

[Aside: we like Jeff Attwood's idea for flagging code snippets with GUIDs.]

As you can see, the log is static, so all queries from all DataContexts will be written to the same log. This would be nightmarish if the server were handling numerous requests concurrently, but this is just a development tool for when the application is running on your local machine (which is partly why the logging only happens when the application's in debug mode).

That takes care of logging the queries; next we have to display them. We have this in the class that all our pages inherit from:

#if (DEBUG)

protected override void Render(HtmlTextWriter writer)

{

    // Snip - write the contents of the log

    // to the page

    base.Render(writer);

 

    BaseDataContext.Logger = new StringBuilder();

}

#endif

 

This ensures the log is cleared down right at the very end of the page lifecycle, ready to start logging queries for the next page. Also, as the log is only cleared after it's written out, no queries get lost if the page lifecycle ends prematurely in a redirect.

The snipped code is a bit lengthy, but it basically renders the database hit count with a little jQuery to expand the full details of the queries when clicked, as in the screenshots above.

Astonishingly you can't do this sort of thing at all in LINQ to Entities - it doesn't have this logging support - so for all the flexibility that it offers, it's still missing some features that seem pretty crucial to us.

Labels: , , ,

Tuesday, November 11, 2008

Richard Thomason: TechEd 2008 Day 2

3 Oslo, Dublin and WF4 - David Chappell

Not the ex-Compsoft employee David Chappell, instead a rather annoying "gee dub-f" Seattle microsoftie.

This session promised a rewrite of the Workflow foundation. I went to a couple of sessions on WF3 last year and Tim investigated it for Hippo, and both of us found it to be inadequate. The hope is that the new version may be more up to scratch.

As it turns out, there has been a lot of work done. The workflow engine got a rewrite and is "much faster". They added a Flowchart model in addition to the Sequential and StateMachine ones. To help people who are afraid to write their own host process (?) sic, Dublin provides something like a service host for WF activities, including start/stop/restart and persistence. WF is the sort of thing you would use with SharePoint to implement simple activities beyond the scope of form-filling. Comparisons with Biztalk are probably not useful. Biztalk is not free.

Latterly, David spoke about Oslo, which is a general purpose modelling platform; here's an url for you to look at:

http://www.microsoft.com/soa/products/oslo.aspx.

Unfortunately, my BLX detector was activated during this part of the talk, and when he started talking about modelling schema languages and first releases, it triggered the "bail out now before the Tourette's kicks in" alarm.


4 Developing data centric web applications - Jonathan Carter

This session demonstrated substituting DynamicData controls for normally bound ones using templates to reduce the amount of code in asp forms. I can't resist saying that these are features that have been in Equinox since version 1 :) but enough of that since we didn't do forms in the web server, yet. There is a large amount of work to set up the template and refer to it in the form, however it is work that needs doing only once, and is extensible with user-defined types and so on. This does look good, especially for new, more substantial applications, but it still gives me the "whole load of legwork" feeling, and I don't see the point of reverse engineering it into existing apps. Maybe my expectations are too high.

5 Developing accessible web apps with Silverlight- Sean Hayes

Well it was either this or Windows for Washing Machines. I was concerned to see that the "with Silverlight" part of the title was missing from the title slide, but I thought I'd stick it out to see what I could learn. Sean rehearsed the well-known accessibility feaures in standard HTML - alt text and so forth, then went on to describe ARIA, which extends accessibility features in the latest browsers now, and will be part of HTML 5. It provides assistance in more complex controls such as drop-down lists and slider controls, etc, as well as a "live region" feature that allows assistive technology to handle dynamically updating areas of the screen.

Silverlight 2.0 is fully enabled for accessibility, and in this repect is unlike most modern browser-based implementations. Audio have have transcripts, and video can have captions or subtitles, as well or instead of transacripts. Finally you can use descriptions, which can pause the video if necessary. PC media allows for sign language translation more easily, since unlike TV it can be switched off and on.

6 LINQ and C# - Luke Hoban

This session is a warm-up for tomorrow's dead exciting LINQ to Anything talk, to remind me of the deep details of LINQ in C#.

LINQ works with both objects (via an enumerator interface) and via SQL (via a query interface). It's the same deal for both, and only varies in the provider and the references, eg Customer object versus db.Customer data provider, and so on. Luke showed a simple example querying customers:

var query = from c in LoadCustomers() where c.city == "London" select c;
var query = LoadCustomers().where(c => c.city == "London");

He demonstrated the .Net Reflector tool which shows details of generated code. CachedAnonymousDelegates turn lambdas into references to private static methods. If static methods start with "this", it defines an extension method that can be used with dot notation. He then overrode the Where method ("yield return" adds item into the output collection) on IEnumerable, which only executes as much as it needs to get to the next element, then returns that.

He then showed a SQL version demonstrating expression trees, which showed how out of memory execution works. Lambda expressions can also be turned into expression trees:

Expression<Func<Customer, bool>> MyExpr = c => c.City == "London";

IQueryable is equivalent to IEnumerable for out of memory types. It contains a pointer to an expression tree, and a Provider which can executes the query. The Provider needs to traverse the expression tree and provide results for resolvable items.

7 Using multicore resources with the concurrency runtime - Joe Duffy

Anything that makes it easier to do multi-thread programming is worth checking out. This was a brain melting discussion of how Windows native and the CLR do thread pooling and task allocation. There are two separate systems which mirror each other. The Concurrency runtime will ship with VS 2010.

The CTO of Intel said last February that he believes we'll have 80 cores in our pc's within the next decade. Secondly although Moore's law is not broken for numbers of transistors available, the fact is that the increase is not going to lead to an increase in speed as it has done in the past, so therefore in order to speed things up we will need to be looking at more concurrency.

The main technique of interest Joe discussed was task stealing, which gives much better performance in highly parallelised processes where threads create tasks recursively. The way it works is that threads can push and pop tasks on their local FIFO queue without locking (except the first one), and if other threads run out of work, rather than wait idly they can lock and pop other queues on a LIFO basis, thus maximising throughput.

Labels: , , , , , , , , , , , , , , ,

Tristan Smith: Tech Ed 2008 Day 2

Introduction to the Entity Framework

I really felt for the speaker here, a quirky, excitable American woman. Both because it's the first session of the day with most people barely awake and also because the audience seemed semi-hostile. Hostile, I imagine, as a result of Microsoft announcement that they're effectively killing LINQ to SQL (which a lot of developers have invested time and code in) in favour of the Entity Framework (EF). As we have also invested in LINQ to SQL for our data access, this seemed like an important session for us.

We currently do a lot of code generation based on the shape of the database so we'll have to update our generation when we make the switch. While there are some obvious gains by using EF which were mentioned, I wasn't sold, the relatively few benefits over LINQ to SQL didn't seem to justify a switch.

Unfortunately the session barely skimmed the surface, no real depth was gone into.

How IT will change in the next 10 years and why you should care

Definitely my favourite session so far presented by an awesome speaker.
There were so many areas that were covered, it's hard to summarise.
Some interesting points were brought up around subjects such as the move towards virtualisation, how the green friendliness of hardware is going to have it's impact and is already.

A really interesting point was the way in which the next generation of employees are going to be the first generation of Digital Natives(DN). Here we are as Digital Immigrants, we were there before the great migration, we've been working through the change and are enjoying the gadgets but we're just not in that same headspace. The DNs of today instinctively navigate and manipulate social networks living their online identities. He pointed out that they're going to be entering the work force where they're to be stripped of their online identities, given a crappy email address and effectively disconnected. Quite a culture shock it will be for them.

The IT industry's carbon footprint is already larger than that of total global aviation. How increasing power consumption means Microsoft will dump their entire computers if a new machine has sufficient power savings. Heat is the great enemy. For the huge savings, data centres are being moved to cold places such as Greenland where there are beefy data backbones between the USA and Europe.

Introducing ASP.NET MVC

In ASP.NET Webforms, there is no master handing your pages and controls the data they need, nothing takes responsibility. The masterpage, page, controls can all have their own presentation, data access and logic.
This can make code less maintainable because you're not sure what in the hierarchy has broken. Wouldn't it be nice if you could have a clean separation of the data, logic and view? Yep! and that's what MVC is all about.
As a result of being separated out like this, your code becomes a lot more testable and you can swap out the different parts as you need.

While this sounds like the golden chalice, it takes a lot more work to make a page. There is a definite hard work tax involved, it's harder to get the same kinds of AJAX functionality that you would by just slapping an ASP.NET AJAX Update Panel around your code.

ASP.NET practices with MVC
Following up on the introduction to MVC which I was very impressed with, this session talked about some of the implementation issues and pitfalls you're likely to encounter.

Also mentioned was Unity, Microsoft's Inversion of Control offering allows you to remove the relationship reliances between layers of your code meaning when one part of your system is rewritten, providing it still matches the interface signature, it can just be swapped out.

Silverlight 2 for Mobile: Developing for Mobile Devices
Mobile development gives you a lot of functionality with a very small footprint.
Somewhere it falls far short of windows and web development is when it comes to graphics. Generally the trade off of using the compact framework is dull looking forms, text and interactivity. While you can do pretty graphics, the work required renders it generally unfeasible.

Silverlight mobile looks to change all that, giving you the full Silverlight experience you'd get on the desktop with all the same awesome animation, vector graphics and interactivty.
For situations where you have a Silverlight website, you can have the mobile get a different experience by checking the type of device requesting the page and redirecting to different content. With Nokia as well as Windows Mobile phones supporting Silverlight, it's a really good way of standing out from the crowd.

Labels: , , , , , , , , ,

Neil Bostrom: Tech Ed 2008 - Day 2

Learning the Entity Framework

Entity Framework is one topic I really wanted to learn more on, however this was not the session to achieve that. The content of the session was only the basics which I already knew. The practical demos were limited. Felt a little let down when I left the session as I missed out on some other interesting topics to make sure I made that session.

Sync Framework - Deep Dive

Sync framework was an excellent session covering everything from what the sync framework is right down to how to write a custom provider for it. The Sync framework allows you to sync almost anything (if you have a provider for it) with anything else. So you could sync a file system with a database, or outlook with facebook etc. This solution would have been a perfect for the Hippo PDA project where we had to write all the synchronisation manually.

Building a Dynamic Info-Screen application with Silverlight 2.0

I was extremely pleased with this session as it was showing a practical implementation of Silverlight in a real world application. The Info screen was talking about ad boards or train station screens, where you need dynamic content inside a range of different templates. Max Knor did an excellent job explaining the architecture of the application and also showing real code to swap in and out dynamic templates in Silverlight. The application showed some of the great power you have with Silverlight, including the ability to run the Silverlight on a client inside a WPF application.

How LINQ Works: A Deep Dive into the C# Implementation of LINQ

This session was a level 400 (uber hardcore) and it was great! Luke Hoban did a fantastic job covering a difficult topic in an easy to understand manner. It covered how LINQ holds together and how the C# compiler converts the LINQ expressions into method calls. Interesting point I learnt here is that the compiler will search closest to the code for extension methods. This means you can override the default implementation of an extension method (like the WHERE clause) by declaring it closer than System.Linq. Luke then covered how IQueryable uses expression trees to allow delayed execution. This is the real power behind LINQ. A real gem that came out when was Luke showed the different code that is generated by the compiler depending on which interface you work against, IQueryable or IEnumerable. IEnumerable lambdas are generated as methods on the class, however IQueryable lambdas are created as expression trees. It's a difference I knew about but didn't join the dots to the different code that is generated.

Silverlight 2.0 Security End to End

Security is not a word I’ve heard being mentioned with Silverlight yet, this is why I jumped at this session when I saw it. Silverlight is very powerful but does run client side so security is a concern. The first area covered was the built in security that the Silverlight CLR uses. It has a SecurityCritical attribute applied to it that is used by the platform Silverlight code, like File.Exists. This code can only be used by the Silverlight framework. There is also a SecuritySafeCritical attribute to allow application code to call code that is SecurityCritical locked. All Silverlight appdomains are sandboxed, no Silverlight app can create app domains or cross call them. To allow Silverlight apps to store settings, there is an Isolated storage class. This is a Virtual File System as it needs to work on both PCs and MACs. The Isolated Storage is per application or per domain. The default space allocation in the Isolated Storage is 1MB, however the developer can prompt the user to request more space. Webservice calls are only allowed to same domain, port and protocol. To make cross domain calls, you need a clientaccesspolicy.xml in the root of that site. We spoke about good practices on securing web service calls by using Querystring tokens when making the calls.

Labels: , , , , , , , , ,

Wednesday, November 08, 2006

Neil Bostrom: Microsoft TechEd (Wednesday)

LINQ More Questions
We had another session on LINQ this morning covering much of what we have seen before. There was a lengthy Q&A slot at the end of session giving us a good chance to raise our questions on LINQ. Our main question was on how you control population of related objects to optimise the number of SQL calls made. This was always the biggest drawback we faced with using Gentle.NET. This seems to have some nice solutions in LINQ with declarity control over what is pulled back in your SQL calls.

Windows Presentation Foundation (WPF) In Web Applications
I was interested in joining this session to find out what kind of support WPF has for the web. Turns out is very limited; being only supported on IE7 and you have to have the framework 3.0 installed. It has almost no intergration with your existing web applications.

However, planned at the end of the development is a product code-named WPF/E (for everywhere). This is a cut down version of WPF that is planned to be shipped on most current platforms and browsers as a Flash-like plug-in. This could make for a very powerful addition to web development.

Hardcore .NET Production Debugging
This was a fantastic session covering some of the most advanced tricks to debugging memory leaks, crashes, application hangs and threading issues. It highlighted some of the great tools available to debug your applications on production servers. The most interesting point was on what you could do with crash dump files. These files had always interested me and I wanted to know more about making the most of them.

Dot NET Rocks!
This session was a live recording for the popular Dot Net Rocks show. Turns out the topic for this show was one very close to my own heart: Agile development. The Dot Net Rocks team had managed to dig up three very good experts on the topic and it made for a heated show covering really good tips on getting Agile development working for you in your company. We have already starting using most of the important Agile features (Unit testing and Continuous builds). This puts us in a very strong position to maybe try to pick up some of the other Agile features (XP Programming, The Planning Game, Sprints or Scrum Meetings).

Patterns for Service-Oriented Architecture (SOA)
This session was a do's and don'ts on web services for creating an SOA. Ron Jacobs was clearly a very experienced speaker in this field and brought across the issues very well. Here is a highlight of his points:

Do's:
  • Make very strongly typed web services for business processes
  • Try to version your service objects if you have to change them with existing clients
  • A good design plan is to base your interface on the mental image of moving documents around an office, make it feel right
  • Try not to think of web service calls as methods but more business processes
Don'ts:
  • Make very general interfaces into your services. e.g DoEverythingMethod
  • Use internal objects as part of your interfaces
  • Create a chain of web service calls, as these would add a dependency of the client calling the methods correctly

Labels: , , , , ,

Tim Jeanes: Microsoft TechEd (Wednesday)

We saw some more of LINQ this morning, and holy crap! - this is so going to change the way we work! It just makes it so easy to get your hands on exactly the data you need where and when you need it. When combined with the new anonymous classes in C# in .NET framework 3.0, you get all the type casting and intellisense you'd expect from a proper class, but without the hassle of creating a whole new class just for that one time you want to use it. So, on your customer list page you can create an anonymous class on the fly that holds just the details you want from the customer table (with any aggregate data from child tables), without having to make a "CustomerSummaryDetails" class to hold it. It's a beautiful thing.

I was very impressed with how LINQ saves data back to the database - it supports all common models for data concurrency and transactions right out of the box. However, it frightened me a little that if you query the same table twice, both resultant datasets will refer to the same object in memory. This has the potential to be either very powerful or very dangerous. Similarly, I'm not convinced we'll still have enough control over how LINQ saves changes to child tables. We caught the speaker at the Ask The Experts stand over lunch and though he put our minds at rest over some issues, we managed to throw him slightly with these kinds of questions, so I remained unconvinced.

I later attended an extended Q&A session with Anders Hejlsberg - the head of C# language design - who also had a big hand in LINQ. I think it'll take a bit of a paradigm shift on our part: whereas Gentle.NET takes snapshots of the data in the database and lets you play with them in object form, LINQ considers your objects to be a representation of the underlying data: you only have one instance of that object in memory, just as there is only one instance of the object in the database. Everything we already do is still possible (and slicker in many cases), but we'll just have to alter the way we handle our objects a little.

Hejlsberg talked about his future plans for C#. Microsoft will be taking their current support for partial classes one step further by enabling partial methods too: you can define the signature of a method in one half of your partial class and then instantiate it (if needed) in the other. (If you don't instantiate it then the compiler removes not only the method signature, but also all calls to that method.) This perfectly fits a problem we've hit regarding the validation of classes, one half of which has been created by a code generator.

We'd found a work-around, but as Hejlsberg said that this exact use is the main driver for introducing this new feature, it's nice to see that we're one step ahead of the game! Incidentally, Hejlsberg also said that partial classes were introduced in the first place to enable the safe regeneration of code after the underlying database changed. This is exactly the use we've made of them - it fixed the inheritance workaround we'd used before - another encouragement that our coding practises are right up there with the best of them! omg omg 1337 hax!

Another interesting session today was looking at the ASP.NET AJAX toolkit. Microsoft are providing a good-sized library of out-of-the-box AJAX controls, and though we've not had the business incentive to use them in the past, I think the ease of use I saw today means that we'll be incorporating these into our web applications in the very near future. They're supplying pretty well every type of control that will be commonly useful, and they're all vastly configurable. The demonstration also covered how to build your own AJAX control using the various helper libraries that Microsoft have prepared (that handle everything from the browser-to-server interface to ensuring your control will work under the varying DOM models implemented by all the major browsers). Quite frankly, building your own control looks pretty horrendous, and it's the sort of thing you'll quickly forget unless you do it every day. However, as with most technologies it's enough to know that it can be done, and the ample resources on the web will fill in the gaps as and when you need them.

The session entitled 'Encrypting Without Secrets' took a look at the strengths and weaknesses of public/private key-pair encryption, highlighting the issue that all this generally achieves is transferring what the secret is from one thing to another. Initially your secret is that one big critical document, or perhaps your credit card details; after encryption you tend not to worry too much about who gets to see that encrypted text, so the secret now becomes your private key. Unfortunately, a private key is a lot smaller than a whole bunch of company secrets, and getting your hands on the key unlocks a whole load of valuable information. Typically the private key is kept on the server as the encrypted information, merely for convenience's sake. Avoiding this much-overlooked weak link in the chain is a fascinating topic, especially if you're not to introduce any other new weaknesses, whilst keeping your secure systems usable.

I really hope they do something different for lunch tomorrow though - they've served the same thing two days running now, and though I'm generally not averse to paella, I am when it tastes like that...

Labels: , , , , ,

Tuesday, November 07, 2006

Neil Bostrom: Microsoft TechEd (Tuesday)

ASP.NET AJAX
Previously known as "Atlas", this is Microsoft's open source implementation of AJAX. When I say open source, the client scripting is open source and is compatible with all major current browsers (IE, Firefox, Netscape and Safari - even on the Mac). This client scripting is being developed by the community in an open source fashion.

Server side scripting for this technology is Microsoft's usual closed source but is only compatible with ASP.NET so no real reason to make it open source. A lot of the server side work is drag-and-drop; you can change most of your existing code to start using the power of AJAX (when appropriate).

Neat features with this AJAX framework are that it will plug straight into existing web services. and has bridging code to allowing AJAX script to seamlessly call current web services.

SQL Server 2005: Advanced Indexing Strategies
All of this session made me see that I need to learn a lot more about sql server! and soon!

Summary of this session was try to always have a clustered index of your standard tables. Try to make the clustered index narrow (limited fields), unique (identity field, datetime / identity or GUID) and small (Identity). Sometimes the best non clustered indexes are the ones that cover a lot of fields. This gives the sql optimizer a bunch more options.

Kimberly Tripp knows her stuff and is incredibly passionate about SQL server and all it entails. She has made a bunch of online webcasts discussing almost every aspect of sql server and getting the most out of it. As soon as I get back to the office I will be downloading them all!

Language Integrated Query (LINQ) Framework
I personally believe this is the best thing to come out of TechEd: It's Gentle.NET on steroids backed by Microsoft. It's a well thought through framework for querying almost anything inside .NET. Objects in memory, you want to filter them? Job done. Sort, group, aggregate? Job done. You want to do all that with data from sql server? Job done. You want to all that with xml document / web services? Job done.

I believe this will fundamentally change how I write my code and I'm picking up a copy as soon as I can!

Visual C# IDE Tips and Tricks
Class Diagrams - You can drag framework classes into the class diagrams to explore them in more detail
Refactoring - All the refactoring in C# is code snippet based, meaning you can change the refactoring to suit your needs
Debugging - You can control more closely what is debugged and how it's displayed using the Debugger attributes available in the framework

Labels: , , , , , ,

Tim Jeanes: Microsoft TechEd (Tuesday)

Wow, they work you hard at TechEd! Five seminar sessions a day keep you going from 9am till 7pm, yet none of them is ever long enough to fit in everything you want to learn. Every session left me wanting more, and with 138 seminars, white board discussions and hands-on labs to choose from, you can never get more than a fraction of the amount of information available.

I'll pull out a few things that stood out to me today.

First of all were the changes in working practices that Windows Vista will force on us. Having the same people developing the logic of the code and the visual front end just isn't going to cut it any more, unless you're happy with all your applications looking like Windows XP (which will be worse than the feeling you got running Windows 3.1 apps in Windows 95). The whole visual experience of Vista is going to be such a step above what Windows offers today that you really will need dedicated designers giving your applications their own look and feel. Absolutely everything can be styled. Whereas presently you can style a button by setting its border and colour (or maybe a background picture if you really want to), in Vista you basically have to draw it yourself from scratch. So long as you have some kind of artistic talent then you won't mind setting the shading, transparency and opacity of the various layers you choose, along with the transitional animations for when you move your mouse over it; if not then you'll be needing to hire some graphic designers pretty soon. As a concession they do include xaml to draw the controls we're used to in XP, but that's really only to get you started.

Fortunately they're adding the necessary functionality into Visual Studio to allow the developers to get on with developing the code and the designers to get on with making the look and feel without the two parties stepping on each others toes. I (as a developer) can create my form with a listbox on it and make everything work, only to be utterly surprised that the final project ships with that list box rendered as a rotating 3D carousel - yet I can rest assured that such dramatic changes will have no impact whatsoever on my functionality.

Microsoft are shipping a new set of products (LINQ, DLINQ and BLINQ) that will greatly enhance our speed of application development. LINQ stands for Language Integrated Query, and basically lets you query any sets of objects you have in memory as you would query a SQL database. This gives you clearer and easier methods for searching threw collections of object you already have. However, its real strength lies in letting you tell the compiler that properties on a class map onto fields in an actual database; then querying your objects builds queries on the fly (including all the necessary joins, filters and sorts) to pull out the data you require. This is phenomenally easy to implement - it's just a case of slapping a few attributes on some properties. This nicely side-steps all the hassle of creating stored procedures to handle your data persistence: you may never need to write a stored procedure again.

This all sounds remarkably familiar to those of us who are used to using products like Gentle.NET (which has served us very well for a few projects now), but it's great to see Microsoft catching up with the rest of the coding community, and being a Microsoft product we can be sure it'll plug nicely into Visual Studio and everything else. They're not being exclusive though: they've made it easily extensible so we can use whatever back end database we like.

BLINQ takes code creation one step further. They didn't mention what it stood for, though I'd like to venture "doing my BLINQing job". This product is still in the early stages of development and so only exists as a command line utility so far, but will be integrated as a fully-fledged wizard in the new version of Visual Studio (project Orcas/.NET Framework 3.5). Basically what it does it build your entire web application for you. You hand it a database schema and it creates pages to list, view, add and edit every object that the database describes. It understands the joins in the database so your customer details page will have links to list all the orders that customer has placed, etc.

Fortunately it's a fairly blunt instrument: it doesn't understand which users should be allowed to do what, the relative importance of various fields, or exactly what processes should be triggered when you try to delete a customer, for example, but it certainly could give you a good starting point for your web application (so long as the final version lets you define your own templates), which will take out a lot of the dull monotonous parts of web development.

Once last highlight: they provide all the Coke you can possibly drink, free of charge. It's geek heaven.

Labels: , , , , , ,