setpropvalue problem

Hi Folks,


Given Entity TPerson and Property FirstName I can do 

MyPerson ;= TPerson.Create;
MyPerson.FirstName := 'Greg';

But using typinfo.pas and Delphi RTTI

SetPropValue(MyPerson,'FirstName','Greg');
does not recognise 'FirstName' as a property of MyPerson.

and GetPropInfo(MyPerson,'FirstName') returns nil

Can I do something like Myperson.Props['FirstName'] := 'Greg' on a regular property as it is on Dynamic properties?

A workaround I know is to use the Aurelius Dataset and Fieldbyname('FirstName') but I would rather not.

Cheers Greg

Such methods are the "old" RTTI, pre-2010, which only works for published properties. If you put your FirstName property in the published section of your TPerson class, you will be able to achieve what you want. Otherwise, you would have to use the new RTTI classes. Some references: 
http://docwiki.embarcadero.com/Libraries/XE2/en/System.Rtti.TRttiProperty.SetValue
http://robstechcorner.blogspot.com.br/2009/09/so-what-is-rtti-rtti-is-acronym-for-run.html
https://forums.embarcadero.com/thread.jspa?messageID=529596

Thanks Wagner, 

I am glad I did not pick up on the published properties, obvious in hindsight, as I would not have discovered all the new RTTI features post 2010.