0

我的代码:

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

当我运行它时,我得到了一个NullReferenceExceptionChildProducts线。我知道那string[]是一个对象,因为它就在那里,所以它一定是PropertiesToReturn。有谁知道是什么问题?LoadChildProducts工作没有任何问题。

4

2 回答 2

1

您需要新建SearchOptions对象,如下所示:

CatalogSearchOptions searchOptions = new CatalogSearchOptions();

然后你可以添加PropertiesToReturn,像这样:

searchOptions.PropertiesToReturn = "BasePrice";

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

cc.ChildProducts.SearchOptions = searchOptions;
于 2013-09-06T18:21:41.100 回答
0

它是ChildProductsChildProducts的内部或内部。 确保它们在 a 的构造函数中被初始化SearchOptions
CategoryConfiguration

于 2013-09-06T18:22:50.513 回答