asp.net - Converting a list to an array for a web service -
i'm trying convert searchlist in web app list array can consumed in web method. right now, i'm using web reference allows arrays passed , returned. i'd convert list array, looks won't work. i've tried looking online each scenario i've found hasn't been similar enough i'm able solve this. idea on best way this?
web app
protected function searchcustomer() dim searchlist list(of prxcustomerwebservice1.customer) dim objcustomerws new prxcustomerwebservice1.customerws searchlist = cache("customerdata") 'arr = searchlist.toarray if (ddlsearchspecs.text = "contains") searchlist = objcustomerws.getcontains(tbsearch.text, ddlsearchfields.text, searchlist) elseif (ddlsearchspecs.text = "starts with") searchlist = objcustomerws.getstartswith(tbsearch.text, ddlsearchfields.text, searchlist) else searchlist = objcustomerws.getexact(tbsearch.text, ddlsearchfields.text, searchlist) end if if searchlist.count = 0 lmessage.text = "no customers found" end if return searchlist end function
web method
<webmethod(description:="gets customers contain specific value")> _ public function getcontains(byval sstringcontains string, byval spropertyname string, byval olistofcustomers list(of customer)) olistofcustomers() return customerfactory.getcontains(sstringcontains, spropertyname, olistofcustomers) end function
logic
public shared function getcontains(byval sstringcontains string, byval spropertyname string, byval olistofcustomers list(of customer)) dim ocustomerdata new customerdata dim onewlistofcustomers new list(of customer) dim iindex integer dim propertyinfo propertyinfo propertyinfo = gettype(customer).getproperty(spropertyname) if isnothing(olistofcustomers) = false andalso olistofcustomers.count > 0 try iindex = 0 olistofcustomers.count - 1 if (propertyinfo.getvalue(olistofcustomers.item(iindex)).tostring.trim.tolower.contains(sstringcontains.tolower) = true) onewlistofcustomers.add(olistofcustomers.item(iindex)) end if next catch ex exception return true end try end if return onewlistofcustomers end function
Comments
Post a Comment