You are not logged in.
Pages: 1
I'm very fond of IList but I'm trapped by the fact that I have to declare it as a constant in the parameter list on a service method.
So there is no way to initialize it.
I'm sure that there is a solution to this but at the moment I'm lost.
Delphi-11, WIN10
Offline
We did not validate that IList<T> would work as expected for the services... even as a "const" parameter...
AFAIR the only kind of interface supported is for websockets/async callbacks, not lists...
What does currently work, from your tests?
Offline
I solved it by replacing IList with an ordinary dynamic array for the service. It requires some more coding but it works. I kept using IList in the repository though as I can initiate the collection in the service before calling the repository methods.
It seems to require too much effort to be worth solving ?
Delphi-11, WIN10
Offline
It seems to require too much effort to be worth solving ?
In the client program I work with Spring4D. Here there is also an IList. For this I have connections for various components. The bridge between the two looks like this:
type
TOrmArticleList = class(Spring.Collections.Lists.TObjectList<TOrmArticle>);
TOrmArticleObjArray = array of TOrmArticle;
function ...CreateArticleList(const pmcSectionID: TID): TOrmArticleList;
var
service: IArticle;
dataArr: TOrmArticleObjArray;
begin
if not dmDB.RestServer.Resolve(IArticle, service) then Exit(Nil); //=>
service.GetAllItems(pmcSectionID, [asActive], dataArr);
Result := TOrmArticleList.Create(dataArr, True);
end;
mORMot provides an ObjArray that fills the list. With the Spring4D classes I have many functions that I don't have to implement myself. If you only need the IList interface, you can write like this:
Result := TCollections.CreateObjectList<TOrmArticle>(dataArr, True);
With best regards
Thomas
Offline
Pages: 1