How do I get Linq to SQL to recognize the result set of a dynamic Stored Procedure?

后端 未结 2 843
醉酒成梦
醉酒成梦 2021-01-05 04:03

I\'m using Linq-to-SQL with a SQL Server backend (of course) as an ORM for a project. I need to get the result set from a stored procedure that returns from a dynamically-cr

2条回答
  •  一生所求
    2021-01-05 04:38

    There's no real easy way to do this. I've had the same problem in the past. I think the issue is that Linq to Sql has no way of "figuring out" which type will be returned since you're building up the SELECT statement at execution time. What I did to get around this, was in the stored proc, I did just a select and selected all the columns that I possibly needed. Then, I had Linq to Sql generate the function based on that. Then, I went back to SQL and changed the stored proc back to the way it's supposed to be. The trick here is not to regenerate your DBML.

提交回复
热议问题