My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System.Linq;
using NHibernate.Linq;

namespace Suteki.Common.Repositories
{
public class NHibernateRepository<T> : IRepository<T>, IRepository where T : class
{
protected readonly ISessionManager sessionManager;

public NHibernateRepository(ISessionManager sessionManager)
{
this.sessionManager = sessionManager;
}

public virtual T GetById(int id)
{
return sessionManager.OpenSession().Get<T>(id);
}

public virtual IQueryable<T> GetAll()
{
return sessionManager.OpenSession().Query<T>();
}

public virtual void SaveOrUpdate(T entity)
{
sessionManager.OpenSession().SaveOrUpdate(entity);
}

public virtual void DeleteOnSubmit(T entity)
{
sessionManager.OpenSession().Delete(entity);
}

object IRepository.GetById(int id)
{
return GetById(id);
}

IQueryable IRepository.GetAll()
{
return GetAll();
}

void IRepository.SaveOrUpdate(object entity)
{
SaveOrUpdate((T)entity);
}

void IRepository.DeleteOnSubmit(object entity)
{
DeleteOnSubmit((T)entity);
}
}
}

Change log

r507 by mikehadlow on Jun 26, 2011   Diff
Added simple facility to allow replies to
comments.
Go to: 
Project members, sign in to write a code review

Older revisions

r501 by mikehadlow on May 23, 2011   Diff
Removed NHibernateIntegration
Facility. Created a simple scheme for
session-per-web-request using
PerWebRequest lifestyle and a custom
ISessionManager.
r383 by mikehadlow on Aug 20, 2010   Diff
Web.config connection string is now
respected. Connection string removed
from Windsor.config.
Removed all references to
System.Data.Linq
...
r374 by mikehadlow on Apr 16, 2010   Diff
Changed to use NHibernate. Removed
Linq-to-SQL.
- Multi-tenanted functionality does
not work. I still need to change the
NHibernate Facility to support it.
...
All revisions of this file

File info

Size: 1361 bytes, 55 lines
Powered by Google Project Hosting