As continue to this question, I have this method:
public IEnumerable<Splitting> Get(Guid companyId, long customerId)
{
CustomerRepository customersRep = new CustomerRepository();
var customers = customersRep.Get(companyId);
return GetQuery().Join(customers,
s => s.CustomerId,
c => c.Id,
(s, c) => new { s, c }).
Where(sc => sc.c.Id == customerId).
Select(sc => sc.s);
}
When I am doing:
var query=Get(someGuid, someCustomerId);
query.ToList(); //This throws an exception
I got the exception:
Unable to create a constant value of type 'MyProj.Domain.Business.Entities.Company.Customers.Customer'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.
What is the meen of this exception and how can I solve it?
UPDATE:
GetQuery()
returns Context.CreateObjectSet<T>()
where T in this case is Splitting
class.
CustomerRepository.Get(companyId)
is:
public IEnumerable<Customer> Get(Guid companyId)
{
return GetQuery().
Where(x => x.CompanyId == companyId).
Where(x => x.IsDeleted == false).
AsEnumerable().
OrderBy(x => x.Name.IsNumeric()).
ThenBy(x => x.Name);
}