คำขอดึงข้อมูลต้องเป็นนิพจน์การเข้าถึงของสมาชิกแบบธรรมดา '[100002]' เป็น SubQueryExpression แทน

ฉันได้รับข้อผิดพลาดต่อไปนี้: "คำขอดึงข้อมูลต้องเป็นนิพจน์การเข้าถึงสมาชิกแบบธรรมดา '[100002]' เป็น SubQueryExpression แทน ชื่อพารามิเตอร์: relatedObjectSelector"

ด้านล่างนี้คือคำถามของฉัน:

var query =
    session.Query<Customer().Where(cus => cus.CustomerId == customerId)
    .Fetch(c => c.CustomerType) // Parent CustomerType
    .Fetch(c => c.CustomerOrders) // Child Collection of orders
    .ThenFetch(co => co.Select(it => it.Item)).ToList(); // A parent of CustomerOrder

หากฉันนำ 'ThenFetch' ออก ฉันจะไม่ได้รับข้อผิดพลาดนั้น อย่างไรก็ตาม ฉันจำเป็นต้องดึงข้อมูลวัตถุ Item

มีความคิดอะไรบ้าง?

ขอบคุณ


person Rema Manual    schedule 29.10.2012    source แหล่งที่มา


คำตอบ (1)


คุณไม่สามารถใช้การเลือกกับ CustomerOrder ที่เป็นผลลัพธ์ได้หรือไม่

var query =
    session.Query<Customer().Where(cus => cus.CustomerId == customerId)
    .Fetch(c => c.CustomerType)
    .Fetch(c => c.CustomerOrder)
    .Select(co => co.Item)
    .ToList();
person René Wolferink    schedule 29.10.2012
comment
. เลือกรับลูกค้าและไม่ใช่ CustomerOrder - person Rema Manual; 29.10.2012