Hello Community,
I am trying to evaluate max date (latest date) condition and for that I think I could use MAX() function.
From syntax perspective I am not able to find correct way. Here below is my query.
var sfcStatusQuery = (from Carrier in _orgContext.CreateQuery("account")
join SafetyFitnessCert in _orgContext.CreateQuery("mot_safetyfitnesscertificate")
on Carrier["accountid"] equals SafetyFitnessCert["mot_carriernumber"]
where (SafetyFitnessCert["mot_expirydate"] == null && (int)SafetyFitnessCert["statecode"] == 0)
where SafetyFitnessCert.FormattedValues["new_sfcstatusname"].ToString().Equals("Suspended")
where ((int)Carrier["statecode"] == 0 && Carrier["mot_number"].Equals(carrierNumber))
//where SafetyFitnessCert["mot_lastreviseddate"]
select new
{
SafetyCertSuspFlag = "Y"
}).FirstOrDefault();
In above query the commented where condition which I try to correct by using aggregate function MAX. As this query may/may not contain more than one record with "Suspended" status for a particular carrier number.
Please advise.
*This post is locked for comments
I have the same question (0)