|
using System;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
namespace ECommerceSystem.Repository
{
public interface IRepository<T>
{
void addItem(T item);
void removeItem(T item);
void updateItem(T item);
T getItemById(long item_id);
int getItemCount();
}
internal class NHibernateHelper
{
private NHibernateHelper()
{
Configuration cfg = new Configuration();
cfg.Configure();
sessionFactory = cfg.BuildSessionFactory();
new SchemaExport(cfg).Execute(false, true, false);
}
public static NHibernateHelper Create()
{
if (nHibHelper == null)
{
try
{
nHibHelper = new NHibernateHelper();
}
catch (Exception ex)
{
nHibHelper = null;
}
}
return nHibHelper;
}
public ISession Session
{
get { return sessionFactory.OpenSession(); }
}
ISessionFactory sessionFactory;
static NHibernateHelper nHibHelper;
}
}
|
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.