You are not logged in.
Pages: 1
Hi guys,
I might be wrong in my approach, but I would like to deal exclusively with interfaces when communicating between client and server. In my sandbox project I have a blog (for example). Let's call it IBlog and IBlog has a method:
IBlog = interface(IInvokable)
['{F4479253-C592-48D3-9658-FFE3C9EE07DE}']
function getName: string;
procedure setName(const Value: string);
function getPosts( out Posts : IPosts ) : integer;
end;
TBlog = class(TSQLRecordInterfaced, IBlog)
private
function getName: string;
procedure setName(const Value: string);
public
function getPosts( out Posts : IPosts ) : integer;
publsihed
property Name: string read getName write setName;
end;
What should IPosts' definition look like?
I've been toying around with IEnumerator, IList and a couple of other friends, but none of these seem to really work well.
Offline
If you use SOA, you should better use DTO.
Records and dynamic arrays are very best candidates for DTO.
Since Delphi 2010, they are directly serialized as JSON.
Otherwise, if you want to return class instances (e.g. any TSQLRecord) you could just use :
- RawJSON, and fill a TSQLTable with the returned content;
- a TObjectList.
For an example of a Blog, including working ORM data model and some MVC commands, see our sample https://github.com/synopse/mORMot/tree/ … C%20Server
You will find here some good practice patterns, to refine your approach.
Offline
Pages: 1