Ticket Q410007
Visible to All Users

XtraReports 11.2 - Parameters/Filter String don't work with Entity Framework

created 13 years ago

Hello,

I have report that use Entity Framework (mysql) entities to get data. Report is bound to data at runtime, with following code:

void rep_DesignerLoaded(object sender, DevExpress.XtraReports.UserDesigner.DesignerLoadedEventArgs e)
{

using (var ctx = new biatelbit_kancelaria_tajnaEntities())
{

IDesignerHost host = e.DesignerHost as IDesignerHost;
BindingSource bs = new BindingSource()
{
DataSource =
(from d in ctx.v_ra_osoby_uprawnione select d).ToList()

};

//Remove design-time binding source
foreach (IComponent component in host.Container.Components)
{
if (component is BindingSource)
host.Container.Remove(component);
}

//add runtime binding source
host.Container.Add(bs);

rep.DataSource = bs;
}
}

And then, end user designer is invoked:
rep.ShowRibbonDesignerDialog();

Everything works in end user designer - report data are displayed correctly when user choose PrintPreview tab. Next, end user adds new parameter - screenshoot http://screener.tk/f/o/f/t3nkb.png and filter string for report - screenshoow: http://screener.tk/f/o/f/4T3ZD.png

After this, end user invokes print preview tab, print preview is always empty: http://screener.tk/f/o/f/ptIR0.png and it should not be empty. If I use this filter string for report: [OS_IMIE] Like 'Jan' (instead of [OS_IMIE] Like '?parName'), filter works fine and prints all data like it should: http://screener.tk/f/o/f/HDsBG.png

What's wrong and why parameters does not work?

Answers

created 13 years ago (modified 13 years ago)

Hello Michal.
Thank you for your message. This behavior is caused by the fact that you pass a parameter name as a value to compare with. As a result, a report compares the OS_IMIE field value not with parName.Value, but with the "?parName" string.
To access parameters in the Filter Editor, click the icon on the right of the value until it turns into a question mark. Please refer to the "Filtering Data" help topic for additional information.

    Comments (3)
    MO MO
    Michal Olszewski 13 years ago

      Do you mean it should be:
      [OS_IMIE] Like ?parName
      instead of:
      [OS_IMIE] Like '?parName'
      You are right. I've checked what happens if I use pure .net Dataset, instead of Entity Framework. [OS_IMIE] Like ?parName works, and [OS_IMIE] Like '?parName' does not work.
      But, with Entity framework both does not work. It seems report data are not refreshed properly with bindingSource end Entity Framewok when user click "Submit" on parameters list. After click "Submit", new data should be loaded from database and this does not happen and report is not updated.
      How to solve this?

      DevExpress Support Team 13 years ago

        Would you please provide us with a small compilable sample project to demonstrate this issue? We will examine it and do our best to find a solution.
        I am looking forward to hearing from you.

        MO MO
        Michal Olszewski 13 years ago

          Hello,
          I finally solved this by using DataSourceDemanded event for my report. If I use this:
          using (var ctx = new biatelbit_kancelaria_tajnaEntities())
                      {
                          var fieldList = (from d in ctx.v_ra_osoby_uprawnione select d).ToList();
                          BindingSource bs = new BindingSource() { DataSource = fieldList };
                          rep.DataSource = bs;
                      }
          as OnDataSourceDemanded, report is refreshing after paremeter submit. But this is not very good soloution, it's better when data refreshes automatically

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.