Hello,
we had the problem, that we have a Field in an Table with a lot of same Entries. We need to fill them in a Combobox that has distinct entries. (no doubles)
How can I make a distinct query on a database with the XDataClient List function ?
Thank you.
Hello Jens,
You can't. In this case I would suggest you just create a service operation that returns the entries in the way you want.
Hello,
thanks for ur fast answer.
Can u show me a sample pls, how i can do this ?
Thank u
XData service operations: http://www.tmssoftware.biz/business/xdata/doc/web/service_operations_tutorial.html
Just implement a method with this signature and implement the code you need:
function IMyService.MyEntries: TList<TMyEntry>;
begin
// Retrieve a list of unique TMyEntry objects and return it
end;
A very old Thread, but we solve it like this:
(a service operation, who send only the entries for the combobox. We use it in WebCore)
In this case, we have our own ObjectManager. You can change it.
The field for the combo is "Group"
function TMyServiceFunc.getComboEntries: TStream;
var
ObjManager : TsngDBOManager;
LList : TObjectList<TCriteriaResult>;
i : Integer;
sl : TStringlist;
begin
ObjManager := dmServer.GetXOCObjectManager;
try
LList := ObjManager.OM.Find<TMyEntity>
.Select( TProjections.ProjectionList.Add( TProjections.Group('Group')))
.OrderBy( 'Group')
.ListValues;
sl := TStringlist.Create;
for i := 0 to LList.Count-1 do
sl.Add( LList[i].Values[0]);
Result := TStringStream.Create;
try
sl.SaveToStream( Result);
finally
sl.Free;
LList.Free;
end;
finally
ObjManager.Free;
end;
end;
Here is a sample result, screenshot from Postman.
The table has over 100 records, but only 5 groups
1 Like