System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
Ticket Hash: 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: (text/x-fossil-plain)
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: (text/x-fossil-plain)
Have you tried using the BinaryGUID connection string property?

anonymous added on 2015-03-24 10:05:05: (text/x-fossil-plain)
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: (text/x-fossil-plain)
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: (text/x-fossil-plain)
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: (text/x-fossil-plain)
I'll look into it.

mistachkin added on 2015-03-26 20:04:06: (text/x-fossil-plain)
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: (text/x-fossil-plain)
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: (text/x-fossil-plain)
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: (text/x-fossil-plain)
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: (text/x-fossil-plain)
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: (text/x-fossil-plain)
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: (text/x-fossil-plain)
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: (text/x-fossil-plain)
If you change the ProviderManifestToken in the EDMX file appropriately, it should
also work.