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


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

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

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


1 Like


I had released the object. Tanks for the advice.


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