Need to find the last type in an expression for sort RRS feed

  • Question

  • User1034446946 posted


    I have a complex data entity, and i am using a static method to determine the type in the method i use

    var expression = a => a.DateAdded

    var unaryExpression = expression.Body as UnaryExpression;

    var propertyExpression = (MemberExpression)unaryExpression.Operand;

    then i do

    if (propertyExpression.Type == typeof(DateTime))

    and everything is fine.

    However if the expression used a navigated models field, it fails, eg

    var expression = a => a.Parent.DateAdded

    Is there a way I can just get the last type and not the whole thing

    Any suggestions would be appriciated.

    Tuesday, October 2, 2018 1:29 PM


  • User1034446946 posted

    I have scrapped how I was doing it, but thanks for the reply.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 2, 2018 6:18 PM

All replies