Return a class

Hi there,

How can I return a simple class with Xdata?
I read in the documentation that simple objects are supported.

function ReturnClientDTO(Id: Integer): TClientDTO;

How must the class TClientDTO be structured?

If I return a simple class via a service, I get an access violation

Hi,

It's as simple as that. Nothing especial is required about TClientDTO.

function TMyService.ReturnClientDTO(Id: Integer): TClientDTO;
begin
  Result := TClientDTO.Create;
  Result.Id := Id;
end;

Just, do not destroy the result object inside the service method (or ever since XData will do it for you)

Maybe you can show us the actual code to see what's going on

Regards,

1 Like

:anguished:

I had released the object. Tanks for the advice.

2 Likes

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