Hy
We heavily rely upon injection mechanism with Ninject. Currently we
struggle how to handle sessions. We read a lot about session
management and we want to implement session per business conversion.
We have a simple infrastructure like the following:
public class Repository<TEntity> : IRepository<TEntity>
where TEntity : class, IEntity
{
public Repository(ISession session)
{
this.Session = session;
}
protected ISession Session { get; private set; }
public TEntity FindBy(Guid key)
{
return this.Session.Get<TEntity>(key);
}
/// rest omitted
}
A consumer of a repo looks like the following:
public class Consumer {
public Consumer (Repository<SomeEntity> repo, ISession session)
public void DoSomeWork() {
using (var tx = session.BeginTransaction()) {
repo.FindBy(someId);
/// etc.
tx.Commit();
}
}
The ISession injected in the Repo instance is guaranteed to be the
same as the ISession in the consumer. We are building a little server
application which internally hosts several infrastructure services
which have the lifetime of the server process and some WCF endpoints.
As we are controlling milling machines the infrastructure services are
mainly here to control the creation and proper disposal of the
"software" machines and their state machines.
We were thinking about the following session management structure:
Infrastructure services: Session per Service
WCF endpoints: Session per OperationContext
Other components: ?
For some cases the WCF endpoints need to hook into the infrastructure
services. How would you handle the sessions there?
Any advice?
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.