Click here to Skip to main content
15,898,035 members
Articles / Programming Languages / C#

Save Log Information in Database with log4net and NHibernate

Rate me:
Please Sign up or sign in to vote.
4.50/5 (11 votes)
4 Feb 2010CPOL5 min read 91.7K   3.8K   44  
Using log4net to save data in database with help of NHibernate
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace HLogger
{
    public class HDbParameterCollection : IDataParameterCollection 
    {

        IList<HDbDataParameter> parameters = new List<HDbDataParameter>();

        #region IDataParameterCollection Members

        public bool Contains(string parameterName)
        {
            return parameterName.Contains(parameterName);
        }

        public int IndexOf(string parameterName)
        {
            throw new NotImplementedException("parameterName");
        }

        public void RemoveAt(string parameterName)
        {
            throw new NotImplementedException("parameterName");
        }

        public object this[string parameterName]
        {
            get
            {
                return (from p in parameters
                       where p.ParameterName == parameterName
                       select p).SingleOrDefault();
                       
            }
            set
            {
                throw new NotImplementedException("set Indexator");
            }
        }

        #endregion

        #region IList Members

        public int Add(object value)
        {
            parameters.Add(value as HDbDataParameter);
            return parameters.Count-1;
        }

        public void Clear()
        {
            throw new NotImplementedException("Clear");
        }

        public bool Contains(object value)
        {
            throw new NotImplementedException("Contains");
        }

        public int IndexOf(object value)
        {
            throw new NotImplementedException("IndexOf");
        }

        public void Insert(int index, object value)
        {
            throw new NotImplementedException("Insert");
        }

        public bool IsFixedSize
        {
            get { throw new NotImplementedException("IsFixedSize"); }
        }

        public bool IsReadOnly
        {
            get { throw new NotImplementedException("IsReadOnly"); }
        }

        public void Remove(object value)
        {
            throw new NotImplementedException("Remove");
        }

        public void RemoveAt(int index)
        {
            throw new NotImplementedException("RemoveAt");
        }

        public object this[int index]
        {
            get
            {
                throw new NotImplementedException("get this index");
            }
            set
            {
                throw new NotImplementedException("set this index");
            }
        }

        #endregion

        #region ICollection Members

        public void CopyTo(Array array, int index)
        {
            throw new NotImplementedException("Copy to");
        }

        public int Count
        {
            get 
            {
                return parameters.Count;
            }
        }

        public bool IsSynchronized
        {
            get { throw new NotImplementedException("IsSynchronized"); }
        }

        public object SyncRoot
        {
            get { throw new NotImplementedException("SyncRoot"); }
        }

        #endregion

        #region IEnumerable Members

        public System.Collections.IEnumerator GetEnumerator()
        {
            return parameters.GetEnumerator();
        }

        #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 (Senior) Nokia
Germany Germany
Interested in design/development of framework functionality using the best patterns and practices.

Comments and Discussions