Query with Lambda's/Projection

Posts   
 
    
notrosh
User
Posts: 1
Joined: 25-Oct-2010
# Posted on: 25-Oct-2010 21:56:20   

Hi Everyone,

I have a situation where depending on the parameter I would like to pass a different delegate to my query method. However, I am keep getting a weird error. I think I am doing something wrong.

Please see code below.


        internal  static IEnumerable<ReportParameter> LoadTimelyBillingsParameter(Func<RptTimelyBillingsEntity, string>  displayParameter, Func<RptTimelyBillingsEntity, int> valueParameter)
        {
            var metaData = new LinqMetaData();
            var query =(ILLBLGenProQuery)(metaData.RptTimelyBillings).Select(entity => new ReportParameter(valueParameter(entity), displayParameter(entity)));
            var collection = query.Execute<IEnumerable<ReportParameter>>();
            return collection;
        }

I keep getting the following error which bubbles up from the Execute method.

Unable to cast object of type 'System.String' to type 'EntityClasses.RptTimelyBillingsEntity'.

Any help would be greatly appreciated.

Thanks,

-zd

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-Oct-2010 06:31:37   

Please try to isolate the source of the error, simplifying your query.

Also, post the exact error messsage and stack trace. And don't forget, use the latest build.

David Elizondo | LLBLGen Support Team