locked
With .NET 3.5 is there any way to get results from a stored procedure RRS feed

  • Question

  • I have to use .NET 3.5 because my class will run in Sharepoint 2010

    I takes 2 minutes to set a model and get results from LINQ to SQL.

    I was asked to do it with Entity Framework and I can't figure out any way to get a results set out of a simple stored procedure.

    I see bunch of examples for .NET 4.0 but none work when the project is .NET 3.5

    Should I tell the customer to use LINQ to SQL because Entity Framework can't deliver?


    Ofer Gal

    Wednesday, August 8, 2012 7:38 AM

Answers

  •   

    If the Stored Procedure returns all columns from a table that is in your model use that as the Entity in the function import as the return type.

    If the Stored Procedure does not return a complete entity that is in your model then you will need to create an entity in the model identifying all the columns being returned and giving the entity a name and use that entity in the function import.

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by Allen_MSDN Wednesday, August 15, 2012 1:40 AM
    Wednesday, August 8, 2012 2:42 PM

All replies

  • Hi Ofer,

    Please see this thread.

    Best Regards,


    Please mark this as answer if it helps with this issue!

    Wednesday, August 8, 2012 8:11 AM
  • Hi Ofer;

    Please see the MS article "How to: Import a Stored Procedure", for the steps needed to import a stored procedure into Entity Framework 3.5. Once you have that set up it is nothing more then calling a function to get your results.

      

    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Wednesday, August 8, 2012 1:55 PM
  • It is not at all like the link you sent probably because its Visual studio 2010

    You have the option to “Add a function import” and the return types can only be “None”, simple types or entity.

    If I choose none, the function name is not visible in the intelisence.

    I created an entity for the results and chose that. But then at run time I get the error:”No mapping specified for instances of the EntitySet and AssociationSet in the EntityContainer”


    Ofer Gal

    Wednesday, August 8, 2012 2:15 PM
  •   

    If the Stored Procedure returns all columns from a table that is in your model use that as the Entity in the function import as the return type.

    If the Stored Procedure does not return a complete entity that is in your model then you will need to create an entity in the model identifying all the columns being returned and giving the entity a name and use that entity in the function import.

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by Allen_MSDN Wednesday, August 15, 2012 1:40 AM
    Wednesday, August 8, 2012 2:42 PM
  • The SP returns data from 2 databases, I do not have just one table containing all the returned columns.

    I added to the model an entity that has the exact fields (columns) returned by the SP and used that as return type.

    That compiled but gave me the error:"No mapping specified for instances of the EntitySet and AssociationSet in the EntityContainer" at run time.


    Ofer Gal

    Wednesday, August 8, 2012 3:46 PM
  •   

    Did you go to the Function Import for the SP and modified it to return a type of entity you created?  

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Wednesday, August 8, 2012 3:56 PM