views:

86

answers:

2

Are there any libraries for .Net for building sql statements?

(BTW I know about ADO.NET SqlCommand, SqlParameter classes already)

I'm currently developing a library to do this but am now wondering if there is already something out there which might be better.

Edit:

At this point I'm only interested in returning a DataTable object as I'm developing a reporting feature, hence why I'm not too interested in LINQ (please correct me on this if you think I am misguided).

My main aim is to enable users to select field names for a report from a CheckBoxList and to be able to add/remove filtering expressions (i.e. edit the WHERE clause). Adding fields could mean including sub-selects, not just including a field name in the select clause.

A: 

You're looking for LINQtoSQL which is an relational mapping implementation that ships in the .NET Framework 3.5 and allows you to model a relational database using .NET classes.

Edit-

Since you're using .NET 2.0 With LINQBridge, you'll be able to write local LINQ to Objects queries using the full power of the C# 3.0 compiler and yet your programs will require only .NET 2.0.

TStamper
I'm limited to .Net 2.0 in this case unfortunately, which rules out LINQ I think. Also, I need to be able to be able to dynamically modify which fields are included in my select statements and what conditions are used in the where clause.
mdresser
well LinqtoSQL does only apply to .net 3.5, but it is nice to use in case you ever wanted to upgrade
TStamper
@mdresser: you could still use LINQ with LINQBridge by Joe Albahari: http://www.albahari.com/nutshell/linqbridge.aspx
Mitch Wheat
Mitch is right..updated answer
TStamper
A: 

Take a look at NHibernate

SQLMenace