tags:

views:

96

answers:

4

Is anyone aware of a such a thing as a SQL writing library for .Net? I'm thinking it would be wrapper for generating queries in an object oriented style. Maybe something like the following:

class SelectQuery : BaseQuery
{
    List<Column> SelectedColumns { get; set; }
    Table MainTable { get; set; }
    List<Join> Joins { get; set; }
    List<Condition> Conditions { get; set; }
    List<Column> Order { get; set; }

    string Write() { }
}

Nevermind why I'm looking for something to do this. And, there's no specific problem which this would address for me, I'm just interested in seeing such a thing.

Please note, I am not looking for an O/RM, but a means of writing SQL, and representing queries with objects.

+1  A: 

LINQ to SQL does this.
nHibernate does this. LINQ to Entities does this.

Basically, you seem to be looking for an O/R mapper, of which there are a ton of competing products.

Dave Markle
No, I'm not looking for an O/RM, but a means of writing SQL and representing it in objects. Likely, somewhere along the LINQs query processing pipeline there is just such a thing.
sledgebox
@sledgebox: Are you talking about the IQueryable<T> extension methods that LINQ maps to?
Chris Farmer
+2  A: 

nHibernate has a new project underway called Antlr which is an Abstract Syntax Tree for SQL Queries. I've not looked at it but it might have you want.

JoshBerke
This is helpful. Thank you.
sledgebox
A: 

See this discussion about Object Role Modeling. It's the only available tool I've ever seen for having a conceptual discussion about relational database design.

le dorfier