0

I am calling a stored procedure (PS_StatistiqueEsc) via LINQ, and in the stored procedure i pass 3 parameters start,end and engin (see the code at bottom).

using (var escEnts = new escEntities()) {
var query = escEnts.PS_StatistiqueEsc(Convert.ToDateTime(start),
Convert.ToDateTime(end), engin).ToList();
}

so far so good.

my questions is how can i pass a 4th parameter as a list like (see the code at bottom) or an XML as a parameter:

For Example :

List<int> listToPassInSP = new List<int>();
list.Add(2);
list.Add(3);
list.Add(7);

using (var escEnts = new escEntities()) {
var query = escEnts.PS_StatistiqueEsc(Convert.ToDateTime(start), Convert.ToDateTime(end), engin, listToPassInSP).ToList();
}

Actually the stored procedure accept only 3 parameters ? I am going to changed change my sp which is going to accept a 4th parameter.

The actual SP signature is :

ALTER PROCEDURE [dbo].[PS_StatistiqueEsc] 
    @dateDebut datetime,
    @dateFin datetime,
    @EnginName varchar(250)     
AS

But will be changed like this :

ALTER PROCEDURE [dbo].[PS_StatistiqueEsc] 
    @dateDebut datetime,
    @dateFin datetime,
    @EnginName varchar(250),
    @listToPassInSP ???? (i don't know how to declare a variable like a list)
AS

Just want to pass a list to a SP and and the SP must accept a list. How can i do ?

d_raja_23
  • 339
  • 2
  • 3
  • 14
  • 4th parameter of what, where? Can you clarify a bit? Show the desired usage scenario if it is difficult to describe it verbally. – Eugene Podskal Aug 08 '14 at 15:09
  • thanks for your help, just came to modify my question... i want to pass a list or xml as a parameter in stored procedure. – d_raja_23 Aug 08 '14 at 21:46
  • If `PS_StatistiqueEsc` stored procedure accepts only 3 parameters, than how do you want to force it to accept the fourth? What is the signature of the `PS_StatistiqueEsc` and how should it handle the 4th param? Or do you mean that you want to add some predefined result set into the data returned by `PS_StatistiqueEsc`? – Eugene Podskal Aug 09 '14 at 09:01
  • Hi, i reformulated my question. – d_raja_23 Aug 11 '14 at 07:37
  • http://stackoverflow.com/questions/11102358/how-to-pass-an-array-into-a-sql-server-stored-procedure describes how to declare such a stored procedure in SQL (there are both answers that use XML and that directly use List). I never used such Stored Procedures with EF, but I think that the code generated by EF designer for this procedure will be quite straightforward and easy to use. – Eugene Podskal Aug 11 '14 at 09:35

0 Answers0