Rest api 方法调用不止一次

Rest api Method call morethan one time

我在 nopcommerce 中开发了 REST api 插件方法,用于从产品 table 获取所有产品列表,但是我的方法调用了两次!我只想打电话给那些。

public IList<ProductAllResponse> GetAllProducts(string apiSecretKey, int storeId, int languageId)
    {

      var  _productRepository = EngineContext.Current.Resolve<IRepository<Product>>();

        var GetAllProducts = new List<ProductAllResponse>();

        try
        {

            if (!CheckAPIKey(apiSecretKey, storeId))
            {
                GetAllProducts.Add(new ProductAllResponse { Message = _localizationService.GetResource("Plugins.XcellenceIT.RestApi.Message.CheckApi") });
                return GetAllProducts;
            }

            var query = (from p in _productRepository.Table
                         where p.Published && !p.Deleted
                         select new
                         {
                             Id = p.Id,
                             Name = p.Name

                         }).ToList();

            foreach (var item in query)
            {
                GetAllProducts.Add(new ProductAllResponse { Id = item.Id, Name = item.Name });
            }

            return GetAllProducts;
        }

        catch (Exception exc)
        {
            _logger.Error(exc.Message);
            GetAllProducts.Add(new ProductAllResponse { Message = exc.Message });
            return GetAllProducts;
        }

    }  

这里的问题在 ProductAllResponse 中,这个响应 class 继承自其他 class contextClass,并且 class 具有相同的 属性 称为 Id.

当我从 ProductAllResponse 中删除 Id 时,它现在调用了一次。