Chained Where causing Null Reference Exception

93 Views Asked by At

I have a problem with Entity Framework Plus. Ctx works, ctx2 works but when I execute ctx3 I get : System.NullReferenceException: Object reference not set to an instance of an object. Any ideas what I might be doing wrong ? GetQueryableContext has been reduced to _context.Set.

Thanks.

var ctx = await GetQueryableContext(request);
ctx = ctx.Where(x => x.DepotNo >= request.DepotNo);
ctx.Update(x => new Order() { LorryLoadingListPrinted = 1111 });

var ctx2 = await GetQueryableContext(request);
ctx2 = ctx2.Where(x => x.DepotNo <= request.DepotNo);
ctx2.Update(x => new Order() { LorryLoadingListPrinted = 2222 });

var ctx3 = await GetQueryableContext(request);
ctx3 = ctx3.Where(x => x.DepotNo >= request.DepotNo).Where(x => x.DepotNo <= request.DepotNo);
ctx3.Update(x => new Order() { LorryLoadingListPrinted = 3333 });
0

There are 0 best solutions below