Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
680
NullReferenceException in GridFiltering.GetData
posted

I have the following method:

        public JsonResult SupItemPriceList()
        {
            GenericGridModel ggm = new GenericGridModel();
            EnumerableQuery<ISupplyItem> recs = new EnumerableQuery<ISupplyItem>(new SupplyItemManager().GetAllSupplyItemPrices()); 
            if (recs.Count() == 0) 
            { 
                return null; 
            } 
            ggm.GridFiltering.DataSource = recs; 
           return ggm.GridFiltering.GetData(); 
} 

This appears to work fine when running the app. When I run it in a unit test where I have multiple threads hitting this and similar methods simultaneously (as part of a stress test), I get a NullReferenceException in the return line.

The stack trace is:

at Infragistics.Web.Mvc.GridModel.DataBindInternal()
at Infragistics.Web.Mvc.GridModel.DataBind()
at Infragistics.Web.Mvc.GridModel.GetData()
at GEMS.Web.Controllers.SupplyInventoryController.SupItemPriceList() in s:\[... my directory ...]\Controllers\SupplyInventoryController.cs:line 146

In this particular case, recs always contains 267 records.

What's wrong?