I have combined RIA Services with Entity Framework using POCO's. It's all worked wonderfully (way better than LINQ to SQL). The problem that I have is with the following segment of code:
[Query]
public IQueryable<MyEntity> GetMyEntities()
{
return from myEntity in ObjectContext.MyEntities
where myEntity.Status != "deleted"
select new MyEntity
{
// Other property assignments...
SuchAndSuchTime = TimeSpan.FromMinutes(project.SuchAndSuchTime ?? 0.0),
// Other property assignments...
};
}
This is an version of my code where the names have been changed to protect the innocent. This compiles find but I get following exception when I run it:
Load operation failed for query 'GetMyEntities'. LINQ to Entities does not recognize the method 'System.TimeSpan FromMinutes(Double)' method, and this method cannot be translated into a store expression.
Why can I not do this, and is there a work around?