Guest User

Untitled

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