Referencing ReadOnly property on Aurelius Entity in FMX

I have previously made progress on this problem with this post:

The suggestions in this post enabled me to return good JSON into my Browser.

However now I am trying to call the data into an FMX App I am getting an error.

--

[Entity]
[Table('People')]
[Id('FId', TIdGenerator.IdentityOrSequence)]
TPeople = class
private
[Column('ID', [TColumnProp.Required])]
FID: Integer;
... other properties here ...
[XDataProperty]
property Title: string read GetTitle;
end;

--

In my Broswer I call:

http://localhost:2001/xdata/People(25)

and JSON returns:

{
"$id": 1,
"ID": 25,
... other properties
"Title": "Mr"
}

--In FMX I call

var
oPeople: TPeople;
begin
for oPeople in XDataClient.List('$filter=(ID eq 25)') do
...
end

And get the following error:

GExperts Debugger Exception Notification
ExceptionMessage="Title"
ExceptionName="EPropReadOnly"
ExceptionDisplayName="EPropReadOnly"
ExceptionAddress=7FF99DC1543C
FileName=
LineNumber=
ExceptionObject=16B226418D0
Classes=[EPropReadOnly,Exception,TObject]

The application seems to be throwing an exception because of the presence of the property which is not read/write?

Even though the same call works OK returning JSON In the browser.

Yes, it's trying to set the value read from JSON into the Title property, and that fails because property is read-only. Define a writer for the property. even if it's a dummy SetTitle method that does nothing.

Brilliant. Thanks Wagner!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.