-
Notifications
You must be signed in to change notification settings - Fork 99
High level API entities
Claude edited this page Jul 13, 2026
·
7 revisions
Data entities are normal classes with properties. Each class corresponds to some entity on the MikroTik router, and each property corresponds to some field of an item on the MikroTik router.
For example: API: /interface
[admin@MikroTik] /interface> print
Flags: D - dynamic, X - disabled, R - running, S - slave
# NAME TYPE MTU
0 R ether1 ether 1500
1 wlan1 wlan 1500
C# entity: tik4net.Objects.Interface.Interface
public class Interface
{
public string Id { get; private set; }
public string Name { get; set; }
public string Type { get; set; }
public string Mtu { get; set; }
}To enable O/R mapper functionality we must tell engine names of the fields corresponding to our properties. We have to tell API url as well. So - we have to decorate our entity with attributes:
[TikEntity("/interface", IncludeDetails = true)]
public class Interface
{
[TikProperty(".id", IsReadOnly = true, IsMandatory = true)]
public string Id { get; private set; }
[TikProperty("name", IsMandatory = true)]
public string Name { get; set; }
// ...
}Finally we could use this entity with O/R mapper:
var list = connection.LoadAll<Interface>();See this wiki page for details.
NOTE: See How to create custom entity if you are missing some entity in tik4net project. You can clone the github repository, create your own entity and share it via "pull request" feature with others.