-
Notifications
You must be signed in to change notification settings - Fork 95
ADO.NET like API
Daniel Frantik edited this page Mar 5, 2016
·
7 revisions
Second option is to use ADO.NET like API. This API tries to be very simmilar to database API used in .NET world. It allows you to create ITikCommand commands, use parameters and other features like ADO.NET does.
The main entry point is mikrotik router connection object (ITikConnection). Instance of connection object should be instancied via factory (ConnectionFactory). Command instance should be created via ITikConnection methods.
using tik4net;
// ...
connection = ConnectionFactory.OpenConnection(TikConnectionType.Api, HOST, USER, PASS);
ITikCommand command = connection.CreateCommand("/system/identity/print");
string identity = cmd.ExecuteScalar();
Console.WriteLine("Router identity: {0}", identity);
##How to create command
- connection.CreateCommand
- connection.CreateCommandAndParameters
##How to use parameters Parameters are similar to DB ones. Instance of ITikCommandParameter should be created via connection.CreateParameter method.