単純に見える状況がありますが、解決できないか、同様の状況が解決されていません。助けてください:-)
サーバー上の次の 2 つのクラス:
public class Category
{
[Key]
public int CategoryId { get; set; }
[Required]
[MaxLength(256)]
public string Name { get; set; }
public Int16? Order { get; set; }
[ForeignKey("ParentCategoryId")]
public Category ParentCategory { get; set; }
public int? ParentCategoryId { get; set; }
[ForeignKey("ParentCategory")]
[InverseProperty("ParentCategory")]
public List<Category> SubCategories { get; set; }
[ForeignKey("ProductId")]
public List<Product> Products { get; set; }
}
public class Product
{
[Key]
public int ProductId { get; set; }
[Required]
[MaxLength(256)]
public string Name { get; set; }
[MaxLength(1024)]
public string Desc { get; set; }
public int ShopPrice { get; set; }
public int WebPrice { get; set; }
[MaxLength(32768)]
public string ProductDetails { get; set; }
}
シンプルなコントローラーメソッド:
[HttpGet]
public IQueryable<Category> Categories()
{
return _contextProvider.Context.Categories;
}
次のURLを使用すると:
http://localhost:49733/api/breeze/Categories?$filter=CategoryId%20eq%2010&$expand=Products
次のデータを取得します。
[{"$id":"1","$type":"Photoshwartz.Models.Category, Photoshwartz","CategoryId":10,"名前":"次の .1.1","注文":2," ParentCategory":null,"ParentCategoryId":1,"SubCategories":null,"Products":[{"$id":"2","$type":"Photoshwartz.Models.Product, Photoshwartz","ProductId" :1,"Name":"バージョン 1.1.1","Desc":"バージョン 1.1.1","ShopPrice":328,"WebPrice":295,"ProductDetails":"abcdef...."} ,{"$id":"3","$type":"Photoshwartz.Models.Product, Photoshwartz","ProductId":2,"Name":"バージョン 1.1.2","Desc":" ...","ショップ価格":570,"WebPrice":513,"ProductDetails":"abcdef...."},{"$id":"4","$type":"Photoshwartz.Models.Product, Photoshwartz","ProductId":3, "名前":"バージョン 1.1.3","説明":"バージョン 1.1.3","ShopPrice":579,"WebPrice":521,"ProductDetails":"abcdef...."},{" $id":"5","$type":"Photoshwartz.Models.Product, Photoshwartz","ProductId":4,"Name":"1.1.4 から","Desc":"... ","ShopPrice":598,"WebPrice":538,"ProductDetails":"abcdef...."},{"$id":"6","$type":"Photoshwartz.Models.Product, Photoshwartz ","ProductId":5,"Name":"バージョン 1.1.5","Desc":"ShopPrice":362,"WebPrice":325,"ProductDetails":"abcdef...."},{"$id":"7", "$type":"Photoshwartz.Models.Product, Photoshwartz","ProductId":6,"Name":"バージョン 1.1.6","Desc":"最新バージョンの...","ShopPrice":484, "WebPrice":435,"ProductDetails":"abcdef...."},{"$id":"8","$type":"Photoshwartz.Models.Product, Photoshwartz","ProductId":7, "名前":"バージョン 1.1.7","説明":"バージョン 1.1.7","ShopPrice":416,"WebPrice":374,"ProductDetails":"abcdef...."},{" $id":"9","$type":"Photoshwartz.Models.Product,Photoshwartz","ProductId":8,"Name":"1.1.8 から","Desc":"1.1.8 から購入する...","ShopPrice":281,"WebPrice":252,"ProductDetails":"abcdef ...."},{"$id":"10","$type":"Photoshwartz.Models.Product, Photoshwartz","ProductId":9,"Name":"バージョン 1.1.9"," Desc":"これは...","ShopPrice":213,"WebPrice":191,"ProductDetails":"abcdef...."}]}]Photoshwartz","ProductId":9,"Name":"1.1.9 から","Desc":"これは...","ShopPrice":213,"WebPrice":191,"ProductDetails":"abcdef ...."}]}]Photoshwartz","ProductId":9,"Name":"1.1.9 から","Desc":"これは...","ShopPrice":213,"WebPrice":191,"ProductDetails":"abcdef ...."}]}]
ご覧のとおり、9 つのアイテムを含む「Products」というナビゲーション プロパティがあります。ただし、次のコードを使用してこのデータにアクセスしようとすると、ナビゲーション以外のプロパティ (たとえば、'name()' および 'order()') が取得されますが、'products' は定義されていません (または 'Products' または 'products( )' または 'Products()'...)。これを「data.results[0]」で確認するために、「querySucceededAppend」にブレークポイントを設定しました。
var query = EntityQuery
.from("Categories")
.where("categoryId", "==", categoryId)
.expand("products");
manager.executeQuery(query).then(querySucceededAppend)
提案はありますか?
ありがとう !
エリオール