Created
March 4, 2011 04:06
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks to @mxmissle http://twitter.com/mxmissile/statuses/43528524379860992