From 9ee5a13b2bb8d38600e6206df1034ac834d559a6 Mon Sep 17 00:00:00 2001 From: Elanis Date: Thu, 24 Jun 2021 21:47:55 +0200 Subject: [PATCH] Added documentation --- Doc.md | 456 ++++++++++++++++++ Dysnomia.Common.SQL/DataTableHelper.cs | 7 +- Dysnomia.Common.SQL/DbHelper.cs | 46 +- Dysnomia.Common.SQL/DbNullHelper.cs | 12 +- Dysnomia.Common.SQL/DbReaderMapper.cs | 42 ++ .../Dysnomia.Common.SQL.csproj | 9 +- .../Dysnomia.Common.SteamWebAPI.xml | 171 +++++++ 7 files changed, 729 insertions(+), 14 deletions(-) create mode 100644 Doc.md create mode 100644 Dysnomia.Common.SQL/Dysnomia.Common.SteamWebAPI.xml diff --git a/Doc.md b/Doc.md new file mode 100644 index 0000000..bbd8c98 --- /dev/null +++ b/Doc.md @@ -0,0 +1,456 @@ + +# Dysnomia.Common.SQL + +## Contents + +- [DataTableHelper](#T-Dysnomia-Common-SQL-DataTableHelper 'Dysnomia.Common.SQL.DataTableHelper') + - [CreateDataTableFromObject\`\`1(myObject)](#M-Dysnomia-Common-SQL-DataTableHelper-CreateDataTableFromObject``1-``0- 'Dysnomia.Common.SQL.DataTableHelper.CreateDataTableFromObject``1(``0)') +- [DbHelper](#T-Dysnomia-Common-SQL-DbHelper 'Dysnomia.Common.SQL.DbHelper') + - [ExecStoredProcedure(connection,procName,parameters,transaction)](#M-Dysnomia-Common-SQL-DbHelper-ExecStoredProcedure-System-Data-IDbConnection,System-String,System-Collections-Generic-Dictionary{System-String,System-Object},System-Data-IDbTransaction- 'Dysnomia.Common.SQL.DbHelper.ExecStoredProcedure(System.Data.IDbConnection,System.String,System.Collections.Generic.Dictionary{System.String,System.Object},System.Data.IDbTransaction)') + - [ExecuteNonQuery(connection,sqlStatement,parameters,transaction)](#M-Dysnomia-Common-SQL-DbHelper-ExecuteNonQuery-System-Data-IDbConnection,System-String,System-Collections-Generic-Dictionary{System-String,System-Object},System-Data-IDbTransaction- 'Dysnomia.Common.SQL.DbHelper.ExecuteNonQuery(System.Data.IDbConnection,System.String,System.Collections.Generic.Dictionary{System.String,System.Object},System.Data.IDbTransaction)') + - [ExecuteQuery(connection,sqlStatement,parameters,transaction)](#M-Dysnomia-Common-SQL-DbHelper-ExecuteQuery-System-Data-IDbConnection,System-String,System-Collections-Generic-Dictionary{System-String,System-Object},System-Data-IDbTransaction- 'Dysnomia.Common.SQL.DbHelper.ExecuteQuery(System.Data.IDbConnection,System.String,System.Collections.Generic.Dictionary{System.String,System.Object},System.Data.IDbTransaction)') +- [DbNullHelper](#T-Dysnomia-Common-SQL-DbNullHelper 'Dysnomia.Common.SQL.DbNullHelper') + - [DbNullOrString(val)](#M-Dysnomia-Common-SQL-DbNullHelper-DbNullOrString-System-String- 'Dysnomia.Common.SQL.DbNullHelper.DbNullOrString(System.String)') + - [DbNullOrValue(val)](#M-Dysnomia-Common-SQL-DbNullHelper-DbNullOrValue-System-Object- 'Dysnomia.Common.SQL.DbNullHelper.DbNullOrValue(System.Object)') +- [DbReaderMapper](#T-Dysnomia-Common-SQL-DbReaderMapper 'Dysnomia.Common.SQL.DbReaderMapper') + - [GetBoolean()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetBoolean-System-Data-IDataReader,System-String,System-Boolean,System-Boolean- 'Dysnomia.Common.SQL.DbReaderMapper.GetBoolean(System.Data.IDataReader,System.String,System.Boolean,System.Boolean)') + - [GetDateTime()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetDateTime-System-Data-IDataReader,System-String,System-Boolean,System-DateTime- 'Dysnomia.Common.SQL.DbReaderMapper.GetDateTime(System.Data.IDataReader,System.String,System.Boolean,System.DateTime)') + - [GetDecimal()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetDecimal-System-Data-IDataReader,System-String,System-Boolean,System-Decimal- 'Dysnomia.Common.SQL.DbReaderMapper.GetDecimal(System.Data.IDataReader,System.String,System.Boolean,System.Decimal)') + - [GetDouble()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetDouble-System-Data-IDataReader,System-String,System-Boolean,System-Double- 'Dysnomia.Common.SQL.DbReaderMapper.GetDouble(System.Data.IDataReader,System.String,System.Boolean,System.Double)') + - [GetGuid()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetGuid-System-Data-IDataReader,System-String,System-Boolean,System-Guid- 'Dysnomia.Common.SQL.DbReaderMapper.GetGuid(System.Data.IDataReader,System.String,System.Boolean,System.Guid)') + - [GetGuid()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetGuid-System-Data-IDataReader,System-String,System-Boolean,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetGuid(System.Data.IDataReader,System.String,System.Boolean,System.String)') + - [GetGuid()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetGuid-System-Data-IDataReader,System-String,System-Boolean- 'Dysnomia.Common.SQL.DbReaderMapper.GetGuid(System.Data.IDataReader,System.String,System.Boolean)') + - [GetInt()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetInt-System-Data-IDataReader,System-String,System-Boolean,System-Int32- 'Dysnomia.Common.SQL.DbReaderMapper.GetInt(System.Data.IDataReader,System.String,System.Boolean,System.Int32)') + - [GetInt16()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetInt16-System-Data-IDataReader,System-String,System-Boolean,System-Int16- 'Dysnomia.Common.SQL.DbReaderMapper.GetInt16(System.Data.IDataReader,System.String,System.Boolean,System.Int16)') + - [GetInt32()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetInt32-System-Data-IDataReader,System-String,System-Boolean,System-Int32- 'Dysnomia.Common.SQL.DbReaderMapper.GetInt32(System.Data.IDataReader,System.String,System.Boolean,System.Int32)') + - [GetInt64()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetInt64-System-Data-IDataReader,System-String,System-Boolean,System-Int64- 'Dysnomia.Common.SQL.DbReaderMapper.GetInt64(System.Data.IDataReader,System.String,System.Boolean,System.Int64)') + - [GetLong()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetLong-System-Data-IDataReader,System-String,System-Boolean,System-Int64- 'Dysnomia.Common.SQL.DbReaderMapper.GetLong(System.Data.IDataReader,System.String,System.Boolean,System.Int64)') + - [GetNullableBoolean()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableBoolean-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableBoolean(System.Data.IDataReader,System.String)') + - [GetNullableDateTime()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableDateTime-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableDateTime(System.Data.IDataReader,System.String)') + - [GetNullableDecimal()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableDecimal-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableDecimal(System.Data.IDataReader,System.String)') + - [GetNullableDouble()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableDouble-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableDouble(System.Data.IDataReader,System.String)') + - [GetNullableGuid()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableGuid-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableGuid(System.Data.IDataReader,System.String)') + - [GetNullableInt()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableInt-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableInt(System.Data.IDataReader,System.String)') + - [GetNullableInt16()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableInt16-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableInt16(System.Data.IDataReader,System.String)') + - [GetNullableInt32()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableInt32-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableInt32(System.Data.IDataReader,System.String)') + - [GetNullableInt64()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableInt64-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableInt64(System.Data.IDataReader,System.String)') + - [GetNullableLong()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableLong-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableLong(System.Data.IDataReader,System.String)') + - [GetNullableShort()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableShort-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableShort(System.Data.IDataReader,System.String)') + - [GetNullableUInt()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableUInt-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableUInt(System.Data.IDataReader,System.String)') + - [GetNullableUInt16()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableUInt16-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableUInt16(System.Data.IDataReader,System.String)') + - [GetNullableUInt32()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableUInt32-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableUInt32(System.Data.IDataReader,System.String)') + - [GetNullableUInt64()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableUInt64-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableUInt64(System.Data.IDataReader,System.String)') + - [GetNullableULong()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableULong-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableULong(System.Data.IDataReader,System.String)') + - [GetNullableUShort()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetNullableUShort-System-Data-IDataReader,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetNullableUShort(System.Data.IDataReader,System.String)') + - [GetShort()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetShort-System-Data-IDataReader,System-String,System-Boolean,System-Int16- 'Dysnomia.Common.SQL.DbReaderMapper.GetShort(System.Data.IDataReader,System.String,System.Boolean,System.Int16)') + - [GetString()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetString-System-Data-IDataReader,System-String,System-Boolean,System-String- 'Dysnomia.Common.SQL.DbReaderMapper.GetString(System.Data.IDataReader,System.String,System.Boolean,System.String)') + - [GetUInt()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetUInt-System-Data-IDataReader,System-String,System-Boolean,System-UInt32- 'Dysnomia.Common.SQL.DbReaderMapper.GetUInt(System.Data.IDataReader,System.String,System.Boolean,System.UInt32)') + - [GetUInt16()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetUInt16-System-Data-IDataReader,System-String,System-Boolean,System-UInt16- 'Dysnomia.Common.SQL.DbReaderMapper.GetUInt16(System.Data.IDataReader,System.String,System.Boolean,System.UInt16)') + - [GetUInt32()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetUInt32-System-Data-IDataReader,System-String,System-Boolean,System-UInt32- 'Dysnomia.Common.SQL.DbReaderMapper.GetUInt32(System.Data.IDataReader,System.String,System.Boolean,System.UInt32)') + - [GetUInt64()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetUInt64-System-Data-IDataReader,System-String,System-Boolean,System-UInt64- 'Dysnomia.Common.SQL.DbReaderMapper.GetUInt64(System.Data.IDataReader,System.String,System.Boolean,System.UInt64)') + - [GetULong()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetULong-System-Data-IDataReader,System-String,System-Boolean,System-UInt64- 'Dysnomia.Common.SQL.DbReaderMapper.GetULong(System.Data.IDataReader,System.String,System.Boolean,System.UInt64)') + - [GetUShort()](#M-Dysnomia-Common-SQL-DbReaderMapper-GetUShort-System-Data-IDataReader,System-String,System-Boolean,System-UInt16- 'Dysnomia.Common.SQL.DbReaderMapper.GetUShort(System.Data.IDataReader,System.String,System.Boolean,System.UInt16)') + + +## DataTableHelper `type` + +##### Namespace + +Dysnomia.Common.SQL + + +### CreateDataTableFromObject\`\`1(myObject) `method` + +##### Summary + +Generates a datatable from an object + +##### Returns + + + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| myObject | [\`\`0](#T-``0 '``0') | | + +##### Generic Types + +| Name | Description | +| ---- | ----------- | +| T | Any type | + + +## DbHelper `type` + +##### Namespace + +Dysnomia.Common.SQL + + +### ExecStoredProcedure(connection,procName,parameters,transaction) `method` + +##### Summary + +Execute SQL stored procedure with reader as a result + +##### Returns + + + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| connection | [System.Data.IDbConnection](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Data.IDbConnection 'System.Data.IDbConnection') | Database connection | +| procName | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | Procedure to execute | +| parameters | [System.Collections.Generic.Dictionary{System.String,System.Object}](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Collections.Generic.Dictionary 'System.Collections.Generic.Dictionary{System.String,System.Object}') | Statement parameters | +| transaction | [System.Data.IDbTransaction](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Data.IDbTransaction 'System.Data.IDbTransaction') | (Optional) Transaction this statement should be in | + + +### ExecuteNonQuery(connection,sqlStatement,parameters,transaction) `method` + +##### Summary + +Execute SQL query without any result returned + +##### Returns + + + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| connection | [System.Data.IDbConnection](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Data.IDbConnection 'System.Data.IDbConnection') | Database connection | +| sqlStatement | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | Statement to execute | +| parameters | [System.Collections.Generic.Dictionary{System.String,System.Object}](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Collections.Generic.Dictionary 'System.Collections.Generic.Dictionary{System.String,System.Object}') | Statement parameters | +| transaction | [System.Data.IDbTransaction](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Data.IDbTransaction 'System.Data.IDbTransaction') | (Optional) Transaction this statement should be in | + + +### ExecuteQuery(connection,sqlStatement,parameters,transaction) `method` + +##### Summary + +Execute SQL query with reader as a result + +##### Returns + + + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| connection | [System.Data.IDbConnection](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Data.IDbConnection 'System.Data.IDbConnection') | Database connection | +| sqlStatement | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | Statement to execute | +| parameters | [System.Collections.Generic.Dictionary{System.String,System.Object}](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Collections.Generic.Dictionary 'System.Collections.Generic.Dictionary{System.String,System.Object}') | Statement parameters | +| transaction | [System.Data.IDbTransaction](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Data.IDbTransaction 'System.Data.IDbTransaction') | (Optional) Transaction this statement should be in | + + +## DbNullHelper `type` + +##### Namespace + +Dysnomia.Common.SQL + + +### DbNullOrString(val) `method` + +##### Summary + +Return string or DbNull if the string is null or empty + +##### Returns + + + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| val | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | | + + +### DbNullOrValue(val) `method` + +##### Summary + +Return value or DbNull if the value is null + +##### Returns + + + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| val | [System.Object](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Object 'System.Object') | | + + +## DbReaderMapper `type` + +##### Namespace + +Dysnomia.Common.SQL + + +### GetBoolean() `method` + +##### Parameters + +This method has no parameters. + + +### GetDateTime() `method` + +##### Parameters + +This method has no parameters. + + +### GetDecimal() `method` + +##### Parameters + +This method has no parameters. + + +### GetDouble() `method` + +##### Parameters + +This method has no parameters. + + +### GetGuid() `method` + +##### Parameters + +This method has no parameters. + + +### GetGuid() `method` + +##### Parameters + +This method has no parameters. + + +### GetGuid() `method` + +##### Parameters + +This method has no parameters. + + +### GetInt() `method` + +##### Parameters + +This method has no parameters. + + +### GetInt16() `method` + +##### Parameters + +This method has no parameters. + + +### GetInt32() `method` + +##### Parameters + +This method has no parameters. + + +### GetInt64() `method` + +##### Parameters + +This method has no parameters. + + +### GetLong() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableBoolean() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableDateTime() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableDecimal() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableDouble() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableGuid() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableInt() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableInt16() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableInt32() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableInt64() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableLong() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableShort() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableUInt() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableUInt16() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableUInt32() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableUInt64() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableULong() `method` + +##### Parameters + +This method has no parameters. + + +### GetNullableUShort() `method` + +##### Parameters + +This method has no parameters. + + +### GetShort() `method` + +##### Parameters + +This method has no parameters. + + +### GetString() `method` + +##### Parameters + +This method has no parameters. + + +### GetUInt() `method` + +##### Parameters + +This method has no parameters. + + +### GetUInt16() `method` + +##### Parameters + +This method has no parameters. + + +### GetUInt32() `method` + +##### Parameters + +This method has no parameters. + + +### GetUInt64() `method` + +##### Parameters + +This method has no parameters. + + +### GetULong() `method` + +##### Parameters + +This method has no parameters. + + +### GetUShort() `method` + +##### Parameters + +This method has no parameters. diff --git a/Dysnomia.Common.SQL/DataTableHelper.cs b/Dysnomia.Common.SQL/DataTableHelper.cs index d0085ae..9de7bcc 100644 --- a/Dysnomia.Common.SQL/DataTableHelper.cs +++ b/Dysnomia.Common.SQL/DataTableHelper.cs @@ -6,6 +6,12 @@ namespace Dysnomia.Common.SQL { public static class DataTableHelper { + /// + /// Generates a datatable from an object + /// + /// Any type + /// + /// public static DataTable CreateDataTableFromObject(T myObject) { Type type = typeof(T); var properties = type.GetProperties(); @@ -32,6 +38,5 @@ public static DataTable CreateDataTableFromObject(T myObject) { return dataTable; } - } } diff --git a/Dysnomia.Common.SQL/DbHelper.cs b/Dysnomia.Common.SQL/DbHelper.cs index 4b149fa..e22b3d8 100644 --- a/Dysnomia.Common.SQL/DbHelper.cs +++ b/Dysnomia.Common.SQL/DbHelper.cs @@ -28,9 +28,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE namespace Dysnomia.Common.SQL { public static class DbHelper { private static void BindParameters(this IDbCommand command, Dictionary parametersData) { - if(parametersData != null) { - foreach(KeyValuePair kvp in parametersData) { - if(kvp.Value is IDataParameter) { + if (parametersData != null) { + foreach (KeyValuePair kvp in parametersData) { + if (kvp.Value is IDataParameter) { command.Parameters.Add(kvp.Value); } else { var parameter = command.CreateParameter(); @@ -44,21 +44,29 @@ private static void BindParameters(this IDbCommand command, Dictionary + /// Execute SQL stored procedure with reader as a result + /// + /// Database connection + /// Procedure to execute + /// Statement parameters + /// (Optional) Transaction this statement should be in + /// public async static Task ExecStoredProcedure(this IDbConnection connection, string procName, Dictionary parameters = null, IDbTransaction transaction = null) { - using(IDbCommand command = connection.CreateCommand()) { + using (IDbCommand command = connection.CreateCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = procName; - if(transaction != null) { + if (transaction != null) { command.Transaction = transaction; } @@ -70,12 +78,20 @@ public async static Task ExecStoredProcedure(this IDbConnection con } } + /// + /// Execute SQL query with reader as a result + /// + /// Database connection + /// Statement to execute + /// Statement parameters + /// (Optional) Transaction this statement should be in + /// public async static Task ExecuteQuery(this IDbConnection connection, string sqlStatement, Dictionary parameters = null, IDbTransaction transaction = null) { - using(IDbCommand command = connection.CreateCommand()) { + using (IDbCommand command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = sqlStatement; - if(transaction != null) { + if (transaction != null) { command.Transaction = transaction; } @@ -87,12 +103,20 @@ public async static Task ExecuteQuery(this IDbConnection connection } } + /// + /// Execute SQL query without any result returned + /// + /// Database connection + /// Statement to execute + /// Statement parameters + /// (Optional) Transaction this statement should be in + /// public async static Task ExecuteNonQuery(this IDbConnection connection, string sqlStatement, Dictionary parameters = null, IDbTransaction transaction = null) { - using(IDbCommand command = connection.CreateCommand()) { + using (IDbCommand command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = sqlStatement; - if(transaction != null) { + if (transaction != null) { command.Transaction = transaction; } diff --git a/Dysnomia.Common.SQL/DbNullHelper.cs b/Dysnomia.Common.SQL/DbNullHelper.cs index cc7cad2..117025c 100644 --- a/Dysnomia.Common.SQL/DbNullHelper.cs +++ b/Dysnomia.Common.SQL/DbNullHelper.cs @@ -25,14 +25,24 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE namespace Dysnomia.Common.SQL { public static class DbNullHelper { + /// + /// Return string or DbNull if the string is null or empty + /// + /// + /// public static object DbNullOrString(this string val) { - if(string.IsNullOrEmpty(val)) { + if (string.IsNullOrEmpty(val)) { return DBNull.Value; } return val; } + /// + /// Return value or DbNull if the value is null + /// + /// + /// public static object DbNullOrValue(this object val) { return val ?? DBNull.Value; } diff --git a/Dysnomia.Common.SQL/DbReaderMapper.cs b/Dysnomia.Common.SQL/DbReaderMapper.cs index f855c1e..c8f92c7 100644 --- a/Dysnomia.Common.SQL/DbReaderMapper.cs +++ b/Dysnomia.Common.SQL/DbReaderMapper.cs @@ -51,6 +51,9 @@ public static Int16 GetInt16(this IDataReader reader, string key, bool catchNull return defaultValue; } + /** + * Short/Int16 from reader + */ public static short GetShort(this IDataReader reader, string key, bool catchNull = true, short defaultValue = 0) { return GetInt16(reader, key, catchNull, defaultValue); } @@ -68,6 +71,9 @@ public static short GetShort(this IDataReader reader, string key, bool catchNull return null; } + /** + * Nullable Short/Int16 from reader + */ public static short? GetNullableShort(this IDataReader reader, string key) { return GetNullableInt16(reader, key); } @@ -84,6 +90,9 @@ public static UInt16 GetUInt16(this IDataReader reader, string key, bool catchNu return defaultValue; } + /** + * UShort/UInt16 from reader + */ public static ushort GetUShort(this IDataReader reader, string key, bool catchNull = true, ushort defaultValue = 0) { return GetUInt16(reader, key, catchNull, defaultValue); } @@ -101,6 +110,9 @@ public static ushort GetUShort(this IDataReader reader, string key, bool catchNu return null; } + /** + * Nullable UShort/UInt16 from reader + */ public static ushort? GetNullableUShort(this IDataReader reader, string key) { return GetNullableUInt16(reader, key); } @@ -117,6 +129,9 @@ public static Int32 GetInt32(this IDataReader reader, string key, bool catchNull return defaultValue; } + /** + * Int/Int32 from reader + */ public static int GetInt(this IDataReader reader, string key, bool catchNull = true, int defaultValue = 0) { return GetInt32(reader, key, catchNull, defaultValue); } @@ -133,6 +148,9 @@ public static UInt32 GetUInt32(this IDataReader reader, string key, bool catchNu return defaultValue; } + /** + * UInt/UInt32 from reader + */ public static uint GetUInt(this IDataReader reader, string key, bool catchNull = true, uint defaultValue = 0) { return GetUInt32(reader, key, catchNull, defaultValue); } @@ -149,6 +167,9 @@ public static uint GetUInt(this IDataReader reader, string key, bool catchNull = return null; } + /** + * Nullable Int/Int32 from reader + */ public static int? GetNullableInt(this IDataReader reader, string key) { return GetNullableInt32(reader, key); } @@ -165,6 +186,9 @@ public static uint GetUInt(this IDataReader reader, string key, bool catchNull = return null; } + /** + * Nullable UInt/UInt32 from reader + */ public static uint? GetNullableUInt(this IDataReader reader, string key) { return GetNullableUInt32(reader, key); } @@ -181,6 +205,9 @@ public static Int64 GetInt64(this IDataReader reader, string key, bool catchNull return defaultValue; } + /** + * Long/Int64 from reader + */ public static long GetLong(this IDataReader reader, string key, bool catchNull = true, long defaultValue = 0) { return GetInt64(reader, key, catchNull, defaultValue); } @@ -197,6 +224,9 @@ public static UInt64 GetUInt64(this IDataReader reader, string key, bool catchNu return defaultValue; } + /** + * ULong/UInt64 from reader + */ public static ulong GetULong(this IDataReader reader, string key, bool catchNull = true, ulong defaultValue = 0) { return GetUInt64(reader, key, catchNull, defaultValue); } @@ -213,6 +243,9 @@ public static ulong GetULong(this IDataReader reader, string key, bool catchNull return null; } + /** + * Nullable Long/Int64 from reader + */ public static long? GetNullableLong(this IDataReader reader, string key) { return GetNullableInt64(reader, key); } @@ -229,6 +262,9 @@ public static ulong GetULong(this IDataReader reader, string key, bool catchNull return null; } + /** + * Nullable Long/Int64 from reader + */ public static ulong? GetNullableULong(this IDataReader reader, string key) { return GetNullableUInt64(reader, key); } @@ -349,9 +385,15 @@ public static Guid GetGuid(this IDataReader reader, string key, bool catchNull, return defaultValue; } + /** + * Guid + */ public static Guid GetGuid(this IDataReader reader, string key, bool catchNull, string guidData) { return GetGuid(reader, key, catchNull, Guid.Parse(guidData)); } + /** + * Guid + */ public static Guid GetGuid(this IDataReader reader, string key, bool catchNull = true) { return GetGuid(reader, key, catchNull, Guid.Empty); } diff --git a/Dysnomia.Common.SQL/Dysnomia.Common.SQL.csproj b/Dysnomia.Common.SQL/Dysnomia.Common.SQL.csproj index 95ed0b8..f8ffbdf 100644 --- a/Dysnomia.Common.SQL/Dysnomia.Common.SQL.csproj +++ b/Dysnomia.Common.SQL/Dysnomia.Common.SQL.csproj @@ -1,5 +1,4 @@  - netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;net5.0 Axel "Elanis" Soupé @@ -13,6 +12,8 @@ 1.0.0 1.0.0 1.0.0 + Dysnomia.Common.SteamWebAPI.xml + ..\Doc.md @@ -22,4 +23,10 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/Dysnomia.Common.SQL/Dysnomia.Common.SteamWebAPI.xml b/Dysnomia.Common.SQL/Dysnomia.Common.SteamWebAPI.xml new file mode 100644 index 0000000..5c10115 --- /dev/null +++ b/Dysnomia.Common.SQL/Dysnomia.Common.SteamWebAPI.xml @@ -0,0 +1,171 @@ + + + + Dysnomia.Common.SQL + + + + + Generates a datatable from an object + + Any type + + + + + + Execute SQL stored procedure with reader as a result + + Database connection + Procedure to execute + Statement parameters + (Optional) Transaction this statement should be in + + + + + Execute SQL query with reader as a result + + Database connection + Statement to execute + Statement parameters + (Optional) Transaction this statement should be in + + + + + Execute SQL query without any result returned + + Database connection + Statement to execute + Statement parameters + (Optional) Transaction this statement should be in + + + + + Return string or DbNull if the string is null or empty + + + + + + + Return value or DbNull if the value is null + + + + + + String from reader + + + Short/Int16 from reader + + + Short/Int16 from reader + + + Nullable Short/Int16 from reader + + + Nullable Short/Int16 from reader + + + UShort/UInt16 from reader + + + UShort/UInt16 from reader + + + Nullable UShort/UInt16 from reader + + + Nullable UShort/UInt16 from reader + + + Int/Int32 from reader + + + Int/Int32 from reader + + + UInt/UInt32 from reader + + + UInt/UInt32 from reader + + + Nullable Int/Int32 from reader + + + Nullable Int/Int32 from reader + + + Nullable UInt/UInt32 from reader + + + Nullable UInt/UInt32 from reader + + + Long/Int64 from reader + + + Long/Int64 from reader + + + ULong/UInt64 from reader + + + ULong/UInt64 from reader + + + Nullable Long/Int64 from reader + + + Nullable Long/Int64 from reader + + + Nullable Long/Int64 from reader + + + Nullable Long/Int64 from reader + + + Decimal from reader + + + Nullable Decimal from reader + + + Double from reader + + + Nullable Double from reader + + + Boolean from reader + + + Nullable Boolean from reader + + + DateTime from reader + + + Nullable DateTime from reader + + + Guid + + + Guid + + + Guid + + + Nullable Guid + + +