The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Bug in generated entity with foreign key when using INotifyPropertyChanged?

Last post 04-21-2008, 11:18 AM by marke. 2 replies.
Sort Posts: Previous Next
  •  04-21-2008, 10:30 AM 8951

    Bug in generated entity with foreign key when using INotifyPropertyChanged?

    I found what I believe is bug with the code generation template for a C# entity. It is subtle. The basic idea is that two lines need to be switched in the order for the generation.

    DB model:

    • Book table.
      • Int ID
    • Reference table.
      • Int ID
      • Int RefBookID (foreign key to Book table)

    The generation options: (most relevant are in bold)

    • Generate single file
    • Target Multiple Databases
    • Metadata class should ignore schema
    • Metadata class should ignore catalog
    • Generate Hierarchical Model
    • Support INotifyPropertyChanged

     

    The resulting generated code.

     

    Code:
    1    virtual public System.Int32? RefBookID
    2 {
    3 get 4 {
    5 [...]
    6 }
    7
    8 set 9 {
    10 if(base.SetSystemInt32(BookMetadata.ColumnNames.ShareSurveyID, value))
    11 {
    12 this._UpToBookByRefBookID = null;
    13 this.OnPropertyChanged("UpToBookByRefBookID");
    14 this.MarkFieldAsModified(BookMetadata.ColumnNames.RefBookID);
    15 if (PropertyChanged != null)
    16 {
    17 PropertyChanged(this, new PropertyChangedEventArgs(BookMetadata.PropertyNames.RefBookID));
    18 }
    19 }
    20 }
    21 }
    22

     

    The issue is that Line 13 comes before Line 14. The problem with this is that a binding source may be notified that a change has occurred before the object itself knows that there was a change. The "this.es.IsDirty" will return false when on line 14 but events will already have fired.

    The fix is just to generate line 14 before line 13. When I hand changed my generated class and tested it I got behavior I expected.

    I hope this is enough information to explain the issue.

    -Mark E.
     

  •  04-21-2008, 10:33 AM 8952 in reply to 8951

    Re: Bug in generated entity with foreign key when using INotifyPropertyChanged?

    Good catch, we will fix it.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  04-21-2008, 11:18 AM 8953 in reply to 8952

    Re: Bug in generated entity with foreign key when using INotifyPropertyChanged?

    Mike.Griffin:
    Good catch, we will fix it.

     
    Thanks! 

View as RSS news feed in XML