Hi,
i’m using joins in my dtos to be able to filter on subentities.
It works fine but when i retrieve the results i dont want it to return the sub entity records, only the distinct records (without the subentity). You can see in my DTO that i join against BookingResourceRelation
[ApiResponse(HttpStatusCode.Unauthorized, "You were unauthorized to call this service")]
[Authenticate]
public class BookingQuery : QueryDb<Booking, BookingQueryResponse>, IJoin<Booking, BookingResourceRelation>
{
[ApiMember(
Description =
"Query for specific Booked Resources, default is all resources",
ParameterType = "query",
IsRequired = false)]
[DataMember(Name = "BookedResourceIds")]
public int[] BookingResourceRelationResourceIds { get; set; }
I can do that by using DistinctBy
List<Booking> result = Db.LoadSelect(q).DistinctBy(b=> b.Id).ToList();
But in the return it will not be correct using the Take and Count
This will still have the duplicated rows
return new QueryResponse<BookingQueryResponse>
{
Offset = q.Offset.GetValueOrDefault(0),
Total = (int)Db.Count(q),
Results = merged.Select(Translate).ToList()
};
How can i perform the distict autoquery on the main entity Booking without retrieving the rows on the subentity called BookingResourceRelation but still keep the possibility to filter on BookingResourceRelationResourceIds
Thx!