How to get a property by it's name

Hi,

Yes you can do it via RTTI. Nullable<T> is a record so you should handle it property. However there are helper methods in TMappingExplorer for that as well. One example:


  Value := Manager.Explorer.GetMemberValue(Object, RttiInfo);
  Manager.Explorer.SetMemberValue(Object, RttiInfo, Value);


The above will take care of Nullable and Proxy types transparently. To get RttiInfo you can use this:


  Info := Manager.Explorer.GetOptimization(TMyEntity, 'PropName');
  // You should later destroy Info object!


or


  // For primitive types:
  Info := Manager.Explorer.GetColumnByPropertyName(TMyEntity, 'PropName').Optimization;
  // For instance (association) types:
  Info := Manager.Explorer.GetAssociationByPropertyName(TMyEntity, 'AssocPropName').Optimization;


  // No need to destroy Info objects in this case

Wagner R. Landgraf2018-03-02 15:06:43