asp.net mvc - How to check if value is multiple or not in key value c# -
here method:
protected override void onactionexecuting(actionexecutingcontext filtercontext) { var parameters = filtercontext.actionparameters.toarray(); if (parameters.count() > 0) { foreach (keyvaluepair<string, object> data in parameters) { singleparameters = singleparameters + data.key + ":" + " " + data.value + ","; } singleparameters = singleparameters.remove(singleparameters.lastindexof(','));
i want check if data value contain single or multiple value.
if data single data key:req
, value: pagerecords:200
.
if data contains multiple values there check if values contain array or single value. fot example: key:req
, values: pagerecords:200, pageinfo:"adsa", count:0, filter: records:200,cotnain:"asa"
i want check condition access that..
i newbie in area please give me suggestion more clarification
foreach (keyvaluepair<string, object> data in parameters) { if (data.key == "request" && data.value jqgridrequest) { var fields = g.gettype().getproperties(); bool hassinglevalue = fields.count(x => x.getvalue(g, null) != null) == 1; } }
as screenshot clear data.value type jqgridrequest, can directly make use of object check or desired value, dont need looping , directly cast object , make use of property using if else.
jqgridrequest request = data.value jqgridrequest; if (request != null) { int pageindex = request.pageindex; //// on other properties, , use directly without looping. }
Comments
Post a Comment