Saturday, 15 March 2014

asp.net mvc 4 - Passing datas from controller to DAL -



asp.net mvc 4 - Passing datas from controller to DAL -

i created web method take parameters this

public httpresponsemessage makeorders([fromuri] int[] orderid) { }

for request this

http://www.test.com/makeorders?orderid=1&orderid=2

i need pass these orderid's dal. have 2 questions

[fromuri] proper implementation or standard way of practice passing array values in query string? do need loop orderid's , pass dal single element can create dal this

dal

public void updateorder(int orderid) { var query = 'update tbl set isapproved=1 orderid=@orderid'; }

or need send array this

public void updateorder(int[] orderid) { var query = 'update tbl set isapproved=1 orderid in (@orderid)'; }

the first reply is: thought improve way pass list in json format

for example:

// json format var a=[1,2,3];

pass value using $.ajax() method of jquery.

second reply be:

public void updateorder(int[] orderid) { var orderids= string.join(",", (string[])orderid.toarray(type.gettype("system.string"))) var query = 'update tbl set isapproved=1 orderid in (@orderids)'; }

asp.net-mvc-4

No comments:

Post a Comment