Using Asp.Net 3.1 Core EntityFramework Core LINQ, let's say I have an Order table and a Customer table:
public class Order
{
public long Id { get; set; }
public string CustomerId { get; set; }
public int Total {get; set;}
public virtual Customer Customer{ get; set; }
}
public class Customer : ApplicationUser
{
public long Id {get; set;}
public virtual ICollection<Order> Orders { get; set; }
}
Ultimately, I want to return a list of every Customer in the universe, even if they have no order (left outer?), but I also want a row for every order. So something like:
Customer Order Total
-------- ----- -----
1 null null
2 100 5
2 101 199
3 null null
4 200 299
4 201 399
The complication I ran into is that I need to do this on the server, because I need to paginate this data using skip/take
. Doing a straight Context.Customer.Include(x => x.Order)
doesn't project the rows the way I need them for pagination with skip/take
and I'm stuck on the syntax.
Is this possible in straight LINQ? If so, what would the LINQ look like?
Thanks in advance!