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

JohnKenedy Data Access Layer Library

Rate me:
Please Sign up or sign in to vote.
3.42/5 (12 votes)
10 Jul 2008GPL37 min read 51.8K   1.1K   48  
This is a .NET 3.5 library that acts as Data Access Layer with many automatic features
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace JohnKenedy.DataAccessModule
{
    [Serializable]
    public class ModuleExtendDefinition
    {
        #region Properties
        protected int _Index;
        public int Index
        {
            get
            {
                return _Index;
            }
            set
            {
                _Index = value;
            }
        }

        protected string _ModuleName;
        public virtual string ModuleName
        {
            get
            {
                return _ModuleName;
            }
            set
            {
                _ModuleName = value;
            }
        }

        protected IDictionary<string, string> _RolenameAndTable = new Dictionary<string, string>();
        public virtual IDictionary<string, string> RolenameAndTable
        {
            get
            {
                return _RolenameAndTable;
            }
        }
        #endregion

        public ModuleExtendDefinition()
        {
        }

        public string GetTableRole(string _tableName)
        {
            if (_RolenameAndTable == null || _RolenameAndTable.Count <= 0) return "";
            if (_RolenameAndTable.ContainsKey(_tableName)) return "";
            return _RolenameAndTable[_tableName];
        }

        public virtual string GetModuleExtension(string _tableName)
        {
            return "";
        }

        public virtual string GetModuleCollectionExtension(string _tableName)
        {
            return "";
        }

        public DataTable GetRoleTable()
        {
            DataTable _data = new DataTable();
            _data.Columns.Add("Rolename", typeof(string));
            _data.Columns.Add("Tablename", typeof(string));
            
            foreach (KeyValuePair<string, string> _pair in _RolenameAndTable)
            {
                DataRow _row = _data.NewRow();
                _row["Rolename"] = _pair.Key;
                _row["Tablename"] = _pair.Value;
                _data.Rows.Add(_row);
            }
            _data.AcceptChanges();
            return _data;
        }

        public void SetRoleTable(DataTable _datatable)
        {
            _RolenameAndTable.Clear();
            foreach (DataRow _row in _datatable.Rows)
            {
                string _key = _row["Rolename"].ToString();
                string _value = _row["Tablename"].ToString();
                _RolenameAndTable.Add(_key, _value);
            }
        }
    }
}

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 GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
Singapore Singapore
I write code mostly in C#, VB.NET, PHP and Assembly.

Comments and Discussions