I have a report that is using the Entity Framework for its data source. The report is working fine. I have added a simple string parameter to the report that I want to filter the results by. In my ReportDataSourceProvider I inspect the reportParameters dictionary for the parameter and it is found but the value is always something other than what was typed on the screen during report execution.
Value I typed in: timothy
Value I see in code behind for the OperatorName parameter: System.Func`1[System.Object]
Here is my class:
[ReportDataSourceExport(ReportSearchPattern = "ReportOperatorList.*")] public class ReportOperatorListDataSourceProvider : IReportDataSourceProvider, IDisposable { private EFModelEntities ctx = new EFModelEntities(); public object GetDataSource(string name, IDictionary<string, ParameterValue> reportParameters) { if (reportParameters.ContainsKey("OperatorName") && reportParameters["OperatorName"].Value != null) { var opname = reportParameters["OperatorName"].Value.ToString(); if (String.IsNullOrEmpty(opname)) { return ctx.Operators.OrderBy(c => c.OperatorName); } else { return ctx.Operators.Where(o => o.OperatorName.Contains(opname)).OrderBy(c => c.OperatorName); } } else { return ctx.Operators.OrderBy(c => c.OperatorName); } } public void Dispose() { ctx.Dispose(); } }
Any ideas on what I am most likely doing wrong?
Further research has shown me that my problem isn't with the Entity Framework but only with retrieving the value for the parameter from the reportParameter dictionary collection.
Code like this does not seem to work for me and I don't know why:
public object GetDataSource(string name, IDictionary<string, ParameterValue> parameters)
public
object
string
{
var customerId = (int) parameters["CustomerId"];
var
int
"CustomerId"
return _ctx.Customers.Where(c => c.CustomerID = customerId)
return
}
I took the above sample code from this URL and tried to make it work in my class in the original post but with no change in results. I am missing something somewhere and I'm not sure what it is.
Just realized that I didn't put any of my development environment specs up.
I am using VS2010, .NET 4.0, NetAdvantage 12.1. My application is written in C# and WPF with a SQL Server CE 4 database that is accessed via Entity Framework 4.
I am having the parameter retrieval issue when using an object data source that connects via the Entity Framework and I also have the issue when using a SQL Server CE 4 data source.
Hi Micheal.
I think you are dealing with a known issue. Please read this post. I believe you will find the solution there.
Regards!
Simon
I found it. Was looking all over the site but then went to my account and found the download there.
Simon, you are awesome! That was indeed my problem. Thanks a bunch because I was feeling very frustrated. I can't seem to find where to download the 12.1 SR. You wouldn't happen to know where or how I do that would you?