Skip to content

Instantly share code, notes, and snippets.

@hagbarddenstore
Created May 26, 2014 10:11
Show Gist options
  • Save hagbarddenstore/1f1d1ad87fc1d3938de8 to your computer and use it in GitHub Desktop.
Save hagbarddenstore/1f1d1ad87fc1d3938de8 to your computer and use it in GitHub Desktop.
class Queries
{
public static readonly string FindPrices = @"
SELECT *
FROM prices
";
public static readonly string FindOneUserByUsername = @"
SELECT *
FROM users
WHERE username = @Username
LIMIT 1
";
}
class PriceEntity
{
public int Id { get; set; }
public double Price { get; set; }
}
class User
{
public int Id { get; set; }
public string Username { get; set; }
}
class Database
{
public IEnumerable<PriceEntity> FindPrices()
{
using (var connection = CreateConnection())
{
var prices = command.Query<PriceEntity>(Queries.FindPrices);
return prices;
}
}
public User FindOneUserByUsername(string username)
{
using (var connection = CreateConnection())
{
var user = command.Query<User>(Queries.FindOneUserByUsername, new { Username = username }).FirstOrDefault();
return user;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment