Skip to content

Instantly share code, notes, and snippets.

@margusmartsepp
Created April 1, 2016 14:08
Show Gist options
  • Save margusmartsepp/ef20aba06a8b49462c21b5eeb32ef34d to your computer and use it in GitHub Desktop.
Save margusmartsepp/ef20aba06a8b49462c21b5eeb32ef34d to your computer and use it in GitHub Desktop.
ef7 code first + dapper
private static void Main(string[] args)
{
var connection = new SqlConnection(@"Server=(local);Database=EF7.ConsoleTests;Trusted_Connection=True;");
foreach (var result in connection.Query<Result>(@"
SELECT NAME as Name,
Count(NAME) AS Number
FROM [EF7.ConsoleTests].[dbo].[multiple] as k
GROUP BY NAME
ORDER BY Name, Number"))
{
Console.WriteLine($"{result.Name} {result.Number}");
}
}
public class Result
{
public string Name { get; set; }
public int Number { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment