Given a primitive value age
I know how to create an expression like this:
//assuming: age is an int or some other primitive type
employee => empl
You can't do that because EF doesn't know how to translate equality comparisons on Location
into a SQL expression.
However, if you know what properties of Location
you want to compare, you can do this with anonymous types:
var location = GetCurrentLocation();
var locationObj = new { location.LocationName, location.LocationDescription };
employees = DataContext.Employees.Where(e => new { e.Location.LocationName, e.Location.Description } == locationObj);
Of course that's equivalent to:
var location = GetCurrentLocation();
employees = DataContext.Employees.Where(e => e.Location.LocationName == location.Name &&
e.Location.Description == location.Description);