Very, very simple ORM framework =)

1. Install
PM> Install-Package Changix.Sql

2. Add connection string to .config file
<connectionStrings>
    <add name="AdventureWorks" connectionString="..." />
</connectionStrings>

3. Create SqlClient class instance (static).
public static class DB
{
    public static SqlClient AdventureWorks = new SqlClient("AdventureWorks");
}

4. Use SqlClient class instance.
var products = DB.AdventureWorks
    .Query(@"
        select [ProductID], [Name]
        from [Production].[Product]
        where [FinishedGoodsFlag] = @FinishedGoodsFlag")
    .WithParameter("FinishedGoodsFlag", true)
    .ExecuteObjects();

foreach (var product in products)
{
    Console.WriteLine("{0} {1}",  product.ProductID, product.Name);
}

Last edited Jun 26, 2013 at 3:42 PM by ordos, version 4