2

first of all, thanks to @gregdennis. I use Manatee Trello namespace to query and get Actions from Trello board. there is a limitation to getting entities on each request (50 by default). In Online API documentation I read there are several parameters like 'limit' and 'before'. How I passing these parameters to methods in my code, my sample fetch code is here:

    Board board = new Board(boardId);
    var actions = board.Actions.ToList();
Nader Vaghari
  • 141
  • 10

1 Answers1

0

There are a few extension methods on various collection types that will modify the API queries to add these parameters.

The first you're looking for is Limit(this ReadOnlyActionCollection, int). Just pass in the number of actions you want. Valid values (per the API) are 0-1000.

The second is Filter(this ReadOnlyActionCollection, DateTime?, DateTime?) which will allow you to filter on since (start) and before (end). (The API docs say that lastView is a valid option for the since parameter. This is not supported at the moment.)

Edit

Note that these extension methods work just like LINQ: they return a new instance of the query. The query doesn't execute until the collection is enumerated.

Edit 2

To get any collection you have to have a Trello entity (board, list, card, etc.) first. A collection is meaningless without the object which defines it. For example, boards have lists, lists have cards, cards have checklists, and all of these have actions.

So to get a collection that consists of the 500 most recent actions for a card,

var card = new Card("<ID>");
var actions500 = card.Actions.Limit(500);
foreach(var action in actions500)
{
    Console.WriteLine(action);
}

Edit 3

Okay. I see the problem. I didn't use the this keyword in the Limit() extensions. I'll fix that and publish an updated.

Until then, please use the method statically:

Collections.Limit(card.Actions, 100);

Edit 4

As of Manatee.Trello version 3.0.0, Limit is a property on all collections. The default is 50 for most types.

gregsdennis
  • 7,218
  • 3
  • 38
  • 71
  • I found this extension methods on this type: "ReadOnlyActionCollection". But how to fill a value derived from this type: 'ReadOnlyActionCollection r=;' because I fill the objects like this: 'var _actions = _board.Actions'. please write a full example – Nader Vaghari Dec 18 '16 at 17:27
  • You're getting the actions correctly. You just need to call the extension method. Please see edit 2. Also, please be sure you read the documentation in the [github wiki](https://github.com/gregsdennis/Manatee.Trello/wiki). – gregsdennis Dec 18 '16 at 17:44
  • I really appreciate your answers but if I could attach a picture to this reply, I would show my code screen shot in visual studio to you! I have "Filter()" extension method but there is no "Limit()" method! – Nader Vaghari Dec 19 '16 at 07:49
  • Ah! Please see edit 3. Sorry about that. Update pending. – gregsdennis Dec 19 '16 at 08:43
  • thanks man! I used it in this way: `CollectionExtensions.Limit(board.Actions, 100);` – Nader Vaghari Dec 19 '16 at 10:26
  • Please mark this as the answer if it resolved your issue. Also, check out Manatee.Trello v1.14.1 for your fix. – gregsdennis Dec 19 '16 at 17:36
  • thanks a lot. I upgraded to the last version and my problem was solved. – Nader Vaghari Dec 21 '16 at 12:03
  • there is a problem @gregsdennis, I fetched cards action in this way: `var actions = myCard.actions.limit(1000)` but it returns just 11 from it! I checked with web API but it returns about 50 actions! is there any configuration over fetch Actions?!! – Nader Vaghari Dec 26 '16 at 13:01
  • I got it. there are some default filters! and we I catch all actions by this method: `myCard.actions.Filter(ActionType.All).limit(1000)` – Nader Vaghari Dec 26 '16 at 14:04