locked
ignore additional client side properties RRS feed

  • Question

  • Hi,

    the client side auto-generated classes for entities retreived by a WCF DataService are partial classes. So they can be extended on client side. This works fine for methods and functions.

    But if I create an additional property, that is only used on client side, the property and it's value is sent to the server when saving changes. This causes an error on server side stating that this property name is invalid for the entity type.

    Is there any way to suppress the submission of the client side property?

    Regards,
    Nico

    Example:

    This is the auto-generated class representing the type in the data source:

    public partial class Person : global::System.ComponentModel.INotifyPropertyChanged
    
    {
    
     public string FirstName
    
     {
    
     get
    
     {
    
      return this._FirstName;
    
     }
    
     set
    
     {
    
      this.OnFirstNameChanging(value);
    
      this._FirstName = value;
    
      this.OnFirstNameChanged();
    
      this.OnPropertyChanged("FirstName");
    
     }
    
     }
    
     public string LastName
    
     {
    
     get
    
     {
    
      return this._LastName;
    
     }
    
     set
    
     {
    
      this.OnFirstNameChanging(value);
    
      this._LastName = value;
    
      this.OnFirstNameChanged();
    
      this.OnPropertyChanged("LastName");
    
     }
    
     }
    
    }
    
    

    This is my extension:

    public partial class Person
    
    {
    
     public string FullName
    
     {
    
     get
    
     {
    
      return this.FirstName + " " + this.LastName;
    
     }
    
     set
    
     {
    
     }
    
     }
    
    }
    
    

    Calling SaveChanges() causes an exception saying that the property "FullName" is invalid for the type "Person".

    Wednesday, December 15, 2010 3:47 PM

Answers

  • Hi,

    If you make the property internal (not public), the SaveChange will ignore it.

    Thanks,


    Vitek Karas [MSFT]
    Wednesday, December 15, 2010 4:40 PM
    Moderator

All replies

  • Hi,

    If you make the property internal (not public), the SaveChange will ignore it.

    Thanks,


    Vitek Karas [MSFT]
    Wednesday, December 15, 2010 4:40 PM
    Moderator
  • Hey Vitek,

    thank you for your quick reply.

    I'm not sure, but internal properties cannot be used in UI binding, right?

    Nico

    Thursday, December 16, 2010 3:42 PM