c# - System.Data.Sqlite 1.0.99 guid comparison doesn't work -


i using system.data.sqlite 1.0.99 c#, can call db ef. faced problem when selecting firstordefault guid return null (but row such guid exists in database):

var user = context.users.firstordefault(x => x.id == userid); //returns null //or var user = context.users.where(x => x.id == userid).toarray(); //returns empty array 

found information known issue , fixed in 1.0.95, broken again in 1.0.97 , next 2 solutions:

solution 1: set binaryguid property on connection string true:

data source=...;binaryguid=true; 

solution 2: set next environment variable (before make connection):

   environment.setenvironmentvariable("appendmanifesttoken_sqliteprovidermanifest", ";binaryguid=true;"); 

solution 2 works, because (from sqlite site):

appendmanifesttoken_sqliteprovidermanifest - if environment variable set [to anything], used system.data.sqlite.linq.sqliteprovidermanifest class (and system.data.sqlite.ef6.sqliteprovidermanifest class) modify future provider manifest tokens appending value of environment variable existing provider manifest token, if any. typically, in order constructed provider manifest token syntactically correct, environment variable value [to appended] must begin semicolon.

solution 1 doesn't work me because, understand, has effect on system.data.sqlite.linq.sqliteprovidermanifest.

the question: there solution fix behaviour not setting environment variable?

would try use singleordefault instead of firstordefault? linq: when use singleordefault vs. firstordefault() filtering criteria

example: var user = context.users.singleordefault(x => x.id == userid);


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -