This is a migrated thread and some comments may be shown as answers.

EF 4.1 DataSource Can't find Method

1 Answer 168 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 01 Nov 2011, 04:43 PM

Hello,

I am currently evaluating your reporting product...  I am attempting to connect to an EF 4.1 Object Context...  I created a partial class with a new method that returns a list of a customized class for the report like so:


namespace Telerik.Reporting.Examples.CSharp
{
    public partial class WOCatalogEntities1
    {
        
        public List<ReportData> GetWorkOrdersForReport()
        {
            
            this.ContextOptions.LazyLoadingEnabled = true;
            var list = this.WorkOrderHeaders.Where(e => e.WOStatusType.is_open_status).Select(e => new ReportData
            {
                WONumber = e.wo_no,
                LastEdited = e.server_updt,
                Status = e.WOStatusType.status_desc,
                Task = e.task,
                Tech = e.WOPersonnel.lname,
                VendorNumber = e.pp_vendorcode,
                WOType = e.WOTaskType.TaskType,
                WOUnit = e.WORentalUnit.unit
            });
 
            return list.Take(50).ToList();;
            
        }
 
 
    }
 
    public class ReportData
    {
 
        public int WONumber { getset; }
        public string WOUnit { getset; }
        public string Tech { getset; }
        public string Status { getset; }
        public string VendorNumber { getset; }
        public string Task { getset; }
        public string WOType { getset; }
        public DateTime? LastEdited { getset; }
 
    }
 
 
}


the partial class is in the same assembly AND the same namespace as the Entity Model of the same name...  but I get the error that telerik cannot find the method ???



Telerik.Reporting.Processing.Data.ObjectDataSourceException: Method GetWorkOrdersForReport() not found.
   at Telerik.Reporting.Processing.Data.ObjectQueryProvider.GetSelectMethod(Type type, String name, IDictionary`2 parameters)
   at Telerik.Reporting.Processing.Data.ObjectQueryProvider.ResolveDataSourcePropertiesFromType()
   at Telerik.Reporting.Processing.Data.ObjectQueryProvider.ResolveDataSourceProperties()
   at Telerik.Reporting.Processing.Data.ObjectSchema.FillSchema(ObjectQueryProvider queryProvider)
   at Telerik.Reporting.Processing.Data.ObjectSchema..ctor(ObjectQueryProvider queryProvider)
   at Telerik.Reporting.Processing.Data.ObjectQueryProvider.CreateSchema()
   at Telerik.Reporting.Processing.Data.MultidimensionalQueryProvider.GetSchema()
   at Telerik.Reporting.Design.DataSourceService.GetCurrentDataSourceSchema(Boolean throwOnError)
   at Telerik.Reporting.Design.DataExplorerControl.RefreshDataSource()



Thanks
Greg


1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 04 Nov 2011, 10:44 AM
Hi Greg,

Do you use EntityDataSource component? The EntityDataSource component, enables data items to connect to an ADO.NET Entity Data Model

Currently when EntityDataSource component is used the EF Model should be located in a separate class library in order for the report designer and the report wizards to work properly. Additionally you will have to copy the connection string to the web.config/app.config file of the report class library, so that Entity Framework can find your database at design-time. 

We are resolving the types at design-time using ITypeDiscoveryService and ITypeResolutionService. These are standard services from the design-time support of Visual Studio, however they seem to leak compiled assemblies and in some cases cannot resolve the correct type. Actually there is a bug in Connect related to this problem, but to our greatest regret it is postponed by Microsoft. You can read more regarding this by visiting the following link: ITypeDiscoveryService - leaks compiled assemblies.

Thus when adding new classes/types in order to use the new types you may have to restart Visual Studio

Still we do plan to investigate the issue further and to introduce fix to avoid the ITypeDiscoveryService leak. 

We have attached a sample project to illustrate the suggested approach. To run the sample project you will need the AdventureWorks database that comes with Telerik Reporting installation.

Best wishes,
Peter
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

Tags
General Discussions
Asked by
Greg
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or