Skip to content

High level API CRUD

Daniel Frantik edited this page Apr 9, 2017 · 4 revisions

All data-modify methods are implemented as extension methods of ITikConnection and ITikCommand objects. Every works with some data entity. For details about entities see this wiki page.

  • Save: Saves entity to mikrotik router.
  • SaveListDifferences: Advanced version of Save which works with whole list of entities.
  • Delete: Deletes entity (.id is the key) on mikrotik router.
  • DeleteAll: Deletes all entities of given type on mikrotik router.
  • Move: Moves given entityToMove before given entityToMoveBefore.
  • MoveToEnd: Moves given entityToMove to the end (make it last entity in the list).

Save

Saves entity to mikrotik router. Does insert (/add) whan entity has empty id and update(/set + /unset) when id is present).

var firewallFilter = new FirewallFilter()
{
    Chain = FirewallFilter.ChainType.Forward,
    Action = FirewallFilter.ActionType.Accept,
};
connection.Save(firewallFilter);

SaveListDifferences

Advanced version of Save which works with whole list of entities. See advanced scenarions for details.

Delete

Deletes entity (.id is the key) on mikrotik router.

var loadedFilter = Connection.LoadById<BridgeFilter>(filter.Id);
connection.Delete<BridgeFilter>(loadedFilter);

DeleteAll

Deletes all entities of given type on mikrotik router.

int deletedCnt = Connection.DeleteAll<HotspotUser>();

Move

Moves given entityToMove before given entityToMoveBefore. REMARKS: only some entities supports ordering.

MoveToEnd

Moves given entityToMove to the end (make it last entity in the list). REMARKS: only some entities supports ordering.