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
862 B

using DealerSelection.Common.Exceptions;
using DealerSelection.Common.Interfaces.Data;
using System.Data.SqlClient;
namespace DealerSelection.Common.Data;
public abstract class RepositoryBaseDISync : RepositoryDIBase, IRepositoryDISync
{
public RepositoryBaseDISync(string cxnName) : base(cxnName)
{
}
public SqlConnection OpenCxnSync()
{
SqlConnection cxn = new SqlConnection(CxnString);
try
{
cxn.Open();
}
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;
}
}