Working with RDLC Reports and object data sources

Yesterday I had to build RDLC report to report stuff based on business objects. I builded a data source that would open session to database, fetch objects, build data contracts and pass them to report as IEnumerable data source. Seemed simple enough I started hacking and soon got the data source ready. Next I created new Report in Visual Studio 2010 and clicked Add dataset… Blam, Visual Studio opens me wizard to create connection to database.

After hours of googling I found out that Visual Studio has a long-lived bug in it. If the project is web project where RDLC file is located, then report data sources  are not refreshed always. There is a work around though. Data sources are often refreshed if you open one .aspx file in the project. More of this bug and its work around can be found from

After creating one aspx page to project and opening it I managed to get pass create database connection wizard. At this point next problem appeared. I couldn’t find my method from Available datasets.  My method had simple signature IEnumerable GetData(). After a while thinking and reading MSDN, I realized that the report designer is actually instantiating my class and calling the method to see what types it returns. That would of course fail because SessionFactory wouldn’t exists. To work around that I added try…catch block to the GetData() method and in case of exception returned array with one item. After that and building the project,  data source appeared to report designer.


Täytä tietosi alle tai klikkaa kuvaketta kirjautuaksesi sisään:

Olet kommentoimassa -tilin nimissä. Log Out /  Muuta )


Olet kommentoimassa Facebook -tilin nimissä. Log Out /  Muuta )

Muodostetaan yhteyttä palveluun %s