123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- using System;
- using System.Collections.Generic;
- using NHibernate;
- using WhiteNoise.Domain.Abstract;
- namespace WhiteNoise.Domain.Concrete
- {
-
-
-
- public abstract class DbRepository<T> : IRepository<T>
- {
-
-
-
- private readonly ISession _session;
-
-
-
-
-
-
-
- public DbRepository(ISession session)
- {
- this._session = session;
- }
- #region IRepository[T] implementation
-
-
-
-
-
-
-
- public T Add(T member)
- {
- using (ITransaction transaction = this._session.BeginTransaction())
- {
- this._session.Save(member);
- transaction.Commit();
- }
-
- return member;
- }
-
-
-
-
-
-
-
- public T Find(int id)
- {
- return this._session.Get<T>(id);
- }
-
-
-
-
-
-
-
- public T Remove(T member)
- {
- using (ITransaction transaction = this._session.BeginTransaction())
- {
- this._session.Delete(member);
- transaction.Commit();
- }
-
- return member;
- }
-
-
-
-
-
-
-
- public T Update(T member)
- {
- using (ITransaction transaction = this._session.BeginTransaction())
- {
- this._session.Update(member);
- transaction.Commit();
- }
-
- return member;
- }
-
-
-
-
-
-
-
- public IList<T> Collection
- {
- get
- {
- throw new NotImplementedException();
-
- }
- }
-
- #endregion
- }
- }
|