Using special property names in Dynamic LINQ

c# dynamic-linq linq

Question

I'm creating a Dynamic LINQ query in the following manner:

"Guid=Guid(\"" + entityId + "\")"

Eventually, this is transferred to a.Where() somewhere in the code I call, I believe.

This error is occurring for me:

ParseException: '.' or '(' expected

This seems to be the case since it fails to locateGuid not the property, but theGuid function.

How should I inquire about theGuid an attribute of my object?

1
0
12/10/2013 2:37:30 PM

Accepted Answer

Guid is a buzzword, for sure. By prefixing keyword identifiers with, you may escape them.@ .

The appropriate phrase reads as follows:

"@Guid=Guid(\"" + entityId + "\")"
1
12/10/2013 4:39:49 PM

Popular Answer

To summarize Kendall's response, I believe the more elegant strategy is to allow parameterized queries from Dynamic LINQ handle the type conversions.

myIqueryable1.Where("@Guid=@0", entityId)


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow