Asynchronous Object-Oriented SQL Wrapper


Keywords
sql, express, object, oriented, asynchronous, wrapper, mssql, sqlexpress, csharp, object-oriented, object-oriented-programming, postgresql, visual-basic-net
License
MIT
Install
Install-Package SQLExpress -Version 1.4.1

Documentation

SQLExpress

This is an Asynchronous Object Oriented SQL Wrapper to Save/Load data easily by just providing the object(s).

Available on NuGet.

Build status

Install-Package SQLExpress -Version 1.4.1

Supported Databases

MSSQL, PostgreSQL, SQLite and MySQL

Attributes

NotNull: Prevents Null data to be stored. Useful to keep the integrity of the database.

PrimaryKey: Sets the primary key of the Table that references your object. If you inherit from SQLObject, the primary key is already set to be Id property. If you implement IStoreableObject, you will have to add the attribute to the Id manually. Also, keep in mind Primary Keys cannot be Null so you should add NotNull attribute too.

Store: This is the filter attribute to store properties in the database. Optionally, you can set a priority. Only for organization though.

Varchar: Sets the maximun Length of a string (VARCHAR) to be stored in the database. The maximun length you can set is 8000. You can also use -1 to store it as VARCHAR(MAX).

Exceptions

EmptyObject: This exception will be thrown if the object doesn't have any property with Store attribute.

NullProperty: This exception will be thrown if a property with NotNull attribute has a Null value.

UnsupportedTypeException: This exception will be thrown if you add Store attribute to a property whose property type is unsupported. Examples: Object, Func<T>, Stack, etc...

CacheDisabledException: This exception will be thrown if you attempt to load objects to the cache if it was disabled in your configuration.

Methods

InitializeObjectsAsync: Checks the existence of the provided objects, if they don't exist, their tables will be created in the database.

LoadObjectsCacheAsync: Loads the Cache for a group of objects.

CreateObjectAsync: Creates a new Object in the database. LoadObject and UpdateObject will automatically create objects that don't exist so you don't actually need this at all.

LoadObjectAsync: Loads the Object from the database, creates a new one if it doesn't exists.

UpdateObjectAsync: Deletes and Re-add the Object in the database, creates a new Object if it doesn't exist.

RemoveObjectAsync: Removes the Object from the database.

SendNonQueryAsync: Executes a NonQuery in the database and returns the number of rows affected.

SendQueryAsync: Executes a query and returns a string with a table with the result.

SendScalarAsync: Executes a Scalar and returns the first value retrieved.

YieldData: Executes a Reader to yield an IEnumerable of the data retrieved. Only returns the first column.

CheckExistenceAsync: Checks if a Table exists.

CheckObjectExistenceAsync: Checks if an Object exists.