Database
string
OpenMode
enum
CreateIfNotExists
StartMode
enum
StartIfNotRunning
StopMode
enum
IfWeStarted
ContextCount
integer
2
– 24
Database
Database
option is required in the connection string, and consists of an absolute or relative path to the directory where the Starcounter database files are located, or should be located if they do not yet exist.OpenMode
OpenMode
option defines how to interpret the database path on connection. It can have the following string values:Open
Database
option, if it exist. If the directory does not exist, or if there is no Starcounter database located there, an exception is thrown.CreateIfNotExists
Database
option, if it exist. If the directory does not exist, or if there is no Starcounter database located there, it will create the necessary directories and database files, and then open the database directory.StartMode
StartMode
option defines how to start and/or connect to the database process once the database files have been located and/or created.RequireStarted
StartIfNotRunning
StartExclusive
StopMode
StopMode
option defines whether to stop the database process once the connection to it is closed, for example when an application is terminated.IfWeStarted
Never
Never
option is not effective when the application process is forcibly killed, for example from a task manager or by Ctrl + C
. In this case operating system will kill the corresponding database process as well.ContextCount
ContextCount
option defines the number of database contexts to use in the database connection.IDatabaseContext
as used in the .NET API for transactions. In the context of database connections, database contexts refer to the entry points to the database from the applications' point of view. When an application thread has a database context assigned, it can read and write to the database.ContextCount
option to manually adjust the number of database contexts to occupy in this connection.Database
option using a relative path to a database Sample
, located in the .database
directory of the current directory. If such a directory does not exist at the time of connection, or if it does not contain a Starcounter database, the OpenMode
option of CreateIfNotExists
ensures that it is created. If the database process is not running already, the StartMode
option ofStartIfNotRunning
ensures that it should be started. And when the app disconnects from the database, it will stop the database process if it was started by this app, since the StopMode
option is defined asIfWeStarted
. Lastly, we set the number of occupied database contexts in this connection to 10.