Ontani Posted August 28, 2009 Posted August 28, 2009 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. Quote www.purevision.be :: www.devpoint.be
Administrators PlausiblyDamp Posted August 28, 2009 Administrators Posted August 28, 2009 Does it indicate which part of the expression is causing the error? Which of the properties included in the expression are integers or strings? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Ontani Posted August 28, 2009 Author Posted August 28, 2009 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. Quote www.purevision.be :: www.devpoint.be
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.