繁体   English   中英

NullReferenceException Commerce Server Web服务

[英]NullReferenceException Commerce Server Web Service

我的代码:

        ws.CategoryConfiguration cc = new ws.CategoryConfiguration();
        cc.LoadChildProducts = true;
        cc.ChildProducts.SearchOptions.PropertiesToReturn = new string[] { "BasePrice" };

当我运行此命令时,在ChildProducts行上收到NullReferenceException 我知道string[]是一个对象,因为它就在那里,因此它必须是PropertiesToReturn 有人知道这个问题是什么吗? LoadChildProducts可以正常工作。

您需要像这样SearchOptions对象:

CatalogSearchOptions searchOptions = new CatalogSearchOptions();

然后,您可以添加PropertiesToReturn ,如下所示:

searchOptions.PropertiesToReturn = "BasePrice";

最后,您可以将searchOptions分配给CategoryConfiguration.ChildProducts.SearchOptions属性,如下所示:

cc.ChildProducts.SearchOptions = searchOptions;

它要么是ChildProductsSearchOptions的ChildProducts内。
确保它们在CategoryConfiguration的构造函数中已初始化

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM