1. Description
After upgrading the NuGet package System.Linq.Dynamic.Core to version 1.2.20, accessing properties of dynamic results by index, i.e. using variable["index"] fails with NullReferenceException. Direct access by property name works, i.e. variable.index.
2. Exception
[NullReferenceException: Object reference not set to an instance of an object.]
System.Linq.Dynamic.Core.DynamicClass.get_Properties() +125
CallSite.Target(Closure , CallSite , Object , String ) +181
MyAppBackend.BusinessLogic.ListManagement.ListManagement.GetListRowId(Nullable`1 listManagementListRowId) in E:\git-repos\MyAppIII\MyAppBackend\BusinessLogic\ListManagement\ListManagement.cs:555
MyApp.Controllers.ListManagementController.Edit(Nullable`1 listId, Nullable`1 listRowId, Nullable`1 listManagementListRowId) +710
lambda_method(Closure , ControllerBase , Object[] ) +277
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +34
System.Web.Mvc.Async.<>c.<BeginInvokeSynchronousActionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +38
System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +69
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +41
System.Web.Mvc.Async.<>c__DisplayClass11_0.<InvokeActionMethodFilterAsynchronouslyRecursive>b__0() +79
System.Web.Mvc.Async.<>c__DisplayClass11_2.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2() +387
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass3_6.<BeginInvokeAction>b__4() +50
System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) +188
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +26
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +68
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +40
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +68
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +648
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +213
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +131
3. Fiddle or Project
Our code looks like
var dc = new DataContext(_connectionString, _xmlMappingSource) {ObjectTrackingEnabled = false};
var listManagementListRowTable = dc.GetTable(_listManagementListRowType);
var element = listManagementListRowTable.AsNoTracking().Where("ListManagementListRowId == @0", listManagementListRowId).FirstOrDefault();
var isDeleted = (bool) element["IsDeleted"];
The exception occurs on the last line.
Using var isDeleted = (bool) element.IsDeleted; instead works.
4. Any further technical details
After downgrading to 1.2.19 our app is working again.
1. Description
After upgrading the NuGet package System.Linq.Dynamic.Core to version 1.2.20, accessing properties of dynamic results by index, i.e. using
variable["index"]fails with NullReferenceException. Direct access by property name works, i.e.variable.index.2. Exception
3. Fiddle or Project
Our code looks like
The exception occurs on the last line.
Using
var isDeleted = (bool) element.IsDeleted;instead works.4. Any further technical details
After downgrading to 1.2.19 our app is working again.