I try to pass to a SSRS report, from the C# code multiple arrays of integer
var rsExec = new ReportExecutionServiceSoapClient(binding, new EndpointAddress(config.ReportExecutionUrl));
ParameterValue[] reportParam = new ParameterValue[] {
new ParameterValue { Name = "pCityId", Value = cityId.ToString() },
new ParameterValue { Name = "pDepartmentIds", Value = string.Join(",", departmentIds) },
new ParameterValue { Name = "pBuildingIds", Value = string.Join(",", buidingIds) }
};
await rsExec.SetExecutionParametersAsync(null, null, reportParam, "en-us");
as the Value type of ParameterValue is "string", it seems I have no choice but passing a CSV as parameter to the report.
Then, in the report I can use data type as integer, and say that I am passing "multiple values", but how to do it from the C# code?
PS. Related to that question
To send parameters where the Allow multiple values option is selected, you need to send a new ParameterValue
object for each value that is going to be consumed by the report, all with the same Name
.
In the case described above, you need to send a ParameterValue
for each value in the departmentIds
collection, all with the same parameter name ("pDepartmentIds").
So, if there was 3 department IDs to send, the reportParam
array should contain 3 ParameterValue
objects, all with the name "pDepartmentIds", one for each department ID.
ParameterValue[] reportParam = new ParameterValue[] {
new ParameterValue { Name = "pCityId", Value = cityId.ToString() },
new ParameterValue { Name = "pDepartmentIds", Value = "1" },
new ParameterValue { Name = "pDepartmentIds", Value = "2" },
new ParameterValue { Name = "pDepartmentIds", Value = "3" },
...
};
Do something similar for buildingIds
.