Click here to Skip to main content
15,885,365 members
Articles / Web Development / ASP.NET

EHSDataCompliance Framework

Rate me:
Please Sign up or sign in to vote.
3.95/5 (13 votes)
5 Mar 2012CPOL13 min read 30.6K   281   8  
This article is about limiting the amount of codes a developer has to write in the DAC layer
#region DotNet Namespaces

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

#endregion

#region Custom Namespaces
using BEs.Person;
using BEs.Enums;

#region Namespaces from the EHS Framework

using EHS.CommonDataHelpers.Interfaces;
using EHS.DatabaseHelpers.SqlDatabaseHelper.DataHelpers;
using EHS.CommonDataHelpers.DataHelper.Data;
using EHS.CommonDataHelpers.DataHelper.DataHelpers;

#endregion

#endregion

namespace DLSql.PersonDAL
{
    public class PersonDAL : IDataAccessLayer<Person, People>
    {
        #region Implemented Methods

        public TransactionStatus Insert(Person dataObject)
        {
            StoredProcedure<Person> objSpInsert = new StoredProcedure<Person>();

            objSpInsert.ProcedureName = "SpPerson_Insert";
            objSpInsert.DataObject = dataObject;
            objSpInsert.SqlConnectionInfo.ConnectionType = (int)ConnectionType.NormalLogin;
            return objSpInsert.ExecuteNonQuery();

        }

        public TransactionStatus Update(Person dataObject)
        {
            throw new NotImplementedException();
        }

        public TransactionStatus Delete(Person dataObject)
        {
            throw new NotImplementedException();
        }

        public TransactionStatusWithData<People> GetAll()
        {
            People objPeople = new People();

            StoredProcedure<People> SpPerson_GetAll = new StoredProcedure<People>();                
      
            SpPerson_GetAll.ProcedureName = "SpPerson_GetAll";
            SpPerson_GetAll.DataObject = objPeople;
            SpPerson_GetAll.SqlConnectionInfo.ConnectionType = (int)ConnectionType.NormalLogin;
            return SpPerson_GetAll.ExecuteReader();
        }

        public TransactionStatusWithData<Person> GetById(Person dataObject)
        {
            StoredProcedure<Person> Sp_PersonGetById = new StoredProcedure<Person>();

            Sp_PersonGetById.ProcedureName = "Sp_PersonGetById";
            Sp_PersonGetById.DataObject = dataObject;
            Sp_PersonGetById.SqlConnectionInfo.ConnectionType = (int)ConnectionType.NormalLogin;

            return Sp_PersonGetById.ExecuteReader();
        }

        #endregion

        #region GetById

        public Person GetById(PersonGetByIdParams personGetByIdParams)
        {
            Person objPerson = new Person();

            StoredProcedure<Person> Sp_PersonGetById = new StoredProcedure<Person>();

            Sp_PersonGetById.ProcedureName = "Sp_PersonGetById";
            Sp_PersonGetById.DataObject = objPerson;
            Sp_PersonGetById.ConditionData = personGetByIdParams;
            Sp_PersonGetById.SqlConnectionInfo.ConnectionType = (int)ConnectionType.NormalLogin;

            Sp_PersonGetById.ExecuteReader();

            return objPerson;
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Informatics International (Pvt)Ltd
Sri Lanka Sri Lanka
Name : Eraj Hilary Shalindra Fernando
Email : hilary.shalindra@gmail.com

Comments and Discussions