I'm trying to add a Where clause to a table joined with a JoinAlias, but there doesn't appear to be a way to specify the JoinAlias on the where clause.
I'm trying to join to the same table multiple times, then add a variable number of where clauses to the join, based on user input:
var userFilterList = new List<Expression<Func<LocationDb, LocationAttributesDateTimeDb, bool>>>();
Expression <Func<LocationDb, LocationAttributesDateTimeDb, bool>> joinPredicate = (loc, ext) =>
loc.LocationId == ext.LocationId && ext.AttributeId == attributeId;
query = query.Join<LocationAttributesDateTimeDb>(joinPredicate, ctx.JoinAlias($"ext{attributeId}"));
foreach (var item in userFilterList)
{
query = query.Where<LocationDb, LocationAttributesDateTimeDb>(item);
}
The main problem is, there doesn't appear to be a way to add the JoinAlias onto the Where clause. If I try to run the query as is, I get an exception regarding the missing alias.
If I try the following code, I get a compile exception:
query = query.Where<LocationDb, LocationAttributesDateTimeDb>(item, ctx.JoinAlias($"ext{attributeId}"));
Is there a way to add the JoinAlias to a where clause without resorting to writing the Where clauses as manual SQL?
Or, is there an alternative method I can use to stitch my multiple requests together into the single Join predicate?