Search Wiki:
More Info
Check out Andrew's personal blog for more information and updates.

Project Description

One Query, Any Database - Write one Query and have it run on multiple Database Engines. OneQuery is a Database-agnostic query engine that focuses on allowing developers to write queries that will run on multiple database engines. It is not an Object/Relational Mapper, at least not in its current incarnation.

December 2007 Preview Release

The December 2007 Preview Release has been posted. This version contains a working query engine that supports simple queries of the form "SELECT * FROM Table WHERE Conditions ORDER BY Columns". Download it, try it out and discuss it in the Discussions section.

Syntax

OneQuery uses a Fluent Interface to provide a simple, but powerful, query tool. The current release only supports simple SELECT queries, but there are plans to support INSERT, UPDATE and DELETE commands in the next release and more advanced queries as time moves on.

Examples

Common Code
The code below creates a class containing some helper fields. In the next few releases I'm hoping to develop a code generator that will create this for you. Of course, if anyone wants to contribute some time to work on that, please post in the Discussions section :).
public class Products
{
    public static readonly ColumnReference UnitPrice = new ColumnReference(Table, "UnitPrice")
    // ... repeat for each column in the table
    public const string Table = "Products"
    public static Query Query() { return Query.From(Table); }
}

"Fetch All" Query
The following query retrieves all records from a table in the database and returns an IDataReader containing those records.
IDataReader rdr = Products.Query().ExecuteReader();

"Fetch By ID" Query
The following query retrieves a specific record by its ID (in this case 4), and returns an IDataReader containing the record.
IDataReader rdr = Products.Query().Where(Products.ProductID == 4).ExecuteReader()

"Fetch By Conditions" Query
The following query retrieves all records matching a set of conditions and returns an IDataReader containing the records.
IDataReader rdr = Products.Query().Where(Products.UnitPrice > 10 & Products.UnitPrice < 20).ExecuteReader()

Operator Overloading

As the examples above show, Operator Overloading is a key part of the cleanliness of the interface. However, there is one important note to be made: The "&&" and "||" operators should NOT be used in OneQuery expressions since the short-circuit evalutation features may cause issues during query translation. Instead, the "&" and "|" operators will have the same effect.
Last edited Dec 13 2007 at 2:04 AM  by openarrow, version 7
Comments
No comments yet.

Updating...