I scratch my head, trying to understand why petapoco "Exists ()" returns false, where it should return true. I use something like this to check:
Simple petapoco model:
[TableName("WorkLog")]
[PrimaryKey("Id")]
public class WorkLog : DefaultConnectionDB.Record<WorkLog>
{
public int Id { get; set; }
public Guid? Customer { get; set; }
public Guid? Project { get; set; }
}
A database table with the same structure as above, filled with identifiers and clients (only for the project).
Create a test object:
var x = new WorkLog {Id = 0, Customer = 'xxx-xxx-xxx...', Project = null}
The query if a DB based on "Project" exists in the DB:
var exist = db.Exists<WorkLog>("Project=@p", new { p = x.Project });
In this case, the result is false. If I populate the model, db and query using Guid for Project, it will return “true” as it should.
, , NULL DbNull, . "null" "DbNull" , false.
:
...
var exist = db.Exists<WorkLog>(x.Project == null ? "Project IS NULL" : "Project=@p", new { p = x.Project });
, , , .