Created
May 26, 2014 10:11
-
-
Save hagbarddenstore/1f1d1ad87fc1d3938de8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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