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

Convert from IQueryable(Of OpenAccessEntity) to IQueryable(Of InheritedEntity)

1 Answer 68 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Erik
Top achievements
Rank 2
Erik asked on 13 Mar 2011, 04:16 PM

Hello,

Making my own model based on Telerik OpenAccess, i ran into a little converion problem. 

In OpenAccess the model has a Application_authorization_user_Entity Class. In my model i have a class that inherits from him and is called User.

Ofcource when using the Telerik Context GetAll function it retrieves a  IQueryable(Of Application_authorization_user_Entity) object. 

I would like to convert that to:  IQueryable(Of User)

I thougt of doing that with the IQueryable.Cast function,  but then i get that the conversion failed (could not cast)

Any ideas on that? 

Partial Public Class User
    Inherits Application_authorization_user_Entity
 
End Class
Public ReadOnly Property Users() As IQueryable(Of User)
    Get
        Dim u As IQueryable(Of UserEntity)
        u = mobj_OAContext.GetAll(Of Application_authorization_user_Entity)()
        Dim x As IQueryable(Of User)
        x = u.Cast(Of User)()
 
        Return x
    End Get
End Property

Regards,

Erik


1 Answer, 1 is accepted

Sort by
0
Serge
Telerik team
answered on 17 Mar 2011, 10:15 AM
Hello Proovit,

 First of all I would like to apologize for the late reply, we have been really busy preparing the Q1 release. While this is no excuse, please rest assured that you will get your tickets replied to in a timely manner from now on. 

The problem you experience is easily described, the IQueryable is you get from OpenAccess is actually translated using the OpenAccess query parser and then sent to the server. The cast statement cannot be translated by us so this is why you get an exception. 

If you were to add a simple .ToList() call just prior to the Cast you should be able work around this issue. 

I hope this is helpful, however if that is not your case please let us know.

All the best,
Serge
the Telerik team
Tags
General Discussions
Asked by
Erik
Top achievements
Rank 2
Answers by
Serge
Telerik team
Share this question
or