I had recently been requested to perform a query in Dynamics CRM database using Linq without EntityGeneratedCode aid, that's when I came up with this error: "Invalid 'where' condition. An entity member is invoking an invalid property or method.".
I thougth it was some syntax error I had gotten, however it was not. Take a look at the code at this moment.
Guid id = new Guid("2C2B13B2-E881-E311-93FA-00155D1E6428");
var query = from c in orgContext.CreateQuery("account")
where ((EntityReference)c.Attributes["accountid"]).Id == id
select c;
With some help I found out that it's a frequent error when using linq. It's pretty easy to solve that, I just had to put off the "Attributes" string from the query. So it's like that right now.
Guid id = new Guid("2C2B13B2-E881-E311-93FA-00155D1E6428");
var query = from c in orgContext.CreateQuery("account")
where ((EntityReference)c["accountid"]).Id == id
select c;
I still don't know why it must be this way, but anyway, that's the way I found to fix that.
No comments:
Post a Comment