ExecuteStoreQuery passing parameter to StoreProcedure

Posted by KDM on Stack Overflow See other posts from Stack Overflow or by KDM
Published on 2011-11-19T01:43:30Z Indexed on 2011/11/19 1:50 UTC
Read the original article Hit count: 459

Filed under:
|

Could someone help with passing a parameter object into my ExecuteStoreQuery. Im executing this from my Entities db and then creating my procedure on the fly is this possible and is my SQL correct. i need to pass a Id paramater value into my sql statement

var node = db.ExecuteStoreQuery<Node>(@"
    @Id int // not sure about this declaration for paramater    

    with c as (
        select Id, Name, ParentId,[0] as level
        from Department d
    union all
        select d.Id, d.Name, d.ParentId, [level] + 1
        from Department d
        join c on d.ParentId = c.Id)
    select * from c where c.Id = @Id"                                                         
"Departments", 
System.Data.Objects.MergeOption.NoTracking, 
new object{ Id: department.Id} // <--paramater object not working);               

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET