Hi,
I have been exploring on how to use ObjectDataSource and manage to make it work but I am encountering an error when passing parameter with Multi-value
HourlyTicketODS DataSource : Object must implement IConvertible.
I searched on online and based on the answers provided i should change the parameter type to object[] however it still doesn't work. I tried string[], IEnumerable<string>, IEnumerable<object>, List<object> and List<string> still the same.
Solutions i found on the internet but doesn't work:
https://docs.telerik.com/reporting/knowledge-base/object-must-implement-iconvertible
https://www.telerik.com/forums/objectdatasource-and-multivalue-parameter
Using =JOIN() and making the method's parameter as string works. Is it really doable to pass array? because on the documentation it states that
"The Data Source Components are based on ADO.NET and ADO.NET does not allow a collection of values to be passed. The SqlDataSource Component however supports parametrized SQL queries by associating the report parameters with placeholders in the SelectCommand
query. "
My config and code for reference
using System.ComponentModel;
using System.Diagnostics;
namespaceTelerikReportData
{
public class HourlyTicket
{
publicint Id { get; set; }
publicstring Category { get; set; } = string.Empty;
publicstring Status { get; set; } = string.Empty;
}
[DataObject]
public class HourlyTickets
{
[DataObjectMethod(DataObjectMethodType.Select)]
public List<HourlyTicket> GetHourlyTickets(DateTime from, DateTime to, object[] categories)
{
Debug.WriteLine($"HOURLY TICKET ODS | Date Range Params: From = {from.ToString()}, To = {to.ToString()}");
//Debug.WriteLine($"HOURLY TICKET ODS | Categories = {categories}");return [new HourlyTicket {
Id = 1,
Category = "Load Reprocessing",
Status = "ongoing"
}];
}
}
}