Dictionary parameter of custom function

Stimulsoft Reports.NET discussion
Post Reply
bra
Posts: 7
Joined: Tue Jul 09, 2019 11:23 am

Dictionary parameter of custom function

Post by bra »

Hello.

Where I can find a list of supported data types in reports.
Currently I am trying to create a custom function with a dictionary argument (.net core, dictionary<string, string>) but in designer it appears with parameter type object instead of dictionary<string, string>.

Could you please provide me a simple example how I can operate with dictionary data type in reports?
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Dictionary parameter of custom function

Post by Lech Kulikowski »

Hello,

Please try to register it as business objects:
report.RegBusinessObject(object);
report.Dictionary.SynchronizeBusinessObjects();

Thank you.
bra
Posts: 7
Joined: Tue Jul 09, 2019 11:23 am

Re: Dictionary parameter of custom function

Post by bra »

I see from reflection information that the "object" has an underlying type of StiBusinessObject. So what I've done is declare an input parameter of the same type and then a simple cast of parameter's BusinessObjectValue property:
Was (dictionary displayed as "object" in designer):

Code: Select all

public static string GetDictionaryValue(IDictionary<string, string> fields, string key)
{
       	???
}
Changed to:

Code: Select all

public static string GetDictionaryValue(StiReportNS.Dictionary.StiBusinessObject fields, string key)
{
       	var dictionary = fields.BusinessObjectValue as IDictionary<string, string>;
	...
	var value = dictionary[key];
	...
}
Thanks.
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Dictionary parameter of custom function

Post by Lech Kulikowski »

Hello

Please let us know if you need any additional help.

Thank you.
Post Reply