Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using NHibernate;
- using NHibernate.Criterion;
- using NHibernate.Linq;
- using NHibernateUnitOfWork;
- using Expression = System.Linq.Expressions.Expression;
- namespace NHibernateRepository
- {
- public class Repository<T> : IRepository<T>
- {
- protected virtual ISession Session
- {
- get { return UnitOfWork.CurrentSession; }
- }
- public Expression Expression
- {
- get { return Session.Query<T>().Expression; }
- }
- public Type ElementType
- {
- get { return Session.Query<T>().ElementType; }
- }
- public IQueryProvider Provider
- {
- get { return Session.Query<T>().Provider; }
- }
- public void Add(T entity)
- {
- Session.Save(entity);
- }
- public T Get(int id)
- {
- return Session.Get<T>(id);
- }
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.GetEnumerator();
- }
- public IEnumerator<T> GetEnumerator()
- {
- return Session.Query<T>().GetEnumerator();
- }
- public void Remove(T entity)
- {
- Session.Delete(entity);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement