none
Mapping of Stored Procedure : What if my parameter is not a specific column and is a Comma Separated List of values or something like that ? RRS feed

  • Question

  • Hi Friends,

    I was just wondering if this would be possible in terms of parameter mapping. Suppose I want to attach same ID with 10 different items and I've a stored procedure to do so in one shot by passing the Comma Separated Values, how could I do so ? The map function would make me call the same SP for 10 times ???

    Got a suggestion :

    I think your sproc would have to know what to do with the list of values if you passed them in single call

    Clarification:

    ... but my stored procedure seems to be working correctly all I do is parse the CSV string and perform the insert operations, instead calling the stored procedure for each operation, I was wondering if I can map to a parameter or so for achieving this purpose. Controller sends me expected info, sproc works as expected its the Data Layer where I am stuck :-(

    Thanks,

    -Aarsh

    Monday, June 10, 2013 6:39 PM

Answers

  • On 6/10/2013 2:39 PM, MCTS wrote:

    Hi Friends,

    I was just wondering if this would be possible in terms of parameter mapping. Suppose I want to attach same ID with 10 different items and I've a stored procedure to do so in one shot by passing the Comma Separated Values, how could I do so ? The map function would make me call the same SP for 10 times ???

    Got a suggestion :

    I think your sproc would have to know what to do with the list of values if you passed them in single call

    Clarification:

    ... but my stored procedure seems to be working correctly all I do is parse the CSV string and perform the insert operations, instead calling the stored procedure for each operation, I was wondering if I can map to a parameter or so for achieving this purpose. Controller sends me expected info, sproc works as expected its the Data Layer where I am stuck :-(

    You can just call the sproc directly even with an EF connection and get a resultset back, just like you can call it with simple ADO.NET using SQL Command objects.

    An ORM is not a stops all and ends all solution, and somethings it simply cannot do.

    Monday, June 10, 2013 8:54 PM

All replies

  • Hi Aarsh;

    What version of Entity Framework are you using?

    How did you import the Stored Procedure into the EF model?

    Seeming your SP takes only  one parameter of type string that is all you would need to pass in.

      


    Fernando (MCSD)

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

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, June 10, 2013 7:49 PM
  • On 6/10/2013 2:39 PM, MCTS wrote:

    Hi Friends,

    I was just wondering if this would be possible in terms of parameter mapping. Suppose I want to attach same ID with 10 different items and I've a stored procedure to do so in one shot by passing the Comma Separated Values, how could I do so ? The map function would make me call the same SP for 10 times ???

    Got a suggestion :

    I think your sproc would have to know what to do with the list of values if you passed them in single call

    Clarification:

    ... but my stored procedure seems to be working correctly all I do is parse the CSV string and perform the insert operations, instead calling the stored procedure for each operation, I was wondering if I can map to a parameter or so for achieving this purpose. Controller sends me expected info, sproc works as expected its the Data Layer where I am stuck :-(

    You can just call the sproc directly even with an EF connection and get a resultset back, just like you can call it with simple ADO.NET using SQL Command objects.

    An ORM is not a stops all and ends all solution, and somethings it simply cannot do.

    Monday, June 10, 2013 8:54 PM