Skip to content

Instantly share code, notes, and snippets.

@mhinze
Created March 4, 2011 04:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhinze/854157 to your computer and use it in GitHub Desktop.
Save mhinze/854157 to your computer and use it in GitHub Desktop.
Effin, the smallest ORM ever. Requires no mapping! http://mhinze.com/simple-reads
using System;
using System.Collections.Generic;
using System.Data.Entity;
public static class Effin
{
public static IEnumerable<T> Query<T>(this string connectionStringName, string sql, params object[] parameters)
{
return new DbContext(connectionStringName).Database.SqlQuery<T>(sql, parameters);
}
}
public class Example
{
public void UsingEffin()
{
IEnumerable<Name> names = "data".Query<Name>("select FirstName from Person");
foreach (var name in names)
{
Console.WriteLine(name.FirstName);
}
}
public class Name
{
public string FirstName { get; set; }
}
}
@mhinze
Copy link
Author

mhinze commented Mar 4, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment