I have three tables
- Person Table (Generic person table)
- Customer Table (every customer is a person)
- Address Table (every customer has an address)
I need to query the database from entity framework for a match on the person's name and city, state. This is what I have but it doesn't work unless I remove the state and city from the where clause
var customer = db.tbl_Person
.Include(t => t.tbl_Customer.tbl_Address)
.Where(t => t.VendorID == person.VendorID &&
t.FirstName == person.FirstName &&
t.LastName == person.LastName &&
t.tbl_Customer.tbl_Address.State == address.State &&
t.tbl_Customer.tbl_Address.City == address.City).ToList();
Any help would be appreciate - I'm still fairly new to EF. As stated in my comments below, the error I get is
Additional information: Unable to cast object of type 'System.Linq.Expressions.FieldExpression' to type 'System.Linq.Expressions.ParameterExpression'.