1

This code is just a random example:

var query = _context.Subscriptions
    .Where(s =>
        s.Archived == false &&
        s.Deleted == false &&
        s.FeatureFlag.Archived == false &&
        s.FeatureFlag.Deleted == false &&
        (s.Subscriber.ToUpper() == memberUrl ||
            s.Subscriber.ToUpper() == tenant ||
            userRegions.Contains(s.Subscriber.ToUpper())))
    .Select(s => /* ... */);

I'd like to refactor this to make the code more readable (and DRYer), by adding some extension methods to my Models; something like:

var query = _context.Subscriptions
    .Where(subscription =>
        subscription.IsActive() && 
        subscription.ApplysToAnyOf(memberUrl, tenant, userRegions))
    .Select(s =>  /* ... */);

but since this is LINQ to Entities, it doesn't know how to parse my refactoring, and I'm not fluent enough with LINQ to understand the right way to do it.

Scott Baker
  • 10,013
  • 17
  • 56
  • 102

0 Answers0