EchoTex_Payroll/Ease.Core/DataAccess/Sql/SqlFactory.cs

56 lines
2.0 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
/*
|-------------------------------------------------------------------------------|
| Copyright © Computer Ease Limited |
| Address: 1/9 Bloack-A Lalmatia, Dhaka-1207, Bangladesh |
| Email: info@celimited.com, cease@bol-online.com, web: www.celimited.com |
| Unauthorized copy or distribution is strictly prohibited |
| Source: UIP |
| Author: S. M. Russel, Last modified date: 23/07/2012 |
|-------------------------------------------------------------------------------|
*/
using System;
using System.Data;
using Ease.Core.Utility;
using System.Collections;
using System.Configuration;
using Microsoft.Data.SqlClient;
namespace Ease.Core.DataAccess.SQL
{
#region DataAccess: SQL Connection Factory
/// <summary>
/// Summary description for SQLFactory.
/// </summary>
public sealed class SqlFactory : ConnectionFactory
{
/// <summary>
/// Create an instance of IDbConnection for MS SQL using default connectionstring.
/// </summary>
/// <returns>Retuen an instance of IDbConnection for MS SQL.</returns>
public override System.Data.IDbConnection CreateConnection()
{
return new SqlConnection(base.ConnectionNode.ConnectionString);
}
/// <summary>
/// Create an instance of IDbConnection for MS SQL using ConnectionContext.
/// </summary>
/// <param name="context">Valid ConnectionContext.</param>
/// <returns>Return instatnce of IDbConnection for MS SQL.</returns>
public override System.Data.IDbConnection CreateConnection(ConnectionContext context)
{
if (context == null || context.ContextKey.Length <= 0)
throw new Exception("There is no key in the Connection Context");
return new SqlConnection(ConnectionFactory.ContextConnection(context).ConnectionNode.ConnectionString);
}
internal SqlFactory()
{
}
}
#endregion
}