Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // sync
- Product produto;
- using (var connection = new SqlConnection(configuration.GetConnectionString("DefaultConnection")))
- {
- 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")))
- {
- produto = await connection.QuerySingleAsync<Product>(@"SELECT * FROM Products WHERE ProductID = @Id", new { id = 2 });
- }
Add Comment
Please, Sign In to add comment