Skip to content

Instantly share code, notes, and snippets.

@aramkoukia
Created August 5, 2017 22:15
Show Gist options
  • Select an option

  • Save aramkoukia/b8f10403223e0c1cf12e976d5fb621bb to your computer and use it in GitHub Desktop.

Select an option

Save aramkoukia/b8f10403223e0c1cf12e976d5fb621bb to your computer and use it in GitHub Desktop.
public class DapperRepository
{
public List<Product> GetAllProductsByCategory(int categoryId)
{
using (IDbConnection db = new SqlConnection(@"Connection String"))
{
return db.Query<Product>
($"SELECT * From [SalesLT].[Product] INNER JOIN [SalesLT].[ProductCategory] ON [SalesLT].[ProductCategory].ProductCategoryId = [SalesLT].[Product].ProductCategoryId WHERE [SalesLT].[ProductCategory].ProductCategoryId ={categoryId}").ToList();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment