Beispiel #1
0
 private IPredicate FilterByPatientId(DoctorToPatientFilterDto filter)
 {
     if (filter.PatientId == Guid.Empty)
     {
         return(null);
     }
     return(new SimplePredicate(nameof(DoctorToPatient.PatientId), ValueComparingOperator.Equal, filter.PatientId));
 }
Beispiel #2
0
        protected override IQuery <DoctorToPatient> ApplyWhereClause(IQuery <DoctorToPatient> query, DoctorToPatientFilterDto filter)
        {
            var definedPredicates = new List <IPredicate>();

            AddIfDefined(FilterByDoctorId(filter), definedPredicates);
            AddIfDefined(FilterByPatientId(filter), definedPredicates);
            if (definedPredicates.Count == 0)
            {
                return(query);
            }
            if (definedPredicates.Count == 1)
            {
                return(query.Where(definedPredicates.First()));
            }
            var wherePredicate = new CompositePredicate(definedPredicates);

            return(query.Where(wherePredicate));
        }