Last active
August 11, 2018 20:42
-
-
Save scottsauber/f2134b78b83717732c62882473a3d932 to your computer and use it in GitHub Desktop.
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
public class Customer | |
{ | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
public string ZipCode9 { get; set; } | |
} | |
public List<Customer> GetCustomersByState(string state) | |
{ | |
var dbConnection = new SqlConnection("SomeConnectionString"); | |
string sql = $@"SELECT F_Name AS {nameof(Customer.FirstName)}, | |
L_Name AS {nameof(Customer.LastName)}, | |
Zip_Code AS {nameof(Customer.ZipCode9)} | |
FROM Customers | |
WHERE State = @State"; | |
var parameters = new DynamicParameters(); | |
parameters.Add("State", state); | |
return dbConnection.Query<Customer>(sql, parameters).ToList(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment