Skip to content

CRUDManager.cs

Muhand Jumah edited this page Oct 19, 2017 · 5 revisions

CRUDManager.cs

class in CRUDManager

Table of Contents

Description

The CRUDManager allows you to control your database with ease, the CRUDManager takes care of opening new connection and closing it, it takes care of garbage collection, etc… It’s so simple, that you only have to provide server information and then make calls to the appropriate functions, and the class will take care of the rest.

CRUDManager is a cross-platform API, any OS that supports .NET Standard will also be supported with this class.

Check Examples for more information.

Properties

Returns Property Description
bool IsDisposed Will return true if this object is disposed otherwise it will return false

Events

For EventArgs please refer to the Events Page

Event EventArgs Description
ConnectionOpenedSuccessfully Empty Once the database connection is opened successfully then this event will be raised
ConnectionFailedToOpen ConnectionFailedToOpenEventArgs If the connection fails to connect then this event will be raised
ConnectionClosedSuccessfully Empty Once the database connection is closed successfully then this event will be raised
ConnectionFailedToClose ConnectionFailedToCloseEventArgs If the connection fails to close then this event will be raised
CreatedSuccessfully Empty This event will be raised when insertion to the database is successful, use Create function to insert data to database
FailedToCreate FailedToCreateEventArgs This event will be raised when insertion to the database fails
ReadSuccessfully Empty This event will be raised when reading from a database was successful, use Read function to read data from database
FailedToRead FailedToReadEventArgs This event will be raised when reading from the database fails
UpdatedSuccessfully Empty This event will be raised when updating a database is successful, use Update function to update a database
FailedToUpdate FailedToUpdateEventArgs This event will be raised when updating a database fails
DeletedSuccessfully Empty This event will be raised when deleting a record from database was successful, use Delete function to delete a record from database
FailedToDelete FailedToDeleteEventArgs This event will be raised when deleting a record from database fails
CustomQueryExecutedSuccessfully Empty This event will be raised when executing a custom query is successful, use ExecuteCustomQuery function to execute a custom query
FailedToExecuteCustomQuery FailedToExecuteCustomQueryEventArgs This event will be raised when executing a custom query fails

Constructor(s)

Any non-standard parameter type can be found in the CRUDManager.Helpers section

Constructor Parameter(s) type(s) Description
CRUDManager ConnectionCredentials This constructor takes ConnectionCredentials as it parameter, this constructor will build the database information and initializes the connection to the database

Public Methods

Any non-standard parameter type can be found in the CRUDManager.Helpers section

Returns Method Parameter(s) type(s) Description
void Create string, Columns, Values This method inserts data into the database by taking 3 different parameters. The first parameter is of type string and this will be the table name to have the data inserted into, the 2nd parameter will be the columns names to insert data into and finally the values to insert into the columns
List<List<string>> Read string This method takes 1 parameter and this parameter is the table name to read from. This method will read the whole table and return a multidimensional list containing rows->columns
List<List<string>> Read string, params string[] This is an overloaded read method. This method takes 2 parameters, the first is the table name and the second will be an array of arguments containing names of columns to read from. This method will return a multidimensional list containing rows->columns. It’s important to keep in mind if the 2nd parameter is set to null then the method will read the entire table
List<List<string>> Read string, Field[] This is an overloaded read method. This method takes 2 parameters, the first is the table name and the second will be an array of conditions (Refer to CRUDManager.Helpers for more information regarding Field type) containing the conditions that must be met in order to read, e.g. reading a specific ID. This method will return a multidimensional list containing rows->columns.
List<List<string>> Read string, Field[], params string[] This is an overloaded read method. This method takes 3 parameters, the first is the table name. The second will be an array of conditions (Refer to CRUDManager.Helpers for more information regarding Field type) containing the conditions that must be met in order to read, e.g. reading a specific ID. The 3rd parameter is an array of arguments containing names of columns to read from. This method will return a multidimensional list containing rows->columns.
void Update string, Field[], Field[] This method takes 3 parameters. The first parameter is the table name to execute the update on. The 2nd parameter is an array of type Field, this will include the names of the columns and the values to be updated to. Finally, the 3rd parameters is also an array of type Field; however, this array will be the conditions in which must be met in order to proceed with the update (Please refer to CRUDManager.Helpers for more info on Field datatype)
void Update string, AssignmentList, AssignmentList This method takes 3 parameters. The first parameter is the table name to execute the update on. The 2nd parameter is of type AssignmentList, this will include the names of the columns and the values to be updated to. Finally, the 3rd parameters is also of type AssignmentList; however, this will be the conditions in which must be met in order to proceed with the update (Please refer to CRUDManager.AssignmentList for more info on Field datatype)
void Delete string, Field[] This method will delete a record from the database; This method takes in 2 parameters. The first parameter is the table name to delete from. The 2nd parameter is an array of type Field; These will be the conditions that must be met in order to proceed with the deletion (Refer to CRUDManager.Field for more information)
void Delete string, AssignmentList This method will delete a record from the database; This method takes in 2 parameters. The first parameter is the table name to delete from. The 2nd parameter is of type Assignment; AssignmentList will include the conditions that must be met in order to proceed with the deletion (Refer to CRUDManager.Assignment for more information)
void ExecuteCustomQuery string This method will execute a custom query that the developer will pass as a parameter, this function will execute the query using ExecuteNonQuery method by default
void ExecuteCustomQuery string, ExecutionOptions This method will execute a custom query that the developer will pass as a first parameter, as a second parameter the developer should pass ExecutionOptions (Refer to CRUDManager.Enumerations for more info on ExecutionOptions); It’s important to note that you should not pass =ExecuteReader= in this method as it will throw an exception; However, if you wish to use =ExecuteReader= then please use the next overloaded method
void ExecuteCustomQuery string, ExecutionOptions, out List<List<string>> This method will execute a custom query that the developer will pass as a first parameter, as a second parameter the developer should pass ExecutionOptions.ExecuteReader if the developer wishes to execute it using something other than ExecuteReader then please use one of the previous overloaded methods. The 3rd parameter will take a multidimensional string list, the method will write the read results to this list in the form of rows->columns.
Clone this wiki locally