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

server side currently not implemented

1 Answer 396 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
luke johnson
Top achievements
Rank 1
luke johnson asked on 14 Dec 2010, 04:13 PM
I am running OpenAccess Q3 2010 and am running into this error.  I had it working with SQL to Linq and then with Entity Framework.  Is there a work around for something like this with OpenAccess?

using (CollectionsContext db = new CollectionsContext())
            {
                IQueryable<LossSaver> query = db.LossSavers;
                if (reportDate.Equals(DateTime.MinValue))
                {
                    query = query.Where(q => q.Status == theStatus)
                        .OrderBy(q => q.MemberNumber);
                }
                else
                {
                    query = query.Where(q => q.Status == theStatus)
                         .Where(q => q.ReportDate.Value.Month == reportDate.Month)
                         .Where(q => q.ReportDate.Value.Year == reportDate.Year)
                         .OrderBy(q => q.MemberNumber);
                }
                return query.Select(q => Mapper.ToBusinessObject(q)).ToList();
            }

This is the code.  It is running the code underneath the if part of the statement.

This is the error:
An exception occured during the execution of '
Extent<DataObjects.LossSaver>.Where(q => (q.Status = value(DataObjects.LossSaverDao+<>c__DisplayClass0).theStatus)).OrderBy(q => q.MemberNumber).Select(q => ToBusinessObject(q))'. See InnerException for more details.
An exception occured during the execution of '
Extent<DataObjects.LossSaver>.Where(q => (q.Status = value(DataObjects.LossSaverDao+<>c__DisplayClass0).theStatus)).OrderBy(q => q.MemberNumber).Select(q => ToBusinessObject(q))'. See InnerException for more details.

An exception occured during the execution of '
Extent<DataObjects.LossSaver>.Where(q => (q.Status = value(DataObjects.LossSaverDao+<>c__DisplayClass0).theStatus)).OrderBy(q => q.MemberNumber).Select(q => ToBusinessObject(q))'. See InnerException for more details.
An exception occured during the execution of '
Extent<DataObjects.LossSaver>.Where(q => (q.Status = value(DataObjects.LossSaverDao+<>c__DisplayClass0).theStatus)).OrderBy(q => q.MemberNumber).Select(q => ToBusinessObject(q))'. See InnerException for more details.
Here is the inner exception:  
"Execution of 'DataObjects.EntityMapper.Mapper:ToBusinessObject(LossSaver)' on the database server side currently not implemented."

The method ToBusinessObject accepts a CollectionsContext.LossSavers.LossSaver object and creates a data model class, just a conversion method.  Maybe I just need to think about the error and understand what it is saying but I wanted to get this out here in case someone can point out what is happening.

1 Answer, 1 is accepted

Sort by
0
Petko_I
Telerik team
answered on 16 Dec 2010, 07:18 PM
Hi luke johnson,

As the exception message correctly states we still do not support projections of custom objects in our LINQ implementation. However, we support projections of anonymous types. There is an alternative which you can use for your query. The solution for you here should be to call the ToList() method of the query before executing the final select where you assemble your custom objects. In other words you can write the following code:
return query.ToList().Select(q => Mapper.ToBusinessObject(q));
This way, you will retrieve the persistent objects in memory and subsequent projections will work with them without troubles. We hope the information provided will help you resolve your issue.

Contact us back, should you encounter further difficulties.

All the best,
Petko_I
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
Tags
LINQ (LINQ specific questions)
Asked by
luke johnson
Top achievements
Rank 1
Answers by
Petko_I
Telerik team
Share this question
or