Tuesday, 6 November 2007

Extending XSD TableAdapters : Dynamic SQL

Objects or typed tables is the preferred way of interacting database but creating those objects and then serialising is not an easy deal if done manually. There are many 3rd pary OR mapper providers for .Net. LLBLGen is one which I used while working in .Net 1 and 1.1

After TableAdapters were introduced in ADO.NET 2.0 creating typed tables (objects) is piece of cake and Visual Studio 2005 has wizards to create the whole Data Access layer by "drag and drop". It uses XSD to create as many schemas per project you like and each schema can have as many typed objects (TableAdapters) you like. TableAdapter lets you connect to a database, run queries or stored procedures, return a new table or fill existing DataTables.

I am not going to create a tutorial for this topic and there are many "How-to" articles available on internet. But soon after you go through "Hello World" type of scenario, you realise that you need to create a table adapter which could cope with any number of parameters at run time. Luckily I found an interesting article about Extending TableAdapters for Dynamic SQL on code project and as usual I was saved from re-inventing the wheel. Here is the link.

http://www.codeproject.com/vb/net/tableadapter.asp

No comments: