I keep getting the following error when I execute the query below. I'm not sure how else to put in my condition. I haven't been able to find the same issue with other questions that have posed the same error output.
Unable to create a constant value of type 'Project.Models.Bill'. Only primitive types or enumeration types are supported in this context.
The code:
var billResults = db.Database.SqlQuery<Bill>("exec [dbo].[sp_getBills]").AsQueryable();
var results = db.Bills.Select(
a => new
{
a.Id,
a.Col1,
a.Col2,
ErrorCount = (int) (billResults.Where(x => x.BillResultsId == a.Id).Count())
}).Where(a => a.Col1 == "Test123");
I'd appreciate any help - been stuck for the past few hours on this.
Thanks!