예제 #1
0
 public IList <Sales> Where(Expression <Func <Sales, bool> > con)
 {
     using (var session = FluentNHibernateHleper.GetSession())
     {
         return(session.Query <Sales>().Where(con).ToList());
     }
 }
예제 #2
0
 public IList <Purchase> GetAll()
 {
     using (var session = FluentNHibernateHleper.GetSession())
     {
         var all = session.Query <Purchase>().ToList();
         return(all);
     }
 }
예제 #3
0
 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);
     }
 }
예제 #4
0
 //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);
     }
 }
예제 #5
0
 //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);
     }
 }
예제 #6
0
 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();
         }
 }
예제 #7
0
 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();
         }
 }
예제 #8
0
 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();
             }
         }
 }
예제 #9
0
 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();
             }
         }
 }