I am trying to use this method to return a boolean value based on whether or not the custody already exists in the database.
var custody = db.Custodies.LastOrDefault(c => c.studentId == id);
if (db.Custodies.Contains(custody) && custody.custodyEndTime == null)
{
return true;
}
return false;
}
The Custodies table uses a composite primary key but I only want to search by studentId, so I can't use Find(). I want to find the custody entry based on the studentId to check if that student is currently in a custody with no custodyEndTime.
I tried using a linq query but that gave me an anonymous type and it complained about that too.
Any help would be great.
Cheers.