Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // sync
- Product produto;
- using (var connection = new SqlConnection(configuration.GetConnectionString("DefaultConnection")))
- {
- // For test pourposes, it's taking top 10. On a reasonable scenario that'll be a top 1.
- produto = connection.QuerySingle<Product>(@"SELECT * FROM Products WHERE ProductID = @Id", param: new { id = 2 });
- }
- // async
- Product produto;
- using (var connection = new SqlConnection(configuration.GetConnectionString("DefaultConnection")))
- {
- // For test pourposes, it's taking top 10. On a reasonable scenario that'll be a top 1.
- produto = await connection.QuerySingleAsync<Product>(@"SELECT * FROM Products WHERE ProductID = @Id", new { id = 2 });
- }
Add Comment
Please, Sign In to add comment