I have a proc that returns two fields as a custom class generated by the EF framework (a mapped class for the custom result). Can I join the proc results in with a ADO.NET EF LINQ query? I’m getting errors that suggests no, but I’m not sure.
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, joining resultset from stored procedure in Linq to entities query is not possible. It is also very hard in SQL directly – I can imagine some approach with OpenQuery in TSQL but it is terrible solution.
If you really need to join result from your stored procedure with some Linq to entities query you should execute stored procedure and query separately and join them using Linq to objects. But be aware that this solution will transfer complete resultsets from both operations to your application server and join will be performed by .NET in memory.
Another solution is to rewrite your stored procedure to UDF (user defined function in TSQL). In this case you will not be able to use mapping of function result into entity but you will be able to join result of the function with other query in EQL.
The best solution in this case would probably be new stored procedure which performs the necessary join operation.