Beispiel #1
0
 public static void RefreshItem <T>(this ISession session, T item) where T : class
 {
     if (session != null)
     {
         session.DeleteItem <T>();
         session.AddItem <T>(item);
     }
 }
Beispiel #2
0
 public static T GetItemLazy <T>(this ISession session) where T : class
 {
     if (session != null)
     {
         Type type = typeof(T);
         if (!session.Keys.Any(x => x == GetKey(type)))
         {
             T newType = Activator.CreateInstance <T>();
             session.AddItem(newType);
         }
         return(session.GetItem <T>());
     }
     return(null);
 }