Entity, problem with entity key

T

ThatsIT.net.au

The query below does not work, if I take out line 2 it works and gives me
the full table, but when I try to select only those with a coutryId of 1 it
gives this error

LINQ to Entities does not recognize the method 'System.Object
CompareObjectEqual(System.Object, System.Object, Boolean)' method, and this
method cannot be translated into a store expression.

My experience tell me this is a problem with passing the wrong datatype, but
CountryId is an integer and even if I change it to a number 1 it still give
the same error.

any ideas?


Dim Q As ObjectQuery(Of emState) = CType((From c In em.emStateSet _
Where
c.CountryReference.EntityKey.EntityKeyValues.First.Value = CountryId
Select c),
ObjectQuery(Of emState))
 
T

ThatsIT.net.au

silly me

I dug up my lats effort in linq to entities and what i should of had was

Using em As ThatsBookingEntities = New ThatsBookingEntities
Dim Q As ObjectQuery(Of emState) = CType((From c In
em.emStateSet _
Where
c.Country.CountryId = CountryId _
Select c),
ObjectQuery(Of emState))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top