I am declaring a Property – when I work on my dev environment it works fine BUT when i access the staging environment, it always returns null. Why is this happening? The code never changes in both environment. This is the code.
private ProductCollection _productCollection;
public ProductCollection ProdCollection
{
get
{
_productCollection = MWProductReviewHelper.GetDistinctProductFromTill(StoreId, TDPId, ReceiptId);
if (_productCollection.Count > 0)
return _productCollection;
else
return null;
}
}
private ProductCollection _guaranteedProductCollection = new ProductCollection();
public ProductCollection GuaranteedProductCollections
{
get
{
if (_guaranteedProductCollection.Count > 0)
{
return _guaranteedProductCollection;
}
else
{
return _guaranteedProductCollection = MWProductGuaranteedHelper.CheckGuaranteedProductsFromList(ProdCollection); // the problem appears to be here...
}
}
}
I access is like this.
if (GuaranteedProductCollections.Count > 0)
{
ProductCollection _prodCollection = GuaranteedProductCollections; // return null
}
It always has one product inside it – I can see this when I put in a breakpoint.
Have you tried to bump that set on two lines? Looks like it might be returning before the set is complete.