Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi i'm having some problems using LINQ to Entities

 

Dim obj As New sof_h

obj.sof_l = (From p In StatsContext.sof_l Where l.id = Locations(myMatch.Groups(1).Value) Select l).FirstOrDefault()

or

Dim obj As New sof_h

Dim QLocations = From l In StatsContext.sof_l Select l
obj.sof_l = QLocations.Where(Function(l) l.id = Locations(myMatch.Groups(1).Value)).FirstOrDefault()

 

Both give me the error:

 

LINQ to Entities does not recognize the method 'Int32 get_Item(System.String)' method, and this method cannot be translated into a store expression.

 

I really have no idea how to fix this problem.

Posted

I located the problem, something pretty strange:

 

obj.sof_l = (From p In StatsContext.sof_l Where l.id = Locations(myMatch.Groups(1).Value) Select l).FirstOrDefault()

 

changed to:

dim location as integer = Locations(myMatch.Groups(1).Value)
obj.sof_l = (From p In StatsContext.sof_l Where l.id = location  Select l).FirstOrDefault()

 

That fixed the problem, no idea why this is because:

obj.sof_l = (From p In StatsContext.sof_l Where l.id = Cint(Locations(myMatch.Groups(1).Value)) Select l).FirstOrDefault()

 

Doesn't work either.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...