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.


Edit this Article
asp.net Core 3.1 asp.net mvc asp.net core errors asp.net web forms asp.net core tutorial Technology published
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

jim said:

Thank you.

Rid said:

Good work, thank you.

Jack said:

Thank you

Your Session is Ending
Login to Continue

© 2021 - ErnesTech - Privacy