System.Data.SQLite
View Ticket
Not logged in
Ticket UUID: a4d9c7ee94e10b5b16252e30d11bf005a56cfe4d
Title: "Contains" function returns no records if column type is Guid
Status: Closed Type: Code_Defect
Severity: Important Priority: Medium
Subsystem: LINQ Resolution: Fixed
Last Modified: 2015-07-22 18:39:43
Version Found In: 1.0.96.0.
User Comments:
anonymous added on 2015-03-23 14:51:18:
I have table with column "Guid" of type guid.

Following code returns no record:
Guid g = new Guid("60C00100-3F07-4ADD-A3C6-0CA138CD7CA7");
Guid[] guidArray = new Guid[1]{g};
PDETag result = DBContext.PDETags.Where(x => guidArray.Contains(x.Guid)).FirstOrDefault();

This code returns right record:
PDETag result2 = DBContext.PDETags.Where(x => x.Guid == g).FirstOrDefault();

mistachkin added on 2015-03-23 17:44:51:
Have you tried using the BinaryGUID connection string property?

anonymous added on 2015-03-24 10:05:05:
I am using BinaryGUID=True. With BinaryGUID=False it works. But only with new database. It is not compatible with my existing databases.

mistachkin added on 2015-03-24 22:11:12:
Well, that setting impacts how the GUIDs are treated by the conversion routines.
It appears things are working as designed.

anonymous added on 2015-03-26 07:58:52:
Unfortunately, I can't change existing databases. Is there some way to make "Contains" function working with BinaryGUID=True?

mistachkin added on 2015-03-26 18:30:36:
I'll look into it.

mistachkin added on 2015-03-26 20:04:06:
Further research reveals that the BinaryGUID setting is working as designed in
this context.

Are you unable to change this connection string property for some other reason?

mistachkin added on 2015-03-26 21:42:03:
On second thought, this does seem like an issue with the LINQ assembly not fully
honoring the BinaryGUID setting.  I'm working on a fix.

mistachkin added on 2015-03-26 21:56:25:
This should be fixed on trunk, via check-in [87b4244129].  Please let us know if
this fix works for you.

anonymous added on 2015-03-27 15:31:42:
Thank you. 

The other reason for binary guid is performance. I have all primary keys as guid and "string guids" makes it slower. Also file size increase is complication.

anonymous added on 2015-04-20 14:29:50:
I tested check-in [87b4244129]. But it is not working for me. I also found out, that I am not able to simple search record by guid. Following code is not workig now:
PDETag result2 = DBContext.PDETags.Where(x => x.Guid == g).FirstOrDefault();
With version 1.0.96.0 is it working fine.

I tested your function "BinaryGuidTest2". I saw, that you sets BinaryGuid with following code:
Environment.SetEnvironmentVariable("AppendManifestToken_SQLiteProviderManifest", String.Format(";BinaryGUID={0};", binaryGuid));
I am using only connection string: "... BinaryGUID=True; ..."
I thing, you sets also SQLiteProviderManifest._binaryGuid and I only SQLiteConnection._binaryGuid. What is the right way to set BinaryGuid? 
In my case is SQLiteProviderManifest._binaryGuid = false and SQLiteConnection._binaryGuid = true. This can be reason of problems.

I tested my application with "Environment.SetEnvironmentVariable("AppendManifestToken_SQLiteProviderManifest", String.Format(";BinaryGUID={0};", binaryGuid));" and it is working fine.

mistachkin added on 2015-04-21 15:19:22:
The new environment variable is used to influence the provider manifest token.
This is not exactly the same as the connection string, even though it is now
parsed similarly.  It's important to set the property for the LINQ provider
itself, because that is what controls the GUID handling in this case.

anonymous added on 2015-07-22 11:49:34:
what if I have to open 2 or more connections at the same time from the very same thread with different binaryguid settings?

mistachkin added on 2015-07-22 18:39:43:
If you change the ProviderManifestToken in the EDMX file appropriately, it should
also work.