Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda

c# dynamic dynamic-linq linq

Question

I'm Using Dynamic Linq library and there is Source code and basic docu and the Nuget version

PM> Install-Package DynamicLINQ

I'm trying to construct a where clause that involves Guids

I have tried with the string "Id == @0". The parameter array is just an object[] with the value (Guid xxxx)

  var whereClauseSB = BuildLogicalKeyWhereClause2(entity, logicalKey);  //build string
  var parms = BuildParamArray(entity, logicalKey); // object[]
  var whereLambda = Ofsi.Bos.Core.DynamicExpression.ParseLambda<T, bool>(whereClauseSB.ToString(),parms);  //parse

an exception is thrown in DynamicExpression.ParseLambda

Operator '==' incompatible with operand types 'Guid' and 'Guid'

  • I have also tried with GUID and String.(fail)
  • I tried with and "Id = @0" (fail).
  • String == string works, as does Int32==int32 but not Guid == Guid does not

Any ideas?

1
5
5/9/2013 4:44:09 PM

Accepted Answer

Try using the Equals method instead of the == operator in your string:

"Id.Equals(@0)"
6
5/9/2013 4:37:50 PM


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