Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After Upgrade NuGet-Package to 1.2.20 accessing dynamic properties by index fails #634

Closed
werner-fleck opened this issue Oct 20, 2022 · 1 comment
Assignees
Labels

Comments

@werner-fleck
Copy link

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.

AlekseyMartynov added a commit to DevExpress/DevExtreme.AspNet.Data that referenced this issue Oct 21, 2022
AlekseyMartynov added a commit to DevExpress/DevExtreme.AspNet.Data that referenced this issue Oct 21, 2022
)

zzzprojects/System.Linq.Dynamic.Core#634

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: AlekseyMartynov <[email protected]>
@StefH
Copy link
Collaborator

StefH commented Oct 23, 2022

#637

@StefH StefH closed this as completed Oct 23, 2022
@StefH StefH self-assigned this Oct 23, 2022
@StefH StefH added the bug label Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants