Please, consider following queries:
Code: Select all
int? idUser = null;
DB.Configurations.First(c => c.Config_key.Equals("ABC") && c.Id_user == idUser);
DB.Configurations.First(c => c.Config_key.Equals("ABC") && c.Id_user == idUser);
idUser = 1;
DB.Configurations.First(c => c.Config_key.Equals("ABC") && c.Id_user == idUser);
idUser = null;
DB.Configurations.First(c => c.Config_key.Equals("ABC") && c.Id_user == idUser);
Here is their SQL translation:
Code: Select all
SELECT ... FROM "main".configuration t1
WHERE (t1.Config_key = :p0) AND (t1.Id_user IS NULL) LIMIT 1
-- p0: Input Text (Size = 18; DbType = String) [ABC]
SELECT ... FROM "main".configuration t1
WHERE (t1.Config_key = :p0) AND (t1.Id_user IS NULL) LIMIT 1
-- p0: Input Text (Size = 18; DbType = String) [ABC]
SELECT ... FROM "main".configuration t1
WHERE (t1.Config_key = :p0) AND (t1.Id_user = :p1) LIMIT 1
-- p0: Input Text (Size = 18; DbType = String) [ABC]
-- p1: Input Int32 (Size = 0; DbType = Int32) [6]
SELECT ... FROM "main".configuration t1
WHERE (t1.Config_key = :p0) AND (t1.Id_user = :p1) LIMIT 1
-- p0: Input Text (Size = 18; DbType = String) [ABC]
-- p1: Input Int32 (Size = 0; DbType = Int32) []
All queries are the same. But the third one has non-null value in second parameter. After executing this query the second parameter persists in next queries regardless of a value of this parameter. Therefore the result of the fourth query is wrong (different from first and second queries).
This behavior is same with SQLite and MySql provider. There was no such a bug in previous versions of LinqConnect (3.x).