String parameters in predicate

var code = sqlXrm.Scalar<MetadataEntity, int>(e => e.ObjectTypeCode, e => e.LogicalName == "inno_subject");
var code2 = sqlXrm.Scalar<MetadataEntity, int>(e => e.ObjectTypeCode, e => e.LogicalName.Equals("inno_subject"));

“code” matches but “code2” does not.

The debug output is…

DEBUG: SQL: SELECT "ObjectTypeCode"
FROM "MetadataSchema"."Entity"
WHERE ("LogicalName" = @0)
PARAMS: @0=inno_subject
DEBUG: SQL: SELECT "ObjectTypeCode"
FROM "MetadataSchema"."Entity"
WHERE "LogicalName"=@0
PARAMS: @0=inno^_subject

When using .Equals it’s inserting the ^ before the underscore which is causing the WHERE clause not to match.

I realise I could just use == but I’ve used .Equals in a bunch of places already.

Any ideas?

Support for .Equals() was recently added, can you try with the latest v5.4.1 on MyGet?

I’m already using 5.4.1.

Should now be resolved from this commit. This change is available from v5.4.1 that’s now on MyGet as you’ve already have v5.4.1 installed you’ll need to clear your NuGet packages cache to download the latest release.

Yep thats working now thanks.

Excellent response as always. I hope they pay you well :smile:

1 Like