internal static IEnumerable <T> GetDataObjects <T>(MySqlConnection ExistingConnection, string QueryString, Dictionary <string, object> Parameters = null, bool ThrowException = true, MySqlTransaction SqlTransaction = null) where T : DALBaseModel { return(RefinedResultsHelper.GetDataTable(ExistingConnection, QueryString, Parameters: Parameters, ThrowException: ThrowException, SqlTransaction: SqlTransaction) .AsEnumerable() .Select(x => x == null ? null : typeof(T).GetConstructors().Any(y => y.GetParameters().Length > 2) ? DatabaseCoreUtilities.CreateCreatorExpression <DataRow, string, bool, bool, T>()(x, null, false, false) : DatabaseCoreUtilities.CreateCreatorExpression <DataRow, string, T>()(x, null))); }
/// <summary> /// Converts an InternalId to an autonumbered row ID. /// </summary> /// <param name="ConfigConnectionString">The connection type to use.</param> /// <param name="Table">Table name to use for the conversion.</param> /// <param name="InternalId">The GUID of the InternalId to convert.</param> /// <returns>ID of the row matching the InternalId.</returns> internal static string GetIdFromInternalId(Enum ConfigConnectionString, string Table, string InternalId) { return(RefinedResultsHelper.GetScalar <string>(ConfigConnectionString, $"SELECT ID FROM {Table} WHERE InternalId = @InternalId", new Dictionary <string, object> { { "@InternalId", InternalId } })); }
/// <summary> /// Use the MySql built in function to get the ID of the last row inserted. /// </summary> /// <param name="ConfigConnectionString">The connection type to use when getting the last ID.</param> /// <returns>A string representation of the ID.</returns> internal static string GetLastInsertId(Enum ConfigConnectionString) { return(RefinedResultsHelper.GetScalar <string>(ConfigConnectionString, "SELECT LAST_INSERT_ID();")); }
internal static IEnumerable <T> GetDataList <T>(MySqlConnection ExistingConnection, string QueryString, Dictionary <string, object> Parameters = null, bool ThrowException = true, MySqlTransaction SqlTransaction = null) //where T : DALBaseModel { return(RefinedResultsHelper.GetDataTable(ExistingConnection, QueryString, Parameters: Parameters, ThrowException: ThrowException, SqlTransaction: SqlTransaction) .AsEnumerable() .Select(x => (T)DatabaseCoreUtilities.ConvertScalar <T>(x[0]))); }