I am building a reporting engine. The goal is to have a database only driven reporting solution. I only have one piece remaining to make it work right.
So I am using reflection to create the report itself off of the database report table and all parameters are dynamically handled on the UI. The trick is getting the data for the report. All reports will have a stored procedure to compile the data needed. Currently I have a report ObjectDataSource being loaded like this:
public static Telerik.Reporting.ObjectDataSource GetReportDataSource(Dal.Report report, Dictionary<string,object> parameterValues)
{
Telerik.Reporting.ObjectDataSource dataSource = new Telerik.Reporting.ObjectDataSource();
dataSource.DataSource = typeof(ReportLogic);
dataSource.DataMember = string.Format("GetData{0}", report.Name.Replace(".", ""));
foreach(KeyValuePair<string,object> parameter in parameterValues)
{
dataSource.Parameters.Add(new Telerik.Reporting.ObjectDataSourceParameter(parameter.Key, parameter.Value.GetType(), parameter.Value));
}
return dataSource;
}
and each report then has to have a method like this:
public static IEnumerable<StoredProcedureDomainMethodReturnShapeHere> GetData<ReportNameHere>(<StoredProcedureParametersHere>)
{
using (DataContext dataContext = new DataContext())
{
return dataContext.StoredProcedureName(StoredProcedureParameters);
}
}
So the goal is to only have ONE GetData method instead of one per report. I am not sure if I should use a different object than the ObjectDataSource or how I can make the Stored Procedure call to a dynamically named SP with params.
Trying to avoid using SQLDataAdapter and Datasets... hoping there is a way to do this with DataAccess dynamically.