I am using UOW in an ASP.NET Core Web API with EF Core. When trying to read values from a stored procedure with UOW the dbContext.Database.SqlQuery
method is not found.
Currently I'm using EF Core 5 and .NET 5.
This is my IRepository
interface:
public interface IUnitOfWorkIntegrado
{
IRepository<T> Repository<T>() where T : class;
Task SaveChangesAsync();
Task BeginTransactionAsync();
Task RollBackAsync();
Task CommitAsync();
Task<List<T>> GetSP<T>() where T : class;
}
My UOW implementation:
public class UnitOfWorkIntegrado : IUnitOfWorkIntegrado
{
public Task<List<T>> GetSP<T>() where T : class
{
// SqlQuery does not appear as a method
return dbContext.Database
.SqlQuery<T>(spQuery, parameters).ToList();
}
}
How can I implement this pattern?