I'd like to check for the length of the the int[] array. If there is not
public List<Parent_Company> GetParentCompany(params int[] clientIds)
{
IEnumerable<Companie> ccs;
if (clientIds.Length == 0)
ccs = _xciRepository.GetAll<Companie>();
else if (clientIds.Length == 1)
ccs = _xciRepository.Find<Companie>(x => x.CustCompID == clientIds[0]);
else
ccs = _xciRepository.Find<Companie>(x => clientIds.Contains(x.CustCompID));
//-- more codes here
}
I'm getting the following error: "The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities."
And I suspect it's the statement in the else that's causing the problem, the expression inside the Find method i.e.x => clientIds.Contains(x.CustCompID)
Is there a way to fix that? Otherwise, I've used Contains several times in linq.
Thanks for helping.
Containsits with the indexed propertyclientIds[0]..Findinstead of a more generic.Whereor.Single? Why isn't GetParentCompany an extension method ofIQueryable<Companie>?Findis not a linq in this case. Someone before me defined this method in the repository. I agree with you that it should have called differently.