Пример #1
0
        public static IList <T> RetrieveAll()
        {
            IList <T> theList = new List <T>();

            using (var session = new CoreDAO <T>().GetSession())
            {
                using (var trans = session.BeginTransaction())
                {
                    theList = session.Query <T>().ToList();
                    trans.Commit();
                }
            }

            return(theList);
        }
Пример #2
0
 public T Retrieve(long id)
 {
     try
     {
         T result;
         //var result = (T)new object();
         using (ISession session = new CoreDAO <T>().GetSession())
         {
             result = session.Get <T>(id);
         }
         return(result);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
 }
Пример #3
0
 public static void Save(T obj)
 {
     try
     {
         using (ISession session = new CoreDAO <T>().GetSession())
         {
             using (ITransaction transaction = session.BeginTransaction())
             {
                 session.Save(obj);
                 transaction.Commit();
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
 }