Click or drag to resize

LiteDatabase Class

The LiteDB database. Used for create a LiteDB instance and use all storage resources. It's the database connection
Inheritance Hierarchy
SystemObject
  Internal.LiteDBLiteDatabase

Namespace: Internal.LiteDB
Assembly: NeoAxis.Core (in NeoAxis.Core.dll) Version: 2026.1.1.0 (2026.1.1.0)
Syntax
C#
public class LiteDatabase : ILiteDatabase, 
	IDisposable

The LiteDatabase type exposes the following members.

Constructors
 NameDescription
Public methodLiteDatabase(ConnectionString, BsonMapper) Starts LiteDB database using a connection string for file system database
Public methodLiteDatabase(String, BsonMapper) Starts LiteDB database using a connection string for file system database
Public methodLiteDatabase(ILiteEngine, BsonMapper, Boolean) Start LiteDB database using a pre-exiting engine. When LiteDatabase instance dispose engine instance will be disposed too
Public methodLiteDatabase(Stream, BsonMapper, Stream) Starts LiteDB database using a generic Stream implementation (mostly MemoryStream).
Top
Properties
 NameDescription
Public propertyCheckpointSize Get/Set in how many pages (8 Kb each page) log file will auto checkpoint (copy from log file to data file). Use 0 to manual-only checkpoint (and no checkpoint on dispose) Default: 1000 pages
Public propertyCollation Get database collection (this options can be changed only in rebuild proces)
Public propertyFileStorage Returns a special collection for storage files/stream inside datafile. Use _files and _chunks collection names. FileId is implemented as string. Use "GetStorage" for custom options
Public propertyLimitSize Get/Set database limit size (in bytes). New value must be equals or larger than current database size
Public propertyMapper Get current instance of BsonMapper used in this database instance (can be BsonMapper.Global)
Public propertyTimeout Get/Set database timeout - this timeout is used to wait for unlock using transactions
Public propertyUserVersion Get/Set database user version - use this version number to control database change model
Public propertyUtcDate Get/Set if database will deserialize dates in UTC timezone or Local timezone (default: Local)
Top
Methods
 NameDescription
Public methodBeginTrans Initialize a new transaction. Transaction are created "per-thread". There is only one single transaction per thread. Return true if transaction was created or false if current thread already in a transaction.
Public methodCheckpoint Do database checkpoint. Copy all commited transaction from log file into datafile.
Public methodCollectionExists Checks if a collection exists on database. Collection name is case insensitive
Public methodCommit Commit current transaction
Public methodDisposeReleases all resources used by the LiteDatabase
Protected methodDispose(Boolean)Releases the unmanaged resources used by the LiteDatabase and optionally releases the managed resources
Public methodDropCollection Drop a collection and all data + indexes
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodExecute(String, BsonDocument) Execute SQL commands and return as data reader
Public methodExecute(String, BsonValue) Execute SQL commands and return as data reader
Public methodExecute(TextReader, BsonDocument) Execute SQL commands and return as data reader.
Protected methodFinalize
(Overrides ObjectFinalize)
Public methodGetCollection(String, BsonAutoId) Get a collection using a generic BsonDocument. If collection does not exist, create a new one.
Public methodGetCollectionT Get a collection using a name based on typeof(T).Name (BsonMapper.ResolveCollectionName function)
Public methodGetCollectionT(BsonAutoId) Get a collection using a name based on typeof(T).Name (BsonMapper.ResolveCollectionName function)
Public methodGetCollectionT(String, BsonAutoId) Get a collection using an entity class as strong typed document. If collection does not exist, create a new one.
Public methodGetCollectionNames Get all collections name inside this database.
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetStorageTFileId Get new instance of Storage using custom FileId type, custom "_files" collection name and custom "_chunks" collection. LiteDB support multiples file storages (using different files/chunks collection names)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Public methodPragma(String) Get value from internal engine variables
Public methodPragma(String, BsonValue) Set new value to internal engine variables
Public methodRebuild Rebuild all database to remove unused pages - reduce data file
Public methodRenameCollection Rename a collection. Returns false if oldName does not exists or newName already exists
Public methodRollback Rollback current transaction
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Extension Methods
 NameDescription
Public Extension MethodMethodInvoke Calls the object method by name.
(Defined by ObjectEx)
Public Extension MethodPropertyGet Gets the value of the object property by name.
(Defined by ObjectEx)
Public Extension MethodPropertyGetT Gets the value of the object property by name.
(Defined by ObjectEx)
Public Extension MethodPropertySet Sets the value of the object property by name.
(Defined by ObjectEx)
Top
See Also