Click here to Skip to main content
15,879,326 members
Home / Discussions / C#
   

C#

 
AnswerRe: Increase performance of csv Pin
Dave Kreskowiak19-Dec-13 3:14
mveDave Kreskowiak19-Dec-13 3:14 
AnswerRe: Increase performance of csv Pin
BillWoodruff19-Dec-13 3:23
professionalBillWoodruff19-Dec-13 3:23 
AnswerRe: Increase performance of csv Pin
Ennis Ray Lynch, Jr.19-Dec-13 3:33
Ennis Ray Lynch, Jr.19-Dec-13 3:33 
SuggestionRe: Increase performance of csv Pin
Richard Deeming19-Dec-13 3:43
mveRichard Deeming19-Dec-13 3:43 
AnswerRe: Increase performance of csv Pin
Eddy Vluggen19-Dec-13 7:57
professionalEddy Vluggen19-Dec-13 7:57 
AnswerRe: Increase performance of csv Pin
Mycroft Holmes19-Dec-13 12:03
professionalMycroft Holmes19-Dec-13 12:03 
AnswerRe: Increase performance of csv Pin
jschell19-Dec-13 14:15
jschell19-Dec-13 14:15 
QuestionNHibernate cascade delete not work Pin
LIttle_Cat19-Dec-13 1:30
LIttle_Cat19-Dec-13 1:30 
Hi,
have this
C#
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();
            }
      }

with one-to-many relationship.
And in my Repository class i define 2 methods for clear table. Full clear and remove one record by name.
C#
/** Удалить все */
            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());
            }

But,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 tables in relationship) stay at there places. Who dealed with this plz give me advice - how to remove all data from table?
Thanks.
AnswerRe: NHibernate cascade delete not work Pin
Eddy Vluggen19-Dec-13 8:00
professionalEddy Vluggen19-Dec-13 8:00 
GeneralRe: NHibernate cascade delete not work Pin
LIttle_Cat20-Dec-13 2:02
LIttle_Cat20-Dec-13 2:02 
Questionproblem with RDLC after deploying the application Pin
Jassim Rahma18-Dec-13 23:49
Jassim Rahma18-Dec-13 23:49 
AnswerRe: problem with RDLC after deploying the application Pin
Dave Kreskowiak19-Dec-13 1:15
mveDave Kreskowiak19-Dec-13 1:15 
Questionhow to set half Pixel size in C# Pin
sagar siripuram18-Dec-13 19:48
sagar siripuram18-Dec-13 19:48 
AnswerRe: how to set half Pixel size in C# Pin
BillWoodruff18-Dec-13 20:47
professionalBillWoodruff18-Dec-13 20:47 
GeneralRe: how to set half Pixel size in C# Pin
OriginalGriff18-Dec-13 21:09
mveOriginalGriff18-Dec-13 21:09 
GeneralRe: how to set half Pixel size in C# Pin
BillWoodruff19-Dec-13 0:24
professionalBillWoodruff19-Dec-13 0:24 
QuestionRe: how to set half Pixel size in C# Pin
GuyThiebaut18-Dec-13 22:01
professionalGuyThiebaut18-Dec-13 22:01 
AnswerRe: how to set half Pixel size in C# Pin
sagar siripuram19-Dec-13 0:20
sagar siripuram19-Dec-13 0:20 
GeneralRe: how to set half Pixel size in C# Pin
Richard MacCutchan19-Dec-13 1:18
mveRichard MacCutchan19-Dec-13 1:18 
GeneralRe: how to set half Pixel size in C# Pin
GuyThiebaut19-Dec-13 20:06
professionalGuyThiebaut19-Dec-13 20:06 
QuestionDeserialize dictionary with datacontractserializer c# Pin
Member 1047521718-Dec-13 8:35
professionalMember 1047521718-Dec-13 8:35 
AnswerRe: Deserialize dictionary with datacontractserializer c# Pin
BillWoodruff18-Dec-13 9:38
professionalBillWoodruff18-Dec-13 9:38 
QuestionHow to avoid compression options pop up box in avisaveoptions Pin
delphix518-Dec-13 8:13
delphix518-Dec-13 8:13 
QuestionHow Choice Avimanger compression from code Pin
delphix518-Dec-13 7:54
delphix518-Dec-13 7:54 
NewsRun SQL Scripts From C# Pin
Kevin Marois18-Dec-13 6:23
professionalKevin Marois18-Dec-13 6:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.