Manually Link Stored Procedure To LINQ
I have a Stored Procedure that returns a dynamic result set based on a temporary table. My project uses LINQ for Data Access, but I can’t incorporate LINQ with this Stored Procedure because it has a dynamic “shape” (I can’t say before hand which columns will come back or how many there will be), so LINQ can’t generate at design time an object that can hold the results.
I am trying to integrate the stored procedure the old fashioned was, using SQLDataAdapter and such, but I was hoping that I could still tie into LINQ so that I don’t need to manage a separate transaction mechanism as that would be a disaster.
Is this possible? Thanks.
2 Solutions collect form web for “Manually Link Stored Procedure To LINQ”
One best practice is that a stored procedure should never be coded such that it gives different columns in a result set based on inputs.
It sounds like your design is causing the single stored proc to try and do too many things. I’d highly suggest you change this.
First – you aren’t using “LINQ” for data access. My guess is you are using Entity Framework for data access. If you are, it depends on which version of EF you are using.
New in Entity Framework 4 is shaping data from a stored proc. For step-by-step instructions, see this blog post: http://blogs.msdn.com/b/nihitk/archive/2010/04/23/ado-net-entity-designer-in-vs-2010-stored-procedure-return-type-shape-sensing.aspx
If you are using Entity Framework 1, which comes with .NET 3.5, then no EF does not have the ability to sense the shape of the stored proc data.