I have 4 classes
public class Customer
{
public string CustomerName { get; set; }
public ICollection<Order> Orders{ get; set; }
}
public class Order
{
public string OrderNumber { get; set; }
public ICollection<OrderLine> OrderLines { get; set; }
public OrderType Type { get; set; }
}
public class OrderLine
{
public string StockItem { get; set; }
}
public class OrderType
{
public string Type { get; set; }
}
Using entity frameworks i want to pull out all the information starting at Customer level. I can get most information out but i am stuck getting OrderType to show against the order.
This is what i have so far.
var customerOrderDetails = _myOrderRepository
.GetAll()
.Include(o => o.Orders)
.ThenInclude(l => l.OrderLines)
I've tried added select after the o.Orders but that doesn't seem to work.
You can (and should) repeat the Include(x => x.ProjectActivityTasks)
part:
var qry = await _projectActivityRepository.GetAll()
.Include(x => x.ProjectActivityVehicles)
.ThenInclude(x => x.Vehicle)
.Include(x => x.ProjectActivityTasks)
.ThenInclude(x => x.ProjectActivityTaskType)
.Include(x => x.ProjectActivityTasks)
.ThenInclude(x => x.UnitOfMeasure)
.Where(x => x.Id == Id && x.TenantId == (int)AbpSession.TenantId)
.FirstOrDefaultAsync();