Exemplo n.º 1
0
 public void EvictProperties(Parent Entity) {
     using (ISession Session = m_SessionFactory.OpenSession())
     {
         Type EntityType = Entity.GetType();
         PropertyInfo[] properties = EntityType.GetProperties();
         foreach (PropertyInfo Property in properties)
         {
             if (Property.PropertyType.Name.Equals("IList`1"))
             {
                 IList List = (IList)Property.GetValue(Entity, null);
                 foreach (Parent Item in List)
                 {
                     this.EvictProperties(Item);
                     Session.Evict(Item);
                     ((Parent)Item).ID = HelperNHibernate.GenerateID();
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 public static Parent Copy(Parent Entity)
 {
     Parent Copy = null;
     using (ISession Session = m_SessionFactory.OpenSession())
     {
         EvictProperties(Entity);
         Session.Evict(Entity);
         //Entity.ID = GenerateID();
         Copy = (Parent)Session.Merge(Entity);
         Copy.ID = GenerateID();
     }
     return Copy;
 }