/// <summary> /// Creates and adds the DB Parameter /// </summary> /// <param name="name">The parameter name</param> /// <param name="value">The parameter value</param> /// <param name="dbType">The data type of the parameter</param> /// <param name="isNullable">Optional parameter indicating if the value is nullable to set the DBNull object, defaults to false</param> /// <param name="parameter">Optionally injectible parameter object</param> public void AddParameter(string name, object value, MySqlDbType dbType, bool isNullable = false, IIpMySqlParameter parameter = null) { #region Validations var validators = new List <IIpValidator> { new IpRequiredStringValidator(name) }; if (!isNullable) { validators.Add(new IpRequiredObjectValidator(value)); } var exceptions = IpValidationHelper.Validate(validators); if (exceptions.Any()) { throw new IpDataAccessParameterException(string.Join(" | ", exceptions)); } #endregion try { parameter = parameter ?? new IpMySqlParameter(); parameter.CreateParameter(name, value, dbType, isNullable); Parameters.Add(parameter.DataParameter); } catch (Exception ex) { throw new IpDataAccessParameterException("An error occured creating the parameter", ex); } }
/// <summary> /// Gets the datalayer using the connection string from the config file /// </summary> /// <param name="connectionStringName">The connection string name</param> /// <param name="useDefault">If not provided, should it use the default provider name</param> /// <returns>An instantiated data layer of the provider type from the connection string</returns> public virtual IIpBaseDataLayer GetDataLayer(string connectionStringName, bool useDefault = false) { #region Validations var exceptions = IpValidationHelper.Validate(new List <IIpValidator> { new IpRequiredStringValidator(connectionStringName) }); if (exceptions.Any()) { throw new IpDataAccessException(string.Join(" | ", exceptions)); } #endregion var configHelper = new IpSettingsFactory().GetSettingsHelper((IIpConfigurationSettingsHelper)null); var connString = (ConnectionStringSettings)configHelper.GetSetting(IpArgument.GetConfigConnString(connectionStringName)); return(GetDataLayerByProvider(connString.ConnectionString, connString.ProviderName, useDefault)); }