Asp.Net Core 3.1 Error: FromSqlRaw or FromSqlInterpolated was called with non-composable 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


Asp.Net Core 3.1 Error: FromSqlRaw or FromSqlInterpolated was called with non-composable 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.

Solution:

Add AsEnumerable<DTO_ClassModelHere>();

 IEnumerable<DTO_ClassModelHere> _yourObject = _context.DTO_ClassModelHere.FromSqlRaw("EXECUTE dbo.YourStoreProcedure {0}", YourParameter).AsEnumerable<DTO_ClassModelHere>();

//The code above should resolve the error.


-Make sure that any other functions consuming the _yourObject result returns IEnumerable as well. The chain should maintain until the Collection reaches it's final destination that is the Front-End.
-Make sure that the AsEnumerable() is comes after FromSqlRaw or else you will still see the error.





jim said:

Thank you.

Posted On: March 01, 2020 14:30:11 PM
Rid said:

Good work, thank you.

Posted On: March 01, 2020 14:29:43 PM
Jack said:

Thank you

Posted On: March 01, 2020 14:11:06 PM

© 2024 - ErnesTech - Privacy
E-Commerce Return Policy