Intercept Query and Filters
I have a business object from Entity Framework that I have added to the report
Shipments = new List<Shipment>();
Report.RegisterData(Shipments, "Shipments");
Report.NEED_DATA += new SomeCallbackToGetData(); ??? how to get data
The fields show up in the Designer and I can design a report.
In the reports Data Band I have a Filter [Shipments.State]="NY" ?? filters can change in the report
Is there an event either in Report, or Connection that is raised so I can query the data and apply the Data Filters?
Private void SomeCallbackToGetData(){
var QueryFilter=report.GetDataBandQueryFilter() ??? How to get Fiter????
dbContext = new EF6Context();
Shipments = dbContext.Shipments.Where(w => w.State == "???").ToList(); //need to dynamically add Filters from Expression Tree
Report.RegisterData(Shipments, "Shipments");
}
There seems to be very limited support for EntityFramework or Odata do you have any better examples
Thanks,
Mike Pisano
Shipments = new List<Shipment>();
Report.RegisterData(Shipments, "Shipments");
Report.NEED_DATA += new SomeCallbackToGetData(); ??? how to get data
The fields show up in the Designer and I can design a report.
In the reports Data Band I have a Filter [Shipments.State]="NY" ?? filters can change in the report
Is there an event either in Report, or Connection that is raised so I can query the data and apply the Data Filters?
Private void SomeCallbackToGetData(){
var QueryFilter=report.GetDataBandQueryFilter() ??? How to get Fiter????
dbContext = new EF6Context();
Shipments = dbContext.Shipments.Where(w => w.State == "???").ToList(); //need to dynamically add Filters from Expression Tree
Report.RegisterData(Shipments, "Shipments");
}
There seems to be very limited support for EntityFramework or Odata do you have any better examples
Thanks,
Mike Pisano
Comments
This example is based on the Preview control, I need the Designer Control and the data is too big to load prior to the designer.
I need a connector\connection or callback for the business object to load and apply the reports tables and filters
I see events like StartReport() and LoadBusinessObject() will they help?
Thanks Again,
Mike
once you push data to fastreport you can manipulate the original data interactively.
should be no problem with webreport since dialog form is supported in webreport, end user can filter the report easily.
if needed, you can call MVC controller / WebApi from webreport. put hyperlink java script:function(); in report to call javascript in your view/page, use ajax from javascript to call your controller and get the result
This is NOT a Web Report, This is a WinForm EXE using EF6 to get to Databases\Business objects
I can not load the "Original Data" there are too many tables and the data is too large.
Using Designer control on a form,
If I:
1) Add a Table
2) Add some Fields
3) Add a Filter
4) Press Preview
How do know the data and filter so I can query for Preview
Thanks,
Mike
Any Suggestions?
you even didnt open my previous example, "exercise.frx" => dynamic filtering data
maybe like this:
1. suppose winforms/wpf is compiled to 'MyApplication.exe' and the namespace is MyNamespace
2. load frx template, push businessobject to fastreport
3. from script in frx file (executed at runtime), you can refer the data : Report.GetDataSource("Shipments").Reference and casting it, you can play the original data at runtime
4. from fastreport script, you need to call a function (callback) declared in exe file.
5. fastreport script, add myapplication.exe as referencedassemblies (see fastreport documentation)
6. in myapplication.exe, create a function "MyFunction" in static class (therefore you dont need to create an instance)
7. from fastreport script, call the function : MyNamespace.MyStaticClass.MyFunction()
I had discounted the "FRX Solution" because I would rather handle the data binding and Filtering in c#
I am trying to give our employees the ability to create and produce reports given the set of databases that they have "rights" to.
I can dynamically add their available tables with Report.RegisterData(foo, "foo") and they can create new FRX's and easily design.
These uses are not really programmers and would like to do all of this within the EXE which is why I was looking down at the Connection level.
All the above works today, (ie) Register the Model in c# and you choose your tables can design an FRX... whats missing is the Data when Previewing or Running.
I guess I would like to write an Entity Framework Connection class?
I would need to ENUM the report bands for tables, relations and filters and dynamically build the Linq expression trees for EF.
Is there anything remotely close to this before I reinvent the wheel?
Thanks Again,
Mike Pisano
filtering data can be done at:
1.database level => stored procedures
2.application level => business object and linq
3.frx level => scripting, though you've loaded frx file, you may modify it, adding script at runtime without permanent changes in original frx file (see report through code). callback to application level is possible.
flow of data:
application level => ORM (business object)
frx level (scripting) => catch business object: Report.GetDataSource("Table Name").Reference as List<BusinessObject>;
application level =>
// push data to frx file
report.RegisterData(businessobject, "table name");
// you can add script here
report.ScriptText = @"";
// open the designer (dialog window), data is pushed to designer
report.Design();
// show the report (preview)
report.Show();
script can be added at application level without permanent changes in original frx file.
sounds like "report through code", you may manipulate report object without permanent changes in original frx file.
I think the biggest flaw is the filtering system
1 - Database level and Stored procedures is not the way Entity Framework works
2 - Application Level would take all the flexibility out of a person designing a report forcing me to define the tables and filters
3 - frx level would mean people would need to learn linq and coding which is beyond basic users
I should just be able to Register the Model and Context and FR should enum all the tables and fields and just work
I think the biggest disappointment in looking through the code is there is no way even at the connection level that the databand "Filters" bubble up through the layers. They need to be written as a "Select" in ReportScript or the application which might be OK for SQL but not EF6.
So even if you put [table.fields] == "foo" as a databand filter, the actual query will be the Entire table across the wire and then the filter is locally applied. These queries would likely timeout and\or flood the network and kill the server!
I really feel like I'm missing something.... I'm not sure with all your recent work on porting to .net core how you don't have better support for Entity Framework?
Before I really start redesigning your DataSourceBase classes... Is this something FR is working on internally? I really don't want to put hours into designing this if its already on your design board.
Thanks,
Mike Pisano
https://stackoverflow.com/questions/1931149...mber-of-records
The Result sets are not large but the dataset is, which is why my concern over filtering.
I agree that EF can be inefficient as the article points out, but mostly around SaveChanges and figuring out what has changed and persisting it.
I'm not worried about this for a report since it's read only, I'm more concerned if I gave direct access to the sql server and bypassed the Business rules within the controller.
As far as memory concerns, I'm converting the iQueryable back to the DataTable[] so FR can render and EF can free the memory.
I Have a new hacked Connection class and a newer DS inherited from DataSourceBase... I have tables\classes from the context now in the UI and I can design and preview, but still have to figure out how to pass the filters up through your compiler logic and build the dynamic linq queries.... and then comes Master\Detail & relations.... fun fun fun [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Regards, Mike[/img]
I have a working EntityFramework Connection project for EF6 based on Dynamic Linq but it does require my modified Databand, and DataSource FR Base Classes.
I don't mind posting my source for others, but I don't want to post the 2 Fast .cs files without permission.
I think EF6 support is long overdue, please let me know how I should proceed....
If other have source licenses I can send you a diff
Regards,
Mike Pisano