Nemerle includes SQL macros. These make writing basic ADO.NET code a lot easier. They won't replace a complex ORM solution, but are fantastic for quick data access code. The main win is compile time query checking! That's right... if you misspell a column, table, etc, you get a compile error.
Watch the Screencast
using System;
using System.Data.SqlClient;
namespace Demo
{
module Program
Main() : void
using (conn = SqlConnection(@"Data Source=(local)\SQLEXPRESS;Initial Catalog=Customers;Integrated Security=SSPI"))
conn.Open();
using (cmd = SqlCommand("select Id, FirstName, LastName from Customer where IsPrefered=1", conn))
using (reader = cmd.ExecuteReader())
while (reader.Read())
def id = reader.GetInt32(0);
def firstName = reader.GetString(1);
def lastName = reader.GetString(2);
Console.WriteLine("{0}: {1} {2}", id, firstName, lastName);
}
_ = Console.ReadLine();
using Nemerle.Data;
[assembly: ConfigureConnection("System.Data.SqlClient.SqlConnection", @"Data Source=(local)\SQLEXPRESS;Initial Catalog=Customers;Integrated Security=SSPI")]
ExecuteReaderLoop("select id, firstName, lastName from Customer where IsPrefered=1", conn, {
});
Powered by: newtelligence dasBlog 2.2.8279.16125
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2010, Andrew Davey
E-mail