Guest User

Untitled

a guest
Jul 18th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. // sync
  2. Product produto;
  3. using (var connection = new SqlConnection(configuration.GetConnectionString("DefaultConnection")))
  4. {
  5. // For test pourposes, it's taking top 10. On a reasonable scenario that'll be a top 1.
  6. produto = connection.QuerySingle<Product>(@"SELECT * FROM Products WHERE ProductID = @Id", param: new { id = 2 });
  7. }
  8. // async
  9. Product produto;
  10. using (var connection = new SqlConnection(configuration.GetConnectionString("DefaultConnection")))
  11. {
  12. // For test pourposes, it's taking top 10. On a reasonable scenario that'll be a top 1.
  13. produto = await connection.QuerySingleAsync<Product>(@"SELECT * FROM Products WHERE ProductID = @Id", new { id = 2 });
  14. }
Add Comment
Please, Sign In to add comment