I have a table DriverScans that joins DriverImages. I want to return all DriverScans where any DriverImage has it's Sent field equal to false.
Essentially
SELECT DriverScan.*
FROM DriverScan
INNER JOIN DriverImages
ON DriverImages.DriverScanId = DriverScan.DriverScanId
WHERE DriverImages.Sent = 0
The code below only DriverScans but the SQL query created pulls back an Inner Join of DriverScan and DriverImages, which includes an image field. How do I write the code so SQL only returns DriverScan info?
public IEnumerable<DriverScan> GetNewScans()
{
var session = GetCleanSession();
var query = session.CreateCriteria(typeof(DriverScan));
query.CreateCriteria("DriverImages", JoinType.InnerJoin)
.Add(Cr.Restrictions.Eq("Sent", false));
return query.List<DriverScan>();
}
If relevant my mapping for DriverImages is
HasMany<DriverDoc>(x => x.DriverDocs)
.WithKeyColumn("DriverScanId").IsInverse()
.Cascade.AllDeleteOrphan().LazyLoad();