Reputation: 11
I have the following related POCO entities saved in SQLite.
public class Customer
{
[PrimaryKey]
public int Id { get; set; }
public string Name { get; set; }
[Reference]
public List<Order> CustomerOrders { get; set; }
}
public class Order
{
[PrimaryKey]
public int Id { get; set; }
public int CustomerId { get; set; }
public string Type { get; set; }
public int Qty { get; set; }
}
Using the following AutoQuery with inner join
public class AutoQueryRequest : QueryBase<Customer>, IJoin<Customer, Order>
{
}
If I have 1 Customer record with 3 related Order records, the inner join query returns 3 records of Customer (as expected). Since the Orders are already included in the Customer entity, how can I make the AutoQuery to return only distinct Customer records (1 in this case)?
Upvotes: 1
Views: 240
Reputation: 143349
You don't need to join on the Order table to load OrmLite POCO References as they're loaded automatically, so your AutoQuery Service just needs to Query the Customer parent POCO, e.g:
public class QueryCustomers : QueryBase<Customer> {}
Upvotes: 1