FindAsync for multiple requests #203
-
Hey, I'm trying to perform a find with 2 differents requests, override the default limit and include a sort order but I didn't understand how should I do that with fmdata and the FindRequest() method. Let's say I'm trying to build a find request where 'Group', 'Work State' and 'FirstName' are properties of the model Employee in my .NET project :
How should I use .FindAsync() to build this query?
Thanks a lot in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
That is a more advanced use case, and the To perform multiple find requests, you will use the fmdata/src/FMData/FileMakerApiClientBase.cs Lines 378 to 394 in 9687e70 An example targeted for your post would be something like below: I want to emphasize this point though, the way the sorting is handled is going to change in v5:#158. It will be a breaking change, so watch for that. No planned release of v5, but its something I'm chipping away at. var findOne = new Employee { Group = "=Surgeon", WorkState = "CA" };
var findTwo = new Employee { Group = "=Surgeon", WorkState = "NY" };
var request = _fmdata.GenerateFindRequest<Employee>.UseLayout(new Employee());
// note the call to AddQuery on the FindRequest object.
// this lets you specify which find requests are omit style and which are not
request.AddQuery(query: findOne, omit: false);
request.AddQuery(query: findTwo, omit: true);
// sort
request.Sort = new[]
{
new FMData.Rest.Requests.Sort()
{
SortField = "Work State", // actual filemaker field name used here
SortOrder = "ascend"
},
new FMData.Rest.Requests.Sort()
{
SortField = "FirstName", // actual filemaker field name used here
SortOrder = "ascend"
},
};
// execute the find and load the results
var results = _fmdata.SendAsync(request); |
Beta Was this translation helpful? Give feedback.
That is a more advanced use case, and the
.FindAsync()
method is not designed for what I'd call an "advanced" find operation; however, the Data API and FMData should be able to generate the API calls that you need.To perform multiple find requests, you will use the
.SendAsync()
overload that takes anIFindRequest
. If you poke around the source, you'll notice that the.FindAsync()
method actually just creates anIFindRequest
and passes it along to.SendAsync()
so that's worth checking out as one example:fmdata/src/FMData/FileMakerApiClientBase.cs
Lines 378 to 394 in 9687e70