Skip to content

Instantly share code, notes, and snippets.

@kemsky
Created July 4, 2023 15:59
Show Gist options
  • Save kemsky/0e5ed603e9812b165130da57daed8026 to your computer and use it in GitHub Desktop.
Save kemsky/0e5ed603e9812b165130da57daed8026 to your computer and use it in GitHub Desktop.
[Medium] nested specifications problem
public sealed class ActiveDepartmentSpecification : LinqSpecification<Department>
{
public override Expression<Func<Department, bool>> AsExpression() => x => x.Active;
}
public sealed class UserWithActiveDepartmentSpecification : LinqSpecification<User>
{
// see, we can't reuse ActiveDepartmentSpecification here:
public override Expression<Func<User, bool>> AsExpression() => x => x.Departments.Any(z => z.Active);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment