This may not be possible in AutoQuery. I have the following:
public class QueryCustomerProductAssignment : QueryDb<Product,CustomerProductAssignment>
{
public int CustomerId { get; set; }
}
With the following implementation
public async Task<object> Any(QueryCustomerProductAssignment request)
{
var customerId = request.CustomerId;
using var db = autoQuery.GetDb(request, base.Request);
var q = autoQuery.CreateQuery(request, base.Request, db);
q.LeftJoin<CustomerProductMap>((p, m) => p.Id == m.ProductId && m.CustomerId == customerId)
.Select<Product, CustomerProductMap>((p, m) =>
new CustomerProductAssignment
{
ProductId = p.Id,
ProductName = p.Name,
CustomerId = m.CustomerId,
IsAssigned = m.CustomerId != 0
});
return autoQuery.Execute(request, q, base.Request, db);
}
Calling the endpoint produces the following:
variable 'p' of type 'OrderApp.ServiceModel.types.Product' referenced from scope '', but it is not defined