Help please.
Have this

public class RecipsMap : ClassMap<Data.Database.Recipe>
      {
            public RecipsMap()
            {
                  this.Table("Recipe");
                  this.Id(x => 
x.Id).GeneratedBy.Native().Column("Id").UnsavedValue(0);
                  this.Map(x => x.Name).Not.Nullable().Length(50).Unique();
                  this.Map(x => x.Description).Nullable();
                  this.Map(x => x.Span);
                  this.HasMany<Data.Database.Temperature>(x => 
x.Temperatures).Table("Temperature").Inverse().Cascade.AllDeleteOrphan();
                  this.HasMany<Data.Database.LampControl>(x => 
x.LampControls).Table("LampControl").Inverse().Cascade.AllDeleteOrphan();
            }
      }



and in repository

           /** Удалить все */
            public void Delete()
            {
                  var metadata = 
this._sessionFactory.GetClassMetadata(typeof(T)) as 
NHibernate.Persister.Entity.AbstractEntityPersister;
                  string table = metadata.TableName;

                  using (var session = this._sessionFactory.OpenSession())
                  {
                        using (var transaction = session.BeginTransaction())
                        {
                              string deleteAll = string.Format("DELETE FROM 
\"{0}\"", table);
                              session.CreateQuery(deleteAll).ExecuteUpdate();
                              transaction.Commit();
                        }
                  }

                  /** сообщим коллбэку что данные изменены */
                  this.OnOnDataChange(this.Get());
            }


            /** Удалить по имени */
            public void Delete(string name)
            {
                  using (var session = this._sessionFactory.OpenSession())
                  {
                        using (var transaction = session.BeginTransaction())
                        {
                              T recipe = 
session.QueryOver<T>().Where(Restrictions.Eq("Name", name)).SingleOrDefault();
                              session.Delete(recipe);
                              transaction.Commit();
                        }
                  }

                  /** сообщим коллбэку что данные изменены */
                  this.OnOnDataChange(this.Get());
            }


trouble is that data are not deleting cascadely in first case "delete all", 
but everything is deleting while deleting separate object in second case. 
If selecting by name as here - all right, if delete all - only recipe table 
is removing and all other (temperatures and LampControl) stay at there 
places. Who dealed with this plz give me advice - hoe to remove all data 
from table?
thnks

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to