Get all IDs from a response using LINQ -
i trying write query take customer id’s taken response , once have them cancel customers.
what did ran search used search request web service , in response list of customer id’s.
_request = new searchrequest(); _request.company = "newcompany";
the linq query needs take list of customer id’s response ‘searchrequest’ , find them , delete them.
the problem customer id’s can number depending on company name search results. thought write line of code:
_response.customers[ ].custid
but error because don’t include value can’t because won’t know value. want take many id’s came request , use them in linq query. here have far:
ienumerable<customerinfo> custinfo = cust in custinfo cust.custid = _response.customers[].custid //this line wrong select cust;
now give little more detail, once had customer id’s linq query gather them , cancelrequest following code:
_request = new cancelrequest(); _request.custid = custids; // put gathered custid’s request delete customers associated.
if have ideas (or questions solved) on how go please let me know!
thanks!
var customerids = _response.customers.select(c =>c.custid);
now have collection of custids.
does each request delete 1 customer or many customers? property name custid guess deletes 1 customer (because name singular) so need send 1 request each customer want delete
foreach(var custid in customerids) { _request = new cancelrequest(); _request.custid = custid; // send request }
paul linton
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment