Unfortunately, our DB is dated back to the 90s. Its legacy is so strong that we are still using SP in order to do most of the CRUD operations. However, it seems that Dapper suits pretty well and we have just started to play with it.
However, I'm a bit concerned about how to handle a single data row. In this case, I'm using QueryAsync to call the SP passing an ID. As you can see, the object is returning outside of the async call(*).
Am I going to be in trouble? If so, does anyone know how to handle it? Do I need to use a QuerySync instead?
public class SchemePolicyRepository : ISchemePolicyRepository
{
private readonly SqlConnection sql;
protected SchemePolicyRepository(SqlConnection connection)
{
sql = connection;
}
...
public async Task<SchemePolicy> GetById(string id)
{
var schemePolicy = await sql.QueryAsync<SchemePolicy>("risk.iE_GetSchemePolicyById",
new { Id = id },
commandType: CommandType.StoredProcedure);
return schemePolicy != null ? schemePolicy.FirstOrDefault() : null;
}
...
}
(*)The SchemePolicy object returned by FirstOfDefault() is not an async method.