FastReport.Net has been supplying plugins for a long time - connectors to various databases. These plugins allow you to add connectors to the report designer to connect to the required database. The purpose of creating these plug-in connectors is to simplify the process of connecting to a data source.
However, there is one inconvenience in using such plug-ins - they must first be compiled. And for this you must first download third-party libraries from the developer's database site. But, once you have compiled the plug-in, you can use it for as long as you like.
FastReport now distributes these connectors in the form of libraries through the Nuget package manager. This is true both for the .Net Framework 4 application and for ASP .Net Core. Now we are spared the need to compile plugins with third-party libraries, for which many thanks to the developers of FastReport.
Let's talk about the peculiarities of using these libraries. To create a report, you need to call the designer. With plugins, you would use a separate Report Designer program, which is convenient. But with the installed connector libraries, you'll need to call a designer from your application to use these connectors in your report.
If for WinForms applications to call the report designer from the code is a trifle, then in .Net Core applications it is impossible. Of course, there is Online Designer for web development of reports, but this is a completely different story. Therefore, you must first create a WinForms application, install the required connector into it and call the report designer. Or you can use the already compiled Designer.exe application that comes with FastReport, but in this case the list of supported DBMS will be limited (MS SQL is supported).
Let's now take a look at all this with an example. Create a test WinForms application and add FastReport.Net libraries to it. And also try to install connectors from the manager Nuget.
The figure shows that we have connectors to the databases: MsSql, MySql, Postgres, SQLite, Json, MongoDB, RavenDB.
Let's try to connect to the Json data source. Install the appropriate connector from Nuget.
On the form, add a button and the following code for it:
In the first line of the button click event handler, we initialize the added JSON connector. Then create a report object and call the designer.
In the designer, we create a new data connection. And among the available connectors we see the JSON we added. Select it and set the path to the data file with the .json extension.
Create a report template and save it. Now, in the code for our button, you can replace the line:
Here we specify the path to the report file that we created earlier and run the report for the show.
Thus, using the library-connector required from us only two actions - to install the library from Nuget, and to initialize it in the code.
However, not everything is so simple if it comes from ASP .Net Core application.
Firstly, we need to create a report. And for this we need to run the designer from the code. In web projects, this is impossible. I'll have to create a WinForms application, specifically to run the designer. Either install the plugin in a separate ReportDesigner and create reports in it.
Secondly, the program code is somewhat more complicated. In addition to initializing the connector library, you will need to specify a connection string, create tables, and add a connection to the report:
By labor, this is comparable with the use of third-party libraries for connecting to databases. So, in the case of .Net Core, not everything is so unambiguous. But in the .Net Framework 4 applications, the advantages over third-party libraries are obvious.