EntityFramework datasource with Linq

8 posts, 0 answers
  1. Darren
    Darren avatar
    10 posts
    Member since:
    Oct 2010

    Posted 02 Apr 2014 Link to this post

    I have a EF 6 datasource configured and working but I'm finding it very limited.  There seems to be no way to query the datasource using Linq from the designer.  I was expecting it to work like the SQL datasource where a query can be specified and then embedded in the report.
  2. Stef
    Admin
    Stef avatar
    3047 posts

    Posted 07 Apr 2014 Link to this post

    Hi Darren,

    The EntityDataSource component connects to the underlying data model, and gives you access to all its collections, their relations and additionally declared methods, where you can add custom queries and logic for data retrieving.

    The SqlDataSource performs the same task - connects to data, but to make use of the relations between database objects you need to declaratively type queries (equivalent to custom methods for data retrieval written in SQL).

    Please elaborate on the feature your are looking for and we will discuss it with our development team.

    Regards,
    Stef
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
  4. Darren
    Darren avatar
    10 posts
    Member since:
    Oct 2010

    Posted 07 Apr 2014 in reply to Stef Link to this post

    I don't want to change the DbContext every time my reporting needs change.   From what I have read, when using the EntityDataSource there is no way to use parameters other than to pass the parameter to a method.  In other words, is there any way to filter one of the IQueryable sources of the DbContext using report parameters without having to create a new method in the context?

    Using a SQL source,  if I need to project the data differently, the only thing that changes is the query defined in the report. I don't need to add a new view or stored procedure.
  5. Nasko
    Admin
    Nasko avatar
    909 posts

    Posted 10 Apr 2014 Link to this post

    Hello Darren,

    Yes, you need to pass the parameter to a method in the ObjectContext/DbContext class and this is the only way to filter on the database level.
    You can define a variety of such methods according to the data that needs to be retrieved or just a single method which can return the different data based on the passed arguments. Then you can map the EntityDataSource component parameters to report parameters and if you need the data differently you would need to change only the report parameters. Please check the Retrieving data from an Entity Data Model with the EntityDataSource component help article which outlines the approach, but note that you can build on top of that to achieve more complicated data retrieval scenarios.

    Regards,
    Nasko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Darren
    Darren avatar
    10 posts
    Member since:
    Oct 2010

    Posted 10 Apr 2014 in reply to Nasko Link to this post

    Thanks for the reply.  Modifying the data context every time I need to change parameters is not a viable solution.  Are the report designer data sources extensible?
  7. Nasko
    Admin
    Nasko avatar
    909 posts

    Posted 15 Apr 2014 Link to this post

    Hello Darren,

    You don't have to modify the data context every single time you need to change parameters. It is required to make modifications only when you add a new method in the ObjectContext or DbContext class.
    Perhaps it would be best if you could open a separate support ticket where you can zip and attach a sample project demonstrating your scenario and some description on what exactly you are trying to achieve. Then we would be able to give further suggestions.
    Also please elaborate further on extending the report designer data sources. Currently, it is possible to use these data source components in Telerik Reporting: Data Source Components.

    Regards,
    Nasko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  8. Darren
    Darren avatar
    10 posts
    Member since:
    Oct 2010

    Posted 15 Apr 2014 in reply to Nasko Link to this post

    By changing parameters, I didn't mean changing the parameter value, I meant changing the types and number of parameters.  I require the ability to put the filtering logic and data projection inside the report. 

    When using the SQL datasource wizard there is a dialog that lets you create a query, that step is missing for the Entity Framework data source.  I made the assumption that the EF datasources could be queried from the report.  It appears that it is not currently possible.


  9. Nasko
    Admin
    Nasko avatar
    909 posts

    Posted 16 Apr 2014 Link to this post

    Hello Darren,

    Language-Integrated Query (LINQ) is a set of features that extends with query capabilities the language syntax of C# and Visual Basic. Thus LINQ is part of the C# and Visual Basic programing languages. Having in mind that LINQ is a subset of compile languages results in the requirement to compile the LINQ instructions. However you can’t just compile any string input. There are multiple implications in parsing and compiling programing language code that are simply out of the reporting engine scope. So we can’t engage with task to include LINQ interpretation abilities to our EntityDataSource component/wizard.

    Generally LINQ seems similar to SQL but this is only on the surface because SQL is interpreted by the SQL server and the reporting engine don’t make any part of the SQL interpretation.

    The recommended approach to extend the model to serve the needs of the report is discussed here.

    Regards,
    Nasko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
DevCraft banner