static async Task <Person> GetPerson(int id) { using (var context = new PeopleContext()) { var personNotDeletedSpecification = new PersonNotDeletedSpecification(); return(await context.People .Where(personNotDeletedSpecification.ToExpression()) .FirstOrDefaultAsync(x => x.Id == id)); } }
static async Task <Person[]> GetPeople(string filter, ushort age) { using (var context = new PeopleContext()) { var personNotDeletedSpecification = new PersonNotDeletedSpecification(); var personOlderThanSpecification = new PersonOlderThanSpecification(age); var personFilterSpecification = new PersonFilterSpecification(filter); var peopleSpecification = personNotDeletedSpecification .And(personOlderThanSpecification.Or(personFilterSpecification)); return(await context.People .Where(peopleSpecification.ToExpression()) .ToArrayAsync()); } }