Skip to content

Instantly share code, notes, and snippets.

@scottsauber
Last active August 11, 2018 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottsauber/7e70e31df7f40da5d09219edf52dcb08 to your computer and use it in GitHub Desktop.
Save scottsauber/7e70e31df7f40da5d09219edf52dcb08 to your computer and use it in GitHub Desktop.
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string ZipCode { get; set; }
}
public List<Customer> GetCustomersByState(string state)
{
var dbConnection = new SqlConnection("SomeConnectionString");
string sql = @"SELECT FirstName,
LastName,
ZipCode
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