Last post Sep 09, 2013 06:55 PM by AidyF
Sep 09, 2013 05:59 PM|Devaraju|LINK
Hi i have stored procedure called uspMarket_test. I need to pass prameter called
session to this SP.
I am writhing this code in controller . Here sess conatains values of session which i am passing.
public ActionResult Index(string sess)
var permissions = new Accept();
In terms.cs, i am using :
public void permissions(string sess)
using (var ctx2 = new market_Entities())
//Here i need to assign sess = session, so value of sess will be equal to session string.But dont know how to do this. ctx2.uspMarket_test(new ObjectParameter("UserID", typeof(int)),"session", new ObjectParameter("Login",typeof(short)));
Here problem i am having is, second parameter session. I need to assign
sess value to session paramter, so when i pass session to SP, it will take sess values. but i dont know how to assign this.
Sep 09, 2013 06:27 PM|AidyF|LINK
Google how to call SPs from Entity Framework, but I'm pretty sure you just call the method like any other method
ctx2.uspMarket_test(123, sess, 1)
or whatever the variables are you need to pass to the params. In the above, 123 is the first param, sess the second and so on.
Sep 09, 2013 06:52 PM|Devaraju|LINK
I tried this before.My doubt is my second parameter name is Session in my SP. so if i pass
sess in place of Session which is string, will it still work?.
When i debug i can see sess values in sess variable but in my table it is not updating. So i have doubt on calling Session parameter.
Sep 09, 2013 06:55 PM|AidyF|LINK
Your variable names don't have to match the parameter names. The param names are just an aid to let you know what the param means. If your data is being updated then I'd image the issue is with the stored proc. Use SQL Profiler to trace what is being
executed against your db and see if you can spot anything obvious with it.