The documentation comes from the Markdown files in the source code, so is always up-to-date but available only in English. Enjoy!
Database and Administrator are static classes, and you usually save, retrieve and query objects with a certain level of ignorance of how the database looks (Schema), or where it is physically located (connection string).
Not having to pass the connectionString and the Schema
as a parameter all the time doesn't mean that you don't have the flexibility to change it when you think it is necessary. In order to change the connection in a block of your code just use Connector.Override
.
You can think in a Connector class like the container that has all the information to access a specific database in a DBMS:
connectionString
.Schema
.Internally, Connection class is also the only gateway to access the database, it's not intended to be used by client code. Executor static class is what should be used if you want low-level ADO.Net access through the current connection.
You can also think of Connector class as a abstract factory of Connections:
ConnectionString
: The connection string that will be used to create the connection.CommandTimeout
: Default timeout, optional.IsolationLevel
: Default IsolationLevel, optional.Typically, you application has just one main Connector
and is set using Connector.Default
.
Connector.Default = new SqlConnector(connectionString, sb.Schema);
Connector
class has a static Override
method that returns a IDisposable
and let you switch Connector.Current
to be something different to Connector.Default
in a region of code.
public static IDisposable Override(Connector connection)
Note: It's uncommon to use more than one Connector
using Signum.Engine for something different that simple loading scenarios. Don't expect every module to work as expected using a non-default Connector
.
Connector
class has a static CommandTimeoutScope
method that returns a IDisposable
and let you override the default CommandTimeout
in a region of code.
public static IDisposable CommandTimeoutScope(int? timeoutMilliseconds)
Example:
using(Connector.CommandTimeoutScope(3 * 60 * 1000)) // 3 mins
{
// slow query here
}
© Signum Software. All Rights Reserved.
Powered by Signum Framework