วัตถุประสงค์: เพื่อขยายออบเจ็กต์ และฉายภาพคุณสมบัติที่ซ้อนกัน ไปยังการเลือกรูท ควบคู่ไปกับอุปกรณ์ประกอบฉากอื่นๆ
มีความสัมพันธ์ดังต่อไปนี้
public class Product {
public string Barcode { get; set; }
public double Price { get; set; }
public Category Category { get; set; }
}
public class Category {
public string Name { get; set; }
}
ฉันต้องการทำการฉายภาพซึ่งจะส่งผลให้:
{
"@odata.context": "http://localhost/odata/$metadata#Product",
"value": [
{
"Price": 500,
"Name": "Meat Products" // this is category name, ideally would be to rename it to CategoryName
}
]
}
ขณะนี้ฉันได้รับสิ่งนี้ที่ไหน:
{
"@odata.context": "http://localhost/odata/$metadata#Product",
"value": [
{
"Price": 500,
"Category": {
"Name": "Meat Products"
}
}
]
}
แบบสอบถามที่ใช้มีดังต่อไปนี้:
/odata/Product?$expand=Category($select=Name)&$select=Price
ฉันคาดว่าจะเขียนภาพเช่นนี้:
/odata/Product?$expand=Category&$select=Price,Category/Name as CategoryName
or
/odata/Product?$expand=Category&$select=Price,Category($select=Name as CategoryName)
or
/odata/Product?$expand=Category&$select=Price,Category($select=Name)
เป็นไปได้ไหม? ขอบคุณ!
ป.ล. โอดาต้า V4.