Replies: 2 comments 6 replies
-
Never use concatenated string in sqlite query like var command = new SqliteCommand($"Select * from Client where Id='{clientId.ToString()}'"); Instead use parameterized query, like var command = new SqliteCommand($"Select * from Client where Id=@clientId");
var clientIdParam = new SqliteParameter("@clientId");
clientIdParam.DbType = DbType.Guid;
clientIdParam.Value = clientId;
command.Parameters.Add(clientIdParam); By the way, Guid in Sqlite are stored as blob but they are basically strings, so you can do something like: select * from Customer where rowguid = '3F5AE95E-B87D-4AED-95B4-C3797AFCB74F' |
Beta Was this translation helpful? Give feedback.
-
Hello, Based on what has been explained I have an issue with the Linq, where the companyID is type Guid and in its comparison with the SQLite BLOB it does not find the record. My code
companyEntity is null f.CompanyId = BLOB //Model But if I change my model from Guid to String and the companyId to string it works correctly //Model |
Beta Was this translation helpful? Give feedback.
-
Hi All,
Some good practice to work the GUIDs in the SQLite as Blob since they must be handled as TEXT in the SQLite queries
I appreciate your comments
Beta Was this translation helpful? Give feedback.
All reactions