on 03 Dec 2019 7:08 PM
  • MongoDB
  • DevExpress

Report development in .NET core is a major road block for developers as the support for report creation using RDLC and crystal reports is not available in .NET core. There are many third party tools available in the market which support report creation in .NET core.

DevExpress is one such tool which provides the ability to create reports and dashboards in NET core. Being a Microsoft partner and the underlying report tool development technology being .NET, DevExpress products integrate nicely with .NET Core. DevExpress has a report designer which can be used from inside visual studio , a web viewer to render the reports. DevExpress provides option for connecting to diverse data sources from standard databases like SQL Sever to excel File. This provides options for integrating data from various platforms into Reports.
 

DevExpress integration with MongoDB

MongoDB is a popular NoSQL database with options for local and could based data storage facilities. It stores data as documents with JSON schema. DevExpress does not provide out of the box integration with MongoDB. However, we can build a connection layer to connect to MongoDB. This is feasible due to one of the data source option called object data source provided by DevExpress.

Object data source can be any .NET library which can supply data to reports. When we setup data source, the wizard will display all the libraries available in the project and we need to specify the .NET library which can be used a data source. This will display all the public types and functions available in the selected library. Then we need to specify which exact type or function in the library will be used a data source along with any parameters the function receives.

This very feature can be utilized to connect MongoDB with DevExpress. We can create a .NET core library which will use the connection settings to establish the connection using standard MongoDB driver available for .NET and retrieve data .The library can expose functions which can be invoked to pull data from MongoDB and feed the same to reports. There will be options to parameterize data source. Once the data source is set up, all the data will be available for report creation. At design time, all the columns in the schema will be available and the same can be used to arrange the data fields in the report layout as per requirements. DevExpress provides various controls like labels, picture box and also various graphs like bar chart and area chart which can use the supplied data .When we generate reports, actual data will be pulled from the database and displayed to the user. Also there will be options to manipulate data using arithmetic and logical expressions and to format the data display.

The reports can be rendered directly in razor pages by inserting DevExpress report control or it can also be rendered by invoking report URL from DevExpress component in any Angular page.


Issues/Challenges

  • DevExpress only supports dependency injection partially currently, so dependency injection cannot be used in the data generation method.
  • The data generation method only supports simple type parameters like number and strings, so the custom types cannot be used in data generation method.
  • Embedded fonts are not supported in Linux environments.
  • Additional settings are required to run the reports in distributed environments.