Entity, problem with entity key

Discussion in 'ASP .Net' started by ThatsIT.net.au, Sep 6, 2009.

  1. 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))
    ThatsIT.net.au, Sep 6, 2009
    #1
    1. Advertising

  2. 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))



    "ThatsIT.net.au" <me@work> wrote in message
    news:D...
    > 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))
    ThatsIT.net.au, Sep 7, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gk
    Replies:
    1
    Views:
    371
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Aug 11, 2006
  2. Samuel van Laere

    Entity Name or Entity Number?

    Samuel van Laere, Feb 24, 2007, in forum: HTML
    Replies:
    4
    Views:
    1,630
    Jukka K. Korpela
    Feb 24, 2007
  3. markla
    Replies:
    1
    Views:
    545
    Steven Cheng
    Oct 6, 2008
  4. Norm
    Replies:
    3
    Views:
    2,711
  5. M P
    Replies:
    1
    Views:
    466
Loading...

Share This Page