You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
889 B
35 lines
889 B
using DealerSelection.Common.Exceptions;
|
|
using DealerSelection.Common.Interfaces.Data;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace DealerSelection.Common.Data;
|
|
|
|
public abstract class RepositoryBaseDIAsync : RepositoryDIBase, IRepositoryDIAsync
|
|
{
|
|
public RepositoryBaseDIAsync(string cxnName) : base(cxnName)
|
|
{
|
|
|
|
}
|
|
|
|
public async Task<SqlConnection> OpenCxnAsync()
|
|
{
|
|
SqlConnection cxn = new SqlConnection(CxnString);
|
|
try
|
|
{
|
|
await cxn.OpenAsync();
|
|
}
|
|
catch (SqlException ex)
|
|
{
|
|
foreach(SqlError error in ex.Errors)
|
|
{
|
|
if(error.Number == 53)
|
|
{
|
|
throw new DbConnectionException($"DB Connection error for CxnString: {CxnString}. Exception: {ex}");
|
|
}
|
|
}
|
|
throw;
|
|
}
|
|
|
|
return cxn;
|
|
}
|
|
}
|