-1
readonly IDbSet<Company> _Companies;

_Companies = _uow.Set<Company>();

public IList<Company> GetAllByGroupNames(IList<CompanyGroupMappings> CompanyGroupMappings)
{
    return _Companies.Where(o => companyGroupMappings.Select(p => p.GroupName).Contains(o.GroupName)).ToList();
}

This returns an error:

Unable to create a constant value of type 'CompanyGroupMappings'. Only primitive types or enumeration types are supported in this context. {System.Collections.ListDictionaryInternal}

How do I have to change it? Is it regarding the first list not being in the memory?

Vikrant
  • 4,920
  • 17
  • 48
  • 72
Efron A.
  • 353
  • 3
  • 10
  • 19
  • Duplicate with lots of upvotes - please do try to search for an answer before opening a new question. – Clint Jun 09 '17 at 00:41

1 Answers1

0

Try the code as below:

return _Companies.Where(o => CompanyGroupMappings.Any(p => p.GroupName == o.GroupName)).ToList();

Make sure to pass a List<CompanyGroupMappings> rather than IList<CompanyGroupMappings>

Rey
  • 3,663
  • 3
  • 32
  • 55