Retrieving Property name from lambda expression

前端 未结 21 2048
迷失自我
迷失自我 2020-11-21 11:12

Is there a better way to get the Property name when passed in via a lambda expression? Here is what i currently have.

eg.

GetSortingInfo         


        
21条回答
  •  Happy的楠姐
    2020-11-21 12:02

    Well, there's no need to call .Name.ToString(), but broadly that is about it, yes. The only consideration you might need is whether x.Foo.Bar should return "Foo", "Bar", or an exception - i.e. do you need to iterate at all.

    (re comment) for more on flexible sorting, see here.

提交回复
热议问题