Home > Articles > Details

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.


Please Login to see the rest of the answer
Answer:

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.


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.

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

© 2022 - ErnesTech - Privacy