public IList <Sales> Where(Expression <Func <Sales, bool> > con) { using (var session = FluentNHibernateHleper.GetSession()) { return(session.Query <Sales>().Where(con).ToList()); } }
public IList <Purchase> GetAll() { using (var session = FluentNHibernateHleper.GetSession()) { var all = session.Query <Purchase>().ToList(); return(all); } }
public ICollection <Purchase> GetById(int key) { using (var session = FluentNHibernateHleper.GetSession()) { var a = session.CreateCriteria(typeof(Purchase)).Add(Restrictions.Eq("Id", key)).List <Purchase>(); return(a); } }
//Lay 1 mang Id trong CSDL public int[] GetId() { using (var session = FluentNHibernateHleper.GetSession()) { int[] id_s = session.Query <Sales>().Select(c => c.Id).ToArray(); return(id_s); } }
//Lay danh sach theo Id su dung HQL public IList <Sales> GetListbyId(int key) { using (var session = FluentNHibernateHleper.GetSession()) { var query = session.CreateQuery("FROM Sales Where Id='" + key + "'"); IList <Sales> listsales = query.List <Sales>(); return(listsales); } }
public void Delete(int key) { using (var session = FluentNHibernateHleper.GetSession()) using (ITransaction tran = session.BeginTransaction()) { var query = session.CreateQuery("Delete From Sales Where Id='" + key + "'") .ExecuteUpdate(); tran.Commit(); session.Close(); } }
public void Delete() { using (var session = FluentNHibernateHleper.GetSession()) using (ITransaction transaction = session.BeginTransaction()) { var query = session.CreateSQLQuery("SELECT 1 WHILE @@ROWCOUNT > 0" + " BEGIN DELETE TOP(10000) FROM Sales " + "END").ExecuteUpdate(); transaction.Commit(); session.Close(); } }
public void Delete(Purchase p) { using (var session = FluentNHibernateHleper.GetSession()) using (ITransaction tran = session.BeginTransaction()) { try { session.Delete(p); tran.Commit(); } catch (Exception) { tran.Rollback(); } finally { session.Close(); } } }
public void Update(Sales s) { using (var session = FluentNHibernateHleper.GetSession()) using (ITransaction transaction = session.BeginTransaction()) { try { session.Update(s); transaction.Commit(); } catch (Exception) { transaction.Rollback(); } finally { session.Close(); } } }