I am moving to EF Core and trying to call a stored procedure with 2 parameters.
The current setup for 1 parameter works fine.
Here is the error I see:
System.InvalidOperationException: FromSqlRaw or FromSqlInterpolated was called with non-compostable SQL and with a query composing over it. Consider calling
AsEnumerable
after the FromSqlRaw or FromSqlInterpolated method to perform the composition on the client-side. at
Here is my repository call:
public IQueryable<PartsGridDTO> GetPartsGridQueryable(int partId, int groupId)
{
return MoreContext.SpPartsGridDetailYourCases
.FromSqlRaw($"EXECUTE dbo.GetProductsByPartAndGroup {partId}, {groupId}")
.Select(s => new PartsGridDTO
{
PartId = partId,
//....
}).AsQueryable();
}
I've tried some fixes from here:
Include with FromSqlRaw and stored procedure in EF Core 3.1
but none of those work.
I am returning AsQueryable()
up until the controller and then calling .ToListAsync()
.
I tried adding .IgnoreQueryFilters();
right before .AsQueryable()
, but I still see the error.
Any thoughts? Am I passing in the parameters wrong? Is it an EF Core issue or?