I think the title pretty much nails it.
I am using a Char(36) in a MySql table which automatically gets recognized as a GUID when using the Entity Framework.
Inserting the GUID is no problem, but trying to compare it in a WHERE clause is a nightmare.
What I’ve tried:
First of all I’ve tried a WHERE element.GUID == GuidToCompare.
This resulted in LINQ to Entities does not recognize the method 'System.Object CompareObjectEqual(System.Object, System.Object, Boolean)' method, and this method cannot be translated into a store expression.
Then I tried to just convert the value to String, like so:
WHERE element.GUID.ToString() == GuidtoCompare.ToString()
This resulted in this error: LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.
So either way, I just can’t compare them. I am ready to just not use GUIDs if they don’t work out.
I know what was wrong: It was just a stupid error of myself.
The thing with comparing guids was quite correct, this was not the part that gave the error. Actually a later part in the same LINQ query fired the error. It compared
ProviderUserKey (Object)toID (int). TheProviderUserKeyis essentialls an int, I just had to explicitly state it’s type (CType(Object, Integer)in VB.NET or(int)Objectin C#)