none
Exception when using ICollectionView.SortDescriptions.Add with a property on an EntityRef within an EntitySet RRS feed

  • Question

  • I have a LINQ to SQL dbml file that has a few entities that I dragged n dropped out of my server explorer.

    A Licensee has an EntitySet of License entities.  A License has an EntityRef to the Dog that the license is for.  The Dog has a Name property.

    Next I attempt the following code.

    Licensee lee; //Comes from my BLL
    
    ICollectionView cvw = CollectionViewSource.GetDefaultView(lee.Licenses);
    
    cvw.SortDescriptions.Add(new SortDescription("Dog.Name", ListSortDirection.Ascending));
    
    
    

    The last statement causes a System.NullReferenceException: Object reference not set to an instance of an object.

    This does work.

    Licensee lee; //Comes from my BLL
    
    List<License> lst = new List<License>();
    
    foreach (BLL.License lic in lee.Licenses)
    {
      lst.Add(lic);
    }
    
    ICollectionView cvw = CollectionViewSource.GetDefaultView(lst);
    
    cvw.SortDescriptions.Add(new SortDescription("Dog.Name", ListSortDirection.Ascending));
    

    This also works.

    partial class License
    {
      string DogName {
        get
        {
          return this.Dog.Name;
        }
      }
    }
    
    Licensee lee; //Comes from my BLL
    
    ICollectionView cvw = CollectionViewSource.GetDefaultView(lee.Licenses);
    
    //Use the custom property in the partial class instead of Dog.Name
    cvw.SortDescriptions.Add(new SortDescription("DogName", ListSortDirection.Ascending));
    

    So it looks like it is the combination of sorting an EntitySet on a property of an EntityRef.  Either by themselves do not cause the problem.

    Is there a workaround or is this by design?

    Friday, August 13, 2010 5:30 PM

Answers

All replies

  • Hi Chris,

     

    I suggest you first make a judgment to make sure “lee” is set to an instance of an entity but not null before using “lee.Licenses” to get its all Licenses. For example:

    if (lee == null)
    {
      MessageBox.Show("Error!");
    }
    else 
    { 
      ICollectionView cvw = CollectionViewSource.GetDefaultView(lee.Licenses);   
      cvw.SortDescriptions.Add(new SortDescription("Dog.Name", ListSortDirection.Ascending));
    }
    
    



    Second, please make sure the value of all the Dog property for every License is not null when you use the Dog.Name property.

     

    And could you please post the defination of the Licensee and License class or give us a repro sample ?

     

     

    Best regards,

    Alex Liang

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, August 16, 2010 7:52 AM
    Moderator
  • First, lee is not null.  Even if it was null, that would not explain why my two alternative code samples do work. (the code sample that uses System.Collections.Generic.List in place of EntitySet and the code sample that uses a custom property in place of Dog.Name)

    Second, I have tried looping through each License and assigning the Dog.Name property to a string variable to ensure that the Dog property is not null and that all the license entities are loaded by LINQ.  Even if the Dog property was null, that also would not explain why my two alternative codes samples do work.

    I am using the same data sample for all three of my code samples.  The first code sample throws an exception.  The other two do not.

    Monday, August 16, 2010 1:11 PM
  • Here is the autogenerated class definition from the dbml designer for License.

    	
    	[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.License")]
    	public partial class License : INotifyPropertyChanging, INotifyPropertyChanged
    	{
    		
    		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
    		
    		private int _LicenseId;
    		
    		private int _LicenseeId;
    		
    		private int _LicenseSubtypeId;
    		
    		private string _Number;
    		
    		private decimal _Cost;
    		
    		private decimal _IssuerFee;
    		
    		private decimal _ThirdPartyProcessingFee;
    		
    		private decimal _Total;
    		
    		private System.DateTime _Issued;
    		
    		private System.DateTime _Effective;
    		
    		private System.Nullable<System.DateTime> _Expires;
    		
    		private int _CostCategoryId;
    		
    		private bool _IsVoid;
    		
    		private System.Nullable<int> _DogId;
    		
    		private string _Location;
    		
    		private string _Notes;
    		
    		private string _PermitNumber;
    		
    		private System.Nullable<System.DateTime> _Drawing;
    		
    		private string _NumberOfChances;
    		
    		private string _PricePerChance;
    		
    		private EntityRef<CostCategory> _CostCategory;
    		
    		private EntityRef<Dog> _Dog;
    		
    		private EntityRef<LicenseSubtype> _LicenseSubtype;
    		
    		private EntityRef<Licensee> _Licensee;
    		
      #region Extensibility Method Definitions
      partial void OnLoaded();
      partial void OnValidate(System.Data.Linq.ChangeAction action);
      partial void OnCreated();
      partial void OnLicenseIdChanging(int value);
      partial void OnLicenseIdChanged();
      partial void OnLicenseeIdChanging(int value);
      partial void OnLicenseeIdChanged();
      partial void OnLicenseSubtypeIdChanging(int value);
      partial void OnLicenseSubtypeIdChanged();
      partial void OnNumberChanging(string value);
      partial void OnNumberChanged();
      partial void OnCostChanging(decimal value);
      partial void OnCostChanged();
      partial void OnIssuerFeeChanging(decimal value);
      partial void OnIssuerFeeChanged();
      partial void OnThirdPartyProcessingFeeChanging(decimal value);
      partial void OnThirdPartyProcessingFeeChanged();
      partial void OnTotalChanging(decimal value);
      partial void OnTotalChanged();
      partial void OnIssuedChanging(System.DateTime value);
      partial void OnIssuedChanged();
      partial void OnEffectiveChanging(System.DateTime value);
      partial void OnEffectiveChanged();
      partial void OnExpiresChanging(System.Nullable<System.DateTime> value);
      partial void OnExpiresChanged();
      partial void OnCostCategoryIdChanging(int value);
      partial void OnCostCategoryIdChanged();
      partial void OnIsVoidChanging(bool value);
      partial void OnIsVoidChanged();
      partial void OnDogIdChanging(System.Nullable<int> value);
      partial void OnDogIdChanged();
      partial void OnLocationChanging(string value);
      partial void OnLocationChanged();
      partial void OnNotesChanging(string value);
      partial void OnNotesChanged();
      partial void OnPermitNumberChanging(string value);
      partial void OnPermitNumberChanged();
      partial void OnDrawingChanging(System.Nullable<System.DateTime> value);
      partial void OnDrawingChanged();
      partial void OnNumberOfChancesChanging(string value);
      partial void OnNumberOfChancesChanged();
      partial void OnPricePerChanceChanging(string value);
      partial void OnPricePerChanceChanged();
      #endregion
    		
    		public License()
    		{
    			this._CostCategory = default(EntityRef<CostCategory>);
    			this._Dog = default(EntityRef<Dog>);
    			this._LicenseSubtype = default(EntityRef<LicenseSubtype>);
    			this._Licensee = default(EntityRef<Licensee>);
    			OnCreated();
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_LicenseId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
    		public int LicenseId
    		{
    			get
    			{
    				return this._LicenseId;
    			}
    			set
    			{
    				if ((this._LicenseId != value))
    				{
    					this.OnLicenseIdChanging(value);
    					this.SendPropertyChanging();
    					this._LicenseId = value;
    					this.SendPropertyChanged("LicenseId");
    					this.OnLicenseIdChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_LicenseeId", DbType="Int NOT NULL")]
    		public int LicenseeId
    		{
    			get
    			{
    				return this._LicenseeId;
    			}
    			set
    			{
    				if ((this._LicenseeId != value))
    				{
    					if (this._Licensee.HasLoadedOrAssignedValue)
    					{
    						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
    					}
    					this.OnLicenseeIdChanging(value);
    					this.SendPropertyChanging();
    					this._LicenseeId = value;
    					this.SendPropertyChanged("LicenseeId");
    					this.OnLicenseeIdChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_LicenseSubtypeId", DbType="Int NOT NULL")]
    		public int LicenseSubtypeId
    		{
    			get
    			{
    				return this._LicenseSubtypeId;
    			}
    			set
    			{
    				if ((this._LicenseSubtypeId != value))
    				{
    					if (this._LicenseSubtype.HasLoadedOrAssignedValue)
    					{
    						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
    					}
    					this.OnLicenseSubtypeIdChanging(value);
    					this.SendPropertyChanging();
    					this._LicenseSubtypeId = value;
    					this.SendPropertyChanged("LicenseSubtypeId");
    					this.OnLicenseSubtypeIdChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Number", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
    		public string Number
    		{
    			get
    			{
    				return this._Number;
    			}
    			set
    			{
    				if ((this._Number != value))
    				{
    					this.OnNumberChanging(value);
    					this.SendPropertyChanging();
    					this._Number = value;
    					this.SendPropertyChanged("Number");
    					this.OnNumberChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Cost", DbType="Money NOT NULL")]
    		public decimal Cost
    		{
    			get
    			{
    				return this._Cost;
    			}
    			set
    			{
    				if ((this._Cost != value))
    				{
    					this.OnCostChanging(value);
    					this.SendPropertyChanging();
    					this._Cost = value;
    					this.SendPropertyChanged("Cost");
    					this.OnCostChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IssuerFee", DbType="Money NOT NULL")]
    		public decimal IssuerFee
    		{
    			get
    			{
    				return this._IssuerFee;
    			}
    			set
    			{
    				if ((this._IssuerFee != value))
    				{
    					this.OnIssuerFeeChanging(value);
    					this.SendPropertyChanging();
    					this._IssuerFee = value;
    					this.SendPropertyChanged("IssuerFee");
    					this.OnIssuerFeeChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ThirdPartyProcessingFee", DbType="Money NOT NULL")]
    		public decimal ThirdPartyProcessingFee
    		{
    			get
    			{
    				return this._ThirdPartyProcessingFee;
    			}
    			set
    			{
    				if ((this._ThirdPartyProcessingFee != value))
    				{
    					this.OnThirdPartyProcessingFeeChanging(value);
    					this.SendPropertyChanging();
    					this._ThirdPartyProcessingFee = value;
    					this.SendPropertyChanged("ThirdPartyProcessingFee");
    					this.OnThirdPartyProcessingFeeChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Total", DbType="Money NOT NULL")]
    		public decimal Total
    		{
    			get
    			{
    				return this._Total;
    			}
    			set
    			{
    				if ((this._Total != value))
    				{
    					this.OnTotalChanging(value);
    					this.SendPropertyChanging();
    					this._Total = value;
    					this.SendPropertyChanged("Total");
    					this.OnTotalChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Issued", DbType="DateTime NOT NULL")]
    		public System.DateTime Issued
    		{
    			get
    			{
    				return this._Issued;
    			}
    			set
    			{
    				if ((this._Issued != value))
    				{
    					this.OnIssuedChanging(value);
    					this.SendPropertyChanging();
    					this._Issued = value;
    					this.SendPropertyChanged("Issued");
    					this.OnIssuedChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Effective", DbType="DateTime NOT NULL")]
    		public System.DateTime Effective
    		{
    			get
    			{
    				return this._Effective;
    			}
    			set
    			{
    				if ((this._Effective != value))
    				{
    					this.OnEffectiveChanging(value);
    					this.SendPropertyChanging();
    					this._Effective = value;
    					this.SendPropertyChanged("Effective");
    					this.OnEffectiveChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Expires", DbType="DateTime")]
    		public System.Nullable<System.DateTime> Expires
    		{
    			get
    			{
    				return this._Expires;
    			}
    			set
    			{
    				if ((this._Expires != value))
    				{
    					this.OnExpiresChanging(value);
    					this.SendPropertyChanging();
    					this._Expires = value;
    					this.SendPropertyChanged("Expires");
    					this.OnExpiresChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CostCategoryId", DbType="Int NOT NULL")]
    		public int CostCategoryId
    		{
    			get
    			{
    				return this._CostCategoryId;
    			}
    			set
    			{
    				if ((this._CostCategoryId != value))
    				{
    					if (this._CostCategory.HasLoadedOrAssignedValue)
    					{
    						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
    					}
    					this.OnCostCategoryIdChanging(value);
    					this.SendPropertyChanging();
    					this._CostCategoryId = value;
    					this.SendPropertyChanged("CostCategoryId");
    					this.OnCostCategoryIdChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IsVoid", DbType="Bit NOT NULL")]
    		public bool IsVoid
    		{
    			get
    			{
    				return this._IsVoid;
    			}
    			set
    			{
    				if ((this._IsVoid != value))
    				{
    					this.OnIsVoidChanging(value);
    					this.SendPropertyChanging();
    					this._IsVoid = value;
    					this.SendPropertyChanged("IsVoid");
    					this.OnIsVoidChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_DogId", DbType="Int")]
    		public System.Nullable<int> DogId
    		{
    			get
    			{
    				return this._DogId;
    			}
    			set
    			{
    				if ((this._DogId != value))
    				{
    					if (this._Dog.HasLoadedOrAssignedValue)
    					{
    						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
    					}
    					this.OnDogIdChanging(value);
    					this.SendPropertyChanging();
    					this._DogId = value;
    					this.SendPropertyChanged("DogId");
    					this.OnDogIdChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Location", DbType="NVarChar(255) NOT NULL", CanBeNull=false)]
    		public string Location
    		{
    			get
    			{
    				return this._Location;
    			}
    			set
    			{
    				if ((this._Location != value))
    				{
    					this.OnLocationChanging(value);
    					this.SendPropertyChanging();
    					this._Location = value;
    					this.SendPropertyChanged("Location");
    					this.OnLocationChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Notes", DbType="NText NOT NULL", CanBeNull=false, UpdateCheck=UpdateCheck.Never)]
    		public string Notes
    		{
    			get
    			{
    				return this._Notes;
    			}
    			set
    			{
    				if ((this._Notes != value))
    				{
    					this.OnNotesChanging(value);
    					this.SendPropertyChanging();
    					this._Notes = value;
    					this.SendPropertyChanged("Notes");
    					this.OnNotesChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PermitNumber", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
    		public string PermitNumber
    		{
    			get
    			{
    				return this._PermitNumber;
    			}
    			set
    			{
    				if ((this._PermitNumber != value))
    				{
    					this.OnPermitNumberChanging(value);
    					this.SendPropertyChanging();
    					this._PermitNumber = value;
    					this.SendPropertyChanged("PermitNumber");
    					this.OnPermitNumberChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Drawing", DbType="DateTime")]
    		public System.Nullable<System.DateTime> Drawing
    		{
    			get
    			{
    				return this._Drawing;
    			}
    			set
    			{
    				if ((this._Drawing != value))
    				{
    					this.OnDrawingChanging(value);
    					this.SendPropertyChanging();
    					this._Drawing = value;
    					this.SendPropertyChanged("Drawing");
    					this.OnDrawingChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_NumberOfChances", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
    		public string NumberOfChances
    		{
    			get
    			{
    				return this._NumberOfChances;
    			}
    			set
    			{
    				if ((this._NumberOfChances != value))
    				{
    					this.OnNumberOfChancesChanging(value);
    					this.SendPropertyChanging();
    					this._NumberOfChances = value;
    					this.SendPropertyChanged("NumberOfChances");
    					this.OnNumberOfChancesChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PricePerChance", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
    		public string PricePerChance
    		{
    			get
    			{
    				return this._PricePerChance;
    			}
    			set
    			{
    				if ((this._PricePerChance != value))
    				{
    					this.OnPricePerChanceChanging(value);
    					this.SendPropertyChanging();
    					this._PricePerChance = value;
    					this.SendPropertyChanged("PricePerChance");
    					this.OnPricePerChanceChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="CostCategory_License", Storage="_CostCategory", ThisKey="CostCategoryId", OtherKey="CostCategoryId", IsForeignKey=true)]
    		public CostCategory CostCategory
    		{
    			get
    			{
    				return this._CostCategory.Entity;
    			}
    			set
    			{
    				CostCategory previousValue = this._CostCategory.Entity;
    				if (((previousValue != value) 
    							|| (this._CostCategory.HasLoadedOrAssignedValue == false)))
    				{
    					this.SendPropertyChanging();
    					if ((previousValue != null))
    					{
    						this._CostCategory.Entity = null;
    						previousValue.Licenses.Remove(this);
    					}
    					this._CostCategory.Entity = value;
    					if ((value != null))
    					{
    						value.Licenses.Add(this);
    						this._CostCategoryId = value.CostCategoryId;
    					}
    					else
    					{
    						this._CostCategoryId = default(int);
    					}
    					this.SendPropertyChanged("CostCategory");
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Dog_License", Storage="_Dog", ThisKey="DogId", OtherKey="DogId", IsForeignKey=true)]
    		public Dog Dog
    		{
    			get
    			{
    				return this._Dog.Entity;
    			}
    			set
    			{
    				Dog previousValue = this._Dog.Entity;
    				if (((previousValue != value) 
    							|| (this._Dog.HasLoadedOrAssignedValue == false)))
    				{
    					this.SendPropertyChanging();
    					if ((previousValue != null))
    					{
    						this._Dog.Entity = null;
    						previousValue.Licenses.Remove(this);
    					}
    					this._Dog.Entity = value;
    					if ((value != null))
    					{
    						value.Licenses.Add(this);
    						this._DogId = value.DogId;
    					}
    					else
    					{
    						this._DogId = default(Nullable<int>);
    					}
    					this.SendPropertyChanged("Dog");
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="LicenseSubtype_License", Storage="_LicenseSubtype", ThisKey="LicenseSubtypeId", OtherKey="LicenseSubtypeId", IsForeignKey=true)]
    		public LicenseSubtype LicenseSubtype
    		{
    			get
    			{
    				return this._LicenseSubtype.Entity;
    			}
    			set
    			{
    				LicenseSubtype previousValue = this._LicenseSubtype.Entity;
    				if (((previousValue != value) 
    							|| (this._LicenseSubtype.HasLoadedOrAssignedValue == false)))
    				{
    					this.SendPropertyChanging();
    					if ((previousValue != null))
    					{
    						this._LicenseSubtype.Entity = null;
    						previousValue.Licenses.Remove(this);
    					}
    					this._LicenseSubtype.Entity = value;
    					if ((value != null))
    					{
    						value.Licenses.Add(this);
    						this._LicenseSubtypeId = value.LicenseSubtypeId;
    					}
    					else
    					{
    						this._LicenseSubtypeId = default(int);
    					}
    					this.SendPropertyChanged("LicenseSubtype");
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Licensee_License", Storage="_Licensee", ThisKey="LicenseeId", OtherKey="LicenseeId", IsForeignKey=true)]
    		public Licensee Licensee
    		{
    			get
    			{
    				return this._Licensee.Entity;
    			}
    			set
    			{
    				Licensee previousValue = this._Licensee.Entity;
    				if (((previousValue != value) 
    							|| (this._Licensee.HasLoadedOrAssignedValue == false)))
    				{
    					this.SendPropertyChanging();
    					if ((previousValue != null))
    					{
    						this._Licensee.Entity = null;
    						previousValue.Licenses.Remove(this);
    					}
    					this._Licensee.Entity = value;
    					if ((value != null))
    					{
    						value.Licenses.Add(this);
    						this._LicenseeId = value.LicenseeId;
    					}
    					else
    					{
    						this._LicenseeId = default(int);
    					}
    					this.SendPropertyChanged("Licensee");
    				}
    			}
    		}
    		
    		public event PropertyChangingEventHandler PropertyChanging;
    		
    		public event PropertyChangedEventHandler PropertyChanged;
    		
    		protected virtual void SendPropertyChanging()
    		{
    			if ((this.PropertyChanging != null))
    			{
    				this.PropertyChanging(this, emptyChangingEventArgs);
    			}
    		}
    		
    		protected virtual void SendPropertyChanged(String propertyName)
    		{
    			if ((this.PropertyChanged != null))
    			{
    				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    			}
    		}
    	}
    
    
    Monday, August 16, 2010 1:14 PM
  • Here is the autogenerated class definition from the dbml designer for Licensee.

    	
    	[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Licensee")]
    	public partial class Licensee : INotifyPropertyChanging, INotifyPropertyChanged
    	{
    		
    		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
    		
    		private int _LicenseeId;
    		
    		private string _FirstName;
    		
    		private string _MiddleName;
    		
    		private string _LastName;
    		
    		private System.Nullable<int> _SuffixId;
    		
    		private string _Address1;
    		
    		private string _Address2;
    		
    		private string _City;
    		
    		private System.Nullable<int> _StateId;
    		
    		private string _ZipCode;
    		
    		private string _PhoneNumber;
    		
    		private string _MobileNumber;
    		
    		private System.Nullable<System.DateTime> _DateOfBirth;
    		
    		private string _Notes;
    		
    		private System.Nullable<int> _MunicipalityId;
    		
    		private bool _IsPhysicallyDisabled;
    		
    		private bool _IsActive;
    		
    		private EntitySet<Dog> _Dogs;
    		
    		private EntitySet<License> _Licenses;
    		
    		private EntityRef<Municipality> _Municipality;
    		
    		private EntityRef<State> _State;
    		
    		private EntityRef<Suffix> _Suffix;
    		
      #region Extensibility Method Definitions
      partial void OnLoaded();
      partial void OnValidate(System.Data.Linq.ChangeAction action);
      partial void OnCreated();
      partial void OnLicenseeIdChanging(int value);
      partial void OnLicenseeIdChanged();
      partial void OnFirstNameChanging(string value);
      partial void OnFirstNameChanged();
      partial void OnMiddleNameChanging(string value);
      partial void OnMiddleNameChanged();
      partial void OnLastNameChanging(string value);
      partial void OnLastNameChanged();
      partial void OnSuffixIdChanging(System.Nullable<int> value);
      partial void OnSuffixIdChanged();
      partial void OnAddress1Changing(string value);
      partial void OnAddress1Changed();
      partial void OnAddress2Changing(string value);
      partial void OnAddress2Changed();
      partial void OnCityChanging(string value);
      partial void OnCityChanged();
      partial void OnStateIdChanging(System.Nullable<int> value);
      partial void OnStateIdChanged();
      partial void OnZipCodeChanging(string value);
      partial void OnZipCodeChanged();
      partial void OnPhoneNumberChanging(string value);
      partial void OnPhoneNumberChanged();
      partial void OnMobileNumberChanging(string value);
      partial void OnMobileNumberChanged();
      partial void OnDateOfBirthChanging(System.Nullable<System.DateTime> value);
      partial void OnDateOfBirthChanged();
      partial void OnNotesChanging(string value);
      partial void OnNotesChanged();
      partial void OnMunicipalityIdChanging(System.Nullable<int> value);
      partial void OnMunicipalityIdChanged();
      partial void OnIsPhysicallyDisabledChanging(bool value);
      partial void OnIsPhysicallyDisabledChanged();
      partial void OnIsActiveChanging(bool value);
      partial void OnIsActiveChanged();
      #endregion
    		
    		public Licensee()
    		{
    			this._Dogs = new EntitySet<Dog>(new Action<Dog>(this.attach_Dogs), new Action<Dog>(this.detach_Dogs));
    			this._Licenses = new EntitySet<License>(new Action<License>(this.attach_Licenses), new Action<License>(this.detach_Licenses));
    			this._Municipality = default(EntityRef<Municipality>);
    			this._State = default(EntityRef<State>);
    			this._Suffix = default(EntityRef<Suffix>);
    			OnCreated();
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_LicenseeId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
    		public int LicenseeId
    		{
    			get
    			{
    				return this._LicenseeId;
    			}
    			set
    			{
    				if ((this._LicenseeId != value))
    				{
    					this.OnLicenseeIdChanging(value);
    					this.SendPropertyChanging();
    					this._LicenseeId = value;
    					this.SendPropertyChanged("LicenseeId");
    					this.OnLicenseeIdChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FirstName", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
    		public string FirstName
    		{
    			get
    			{
    				return this._FirstName;
    			}
    			set
    			{
    				if ((this._FirstName != value))
    				{
    					this.OnFirstNameChanging(value);
    					this.SendPropertyChanging();
    					this._FirstName = value;
    					this.SendPropertyChanged("FirstName");
    					this.OnFirstNameChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_MiddleName", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
    		public string MiddleName
    		{
    			get
    			{
    				return this._MiddleName;
    			}
    			set
    			{
    				if ((this._MiddleName != value))
    				{
    					this.OnMiddleNameChanging(value);
    					this.SendPropertyChanging();
    					this._MiddleName = value;
    					this.SendPropertyChanged("MiddleName");
    					this.OnMiddleNameChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_LastName", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
    		public string LastName
    		{
    			get
    			{
    				return this._LastName;
    			}
    			set
    			{
    				if ((this._LastName != value))
    				{
    					this.OnLastNameChanging(value);
    					this.SendPropertyChanging();
    					this._LastName = value;
    					this.SendPropertyChanged("LastName");
    					this.OnLastNameChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_SuffixId", DbType="Int")]
    		public System.Nullable<int> SuffixId
    		{
    			get
    			{
    				return this._SuffixId;
    			}
    			set
    			{
    				if ((this._SuffixId != value))
    				{
    					if (this._Suffix.HasLoadedOrAssignedValue)
    					{
    						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
    					}
    					this.OnSuffixIdChanging(value);
    					this.SendPropertyChanging();
    					this._SuffixId = value;
    					this.SendPropertyChanged("SuffixId");
    					this.OnSuffixIdChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Address1", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
    		public string Address1
    		{
    			get
    			{
    				return this._Address1;
    			}
    			set
    			{
    				if ((this._Address1 != value))
    				{
    					this.OnAddress1Changing(value);
    					this.SendPropertyChanging();
    					this._Address1 = value;
    					this.SendPropertyChanged("Address1");
    					this.OnAddress1Changed();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Address2", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
    		public string Address2
    		{
    			get
    			{
    				return this._Address2;
    			}
    			set
    			{
    				if ((this._Address2 != value))
    				{
    					this.OnAddress2Changing(value);
    					this.SendPropertyChanging();
    					this._Address2 = value;
    					this.SendPropertyChanged("Address2");
    					this.OnAddress2Changed();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_City", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
    		public string City
    		{
    			get
    			{
    				return this._City;
    			}
    			set
    			{
    				if ((this._City != value))
    				{
    					this.OnCityChanging(value);
    					this.SendPropertyChanging();
    					this._City = value;
    					this.SendPropertyChanged("City");
    					this.OnCityChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_StateId", DbType="Int")]
    		public System.Nullable<int> StateId
    		{
    			get
    			{
    				return this._StateId;
    			}
    			set
    			{
    				if ((this._StateId != value))
    				{
    					if (this._State.HasLoadedOrAssignedValue)
    					{
    						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
    					}
    					this.OnStateIdChanging(value);
    					this.SendPropertyChanging();
    					this._StateId = value;
    					this.SendPropertyChanged("StateId");
    					this.OnStateIdChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ZipCode", DbType="NVarChar(10) NOT NULL", CanBeNull=false)]
    		public string ZipCode
    		{
    			get
    			{
    				return this._ZipCode;
    			}
    			set
    			{
    				if ((this._ZipCode != value))
    				{
    					this.OnZipCodeChanging(value);
    					this.SendPropertyChanging();
    					this._ZipCode = value;
    					this.SendPropertyChanged("ZipCode");
    					this.OnZipCodeChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PhoneNumber", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
    		public string PhoneNumber
    		{
    			get
    			{
    				return this._PhoneNumber;
    			}
    			set
    			{
    				if ((this._PhoneNumber != value))
    				{
    					this.OnPhoneNumberChanging(value);
    					this.SendPropertyChanging();
    					this._PhoneNumber = value;
    					this.SendPropertyChanged("PhoneNumber");
    					this.OnPhoneNumberChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_MobileNumber", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
    		public string MobileNumber
    		{
    			get
    			{
    				return this._MobileNumber;
    			}
    			set
    			{
    				if ((this._MobileNumber != value))
    				{
    					this.OnMobileNumberChanging(value);
    					this.SendPropertyChanging();
    					this._MobileNumber = value;
    					this.SendPropertyChanged("MobileNumber");
    					this.OnMobileNumberChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_DateOfBirth", DbType="DateTime")]
    		public System.Nullable<System.DateTime> DateOfBirth
    		{
    			get
    			{
    				return this._DateOfBirth;
    			}
    			set
    			{
    				if ((this._DateOfBirth != value))
    				{
    					this.OnDateOfBirthChanging(value);
    					this.SendPropertyChanging();
    					this._DateOfBirth = value;
    					this.SendPropertyChanged("DateOfBirth");
    					this.OnDateOfBirthChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Notes", DbType="NText NOT NULL", CanBeNull=false, UpdateCheck=UpdateCheck.Never)]
    		public string Notes
    		{
    			get
    			{
    				return this._Notes;
    			}
    			set
    			{
    				if ((this._Notes != value))
    				{
    					this.OnNotesChanging(value);
    					this.SendPropertyChanging();
    					this._Notes = value;
    					this.SendPropertyChanged("Notes");
    					this.OnNotesChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_MunicipalityId", DbType="Int")]
    		public System.Nullable<int> MunicipalityId
    		{
    			get
    			{
    				return this._MunicipalityId;
    			}
    			set
    			{
    				if ((this._MunicipalityId != value))
    				{
    					if (this._Municipality.HasLoadedOrAssignedValue)
    					{
    						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
    					}
    					this.OnMunicipalityIdChanging(value);
    					this.SendPropertyChanging();
    					this._MunicipalityId = value;
    					this.SendPropertyChanged("MunicipalityId");
    					this.OnMunicipalityIdChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IsPhysicallyDisabled", DbType="Bit NOT NULL")]
    		public bool IsPhysicallyDisabled
    		{
    			get
    			{
    				return this._IsPhysicallyDisabled;
    			}
    			set
    			{
    				if ((this._IsPhysicallyDisabled != value))
    				{
    					this.OnIsPhysicallyDisabledChanging(value);
    					this.SendPropertyChanging();
    					this._IsPhysicallyDisabled = value;
    					this.SendPropertyChanged("IsPhysicallyDisabled");
    					this.OnIsPhysicallyDisabledChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IsActive", DbType="Bit NOT NULL")]
    		public bool IsActive
    		{
    			get
    			{
    				return this._IsActive;
    			}
    			set
    			{
    				if ((this._IsActive != value))
    				{
    					this.OnIsActiveChanging(value);
    					this.SendPropertyChanging();
    					this._IsActive = value;
    					this.SendPropertyChanged("IsActive");
    					this.OnIsActiveChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Licensee_Dog", Storage="_Dogs", ThisKey="LicenseeId", OtherKey="LicenseeId")]
    		public EntitySet<Dog> Dogs
    		{
    			get
    			{
    				return this._Dogs;
    			}
    			set
    			{
    				this._Dogs.Assign(value);
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Licensee_License", Storage="_Licenses", ThisKey="LicenseeId", OtherKey="LicenseeId")]
    		public EntitySet<License> Licenses
    		{
    			get
    			{
    				return this._Licenses;
    			}
    			set
    			{
    				this._Licenses.Assign(value);
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Municipality_Licensee", Storage="_Municipality", ThisKey="MunicipalityId", OtherKey="MunicipalityId", IsForeignKey=true)]
    		public Municipality Municipality
    		{
    			get
    			{
    				return this._Municipality.Entity;
    			}
    			set
    			{
    				Municipality previousValue = this._Municipality.Entity;
    				if (((previousValue != value) 
    							|| (this._Municipality.HasLoadedOrAssignedValue == false)))
    				{
    					this.SendPropertyChanging();
    					if ((previousValue != null))
    					{
    						this._Municipality.Entity = null;
    						previousValue.Licensees.Remove(this);
    					}
    					this._Municipality.Entity = value;
    					if ((value != null))
    					{
    						value.Licensees.Add(this);
    						this._MunicipalityId = value.MunicipalityId;
    					}
    					else
    					{
    						this._MunicipalityId = default(Nullable<int>);
    					}
    					this.SendPropertyChanged("Municipality");
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="State_Licensee", Storage="_State", ThisKey="StateId", OtherKey="StateId", IsForeignKey=true)]
    		public State State
    		{
    			get
    			{
    				return this._State.Entity;
    			}
    			set
    			{
    				State previousValue = this._State.Entity;
    				if (((previousValue != value) 
    							|| (this._State.HasLoadedOrAssignedValue == false)))
    				{
    					this.SendPropertyChanging();
    					if ((previousValue != null))
    					{
    						this._State.Entity = null;
    						previousValue.Licensees.Remove(this);
    					}
    					this._State.Entity = value;
    					if ((value != null))
    					{
    						value.Licensees.Add(this);
    						this._StateId = value.StateId;
    					}
    					else
    					{
    						this._StateId = default(Nullable<int>);
    					}
    					this.SendPropertyChanged("State");
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Suffix_Licensee", Storage="_Suffix", ThisKey="SuffixId", OtherKey="SuffixId", IsForeignKey=true)]
    		public Suffix Suffix
    		{
    			get
    			{
    				return this._Suffix.Entity;
    			}
    			set
    			{
    				Suffix previousValue = this._Suffix.Entity;
    				if (((previousValue != value) 
    							|| (this._Suffix.HasLoadedOrAssignedValue == false)))
    				{
    					this.SendPropertyChanging();
    					if ((previousValue != null))
    					{
    						this._Suffix.Entity = null;
    						previousValue.Licensees.Remove(this);
    					}
    					this._Suffix.Entity = value;
    					if ((value != null))
    					{
    						value.Licensees.Add(this);
    						this._SuffixId = value.SuffixId;
    					}
    					else
    					{
    						this._SuffixId = default(Nullable<int>);
    					}
    					this.SendPropertyChanged("Suffix");
    				}
    			}
    		}
    		
    		public event PropertyChangingEventHandler PropertyChanging;
    		
    		public event PropertyChangedEventHandler PropertyChanged;
    		
    		protected virtual void SendPropertyChanging()
    		{
    			if ((this.PropertyChanging != null))
    			{
    				this.PropertyChanging(this, emptyChangingEventArgs);
    			}
    		}
    		
    		protected virtual void SendPropertyChanged(String propertyName)
    		{
    			if ((this.PropertyChanged != null))
    			{
    				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    			}
    		}
    		
    		private void attach_Dogs(Dog entity)
    		{
    			this.SendPropertyChanging();
    			entity.Licensee = this;
    		}
    		
    		private void detach_Dogs(Dog entity)
    		{
    			this.SendPropertyChanging();
    			entity.Licensee = null;
    		}
    		
    		private void attach_Licenses(License entity)
    		{
    			this.SendPropertyChanging();
    			entity.Licensee = this;
    		}
    		
    		private void detach_Licenses(License entity)
    		{
    			this.SendPropertyChanging();
    			entity.Licensee = null;
    		}
    	}
    
    
    Monday, August 16, 2010 1:16 PM
  • One small thought. Does this work?

      Licensee lee; //Comes from my BLL
    
      ICollectionView cvw = CollectionViewSource.GetDefaultView(lee.Licenses.ToList()); // N.B the .ToList()
    
      cvw.SortDescriptions.Add(new SortDescription("Dog.Name", ListSortDirection.Ascending));
    

    The only notable difference between your first example and your second example is the type of object being passed to GetDefaultView().

    Monday, August 16, 2010 2:07 PM
  • Here is a simplified repro sample.

    1. Create a new WpfApplication project using Visual Studio 2010.

    2. Add a new LINQ to SQL Classes item.

    3. Create a class model with MyMaster, MyChild, and MyLookup classes.  Below is the resulting dbml file.

    <?xml version="1.0" encoding="utf-8"?><Database Class="DataClasses1DataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
     <Table Name="" Member="MyMasters">
      <Type Name="MyMaster">
       <Column Member="MyMasterId" Type="System.Int32" IsPrimaryKey="true" CanBeNull="false" />
       <Column Member="Name" Type="System.String" CanBeNull="false" />
       <Association Name="MyMaster_MyChild" Member="MyChilds" ThisKey="MyMasterId" OtherKey="MyMasterId" Type="MyChild" />
      </Type>
     </Table>
     <Table Name="" Member="MyChilds">
      <Type Name="MyChild">
       <Column Member="MyChildId" Type="System.Int32" IsPrimaryKey="true" CanBeNull="false" />
       <Column Member="MyMasterId" Type="System.Int32" CanBeNull="false" />
       <Column Member="MyLookupId" Type="System.Int32" CanBeNull="true" />
       <Column Member="Name" Type="System.String" CanBeNull="false" />
       <Association Name="MyMaster_MyChild" Member="MyMaster" ThisKey="MyMasterId" OtherKey="MyMasterId" Type="MyMaster" IsForeignKey="true" />
       <Association Name="MyLookup_MyChild" Member="MyLookup" ThisKey="MyLookupId" OtherKey="MyLookupId" Type="MyLookup" IsForeignKey="true" />
      </Type>
     </Table>
     <Table Name="" Member="MyLookups">
      <Type Name="MyLookup">
       <Column Member="MyLookupId" Type="System.Int32" IsPrimaryKey="true" CanBeNull="false" />
       <Column Member="Name" Type="System.String" CanBeNull="false" />
       <Association Name="MyLookup_MyChild" Member="MyChilds" ThisKey="MyLookupId" OtherKey="MyLookupId" Type="MyChild" />
      </Type>
     </Table>
    </Database>
    

    4. Create a custom property for the MyChild class.

      partial class MyChild
      {
        public string LookupName
        {
          get
          {
            return this.MyLookup == null ? "" : this.MyLookup.Name;
          }
        }
      }
    
    

    5. Execute the following tests.  The result will be that Test #1 fails while Tests #2 and #3 are successful.

        private MyMaster GetTestData()
        {
          //Create the master
          MyMaster master = new MyMaster();
    
          master.Name = "Master 1";
    
          //Create three children
          for (int i = 1; i <= 3; i++)
          {
            MyChild child = new MyChild();
    
            child.Name = "Child " + i.ToString();
            master.MyChilds.Add(child);
          }
    
          //Assign lookups to the children
          MyLookup lookup1 = new MyLookup();
          MyLookup lookup2 = new MyLookup();
    
          lookup1.Name = "Lookup 1";
          lookup2.Name = "Lookup 2";
    
          master.MyChilds[0].MyLookup = lookup1;
          master.MyChilds[1].MyLookup = lookup2;
          master.MyChilds[2].MyLookup = null;
    
          return master;
        }
    
        private void Test1()
        {
          MyMaster master = this.GetTestData();
          ICollectionView cvw = CollectionViewSource.GetDefaultView(master.MyChilds);
    
          try
          {
            cvw.SortDescriptions.Add(new SortDescription("Lookup.Name", ListSortDirection.Ascending));
            MessageBox.Show("Test #1 successful");
          }
          catch
          {
            MessageBox.Show("Error with test #1");
          }
        }
    
        private void Test2()
        {
          MyMaster master = this.GetTestData();
          ICollectionView cvw = CollectionViewSource.GetDefaultView(master.MyChilds);
    
          try
          {
            cvw.SortDescriptions.Add(new SortDescription("LookupName", ListSortDirection.Ascending));
            MessageBox.Show("Test #2 successful");
          }
          catch
          {
            MessageBox.Show("Error with test #2");
          }
        }
    
        private void Test3()
        {
          MyMaster master = this.GetTestData();
          List<MyChild> lst = new List<MyChild>();
    
          foreach (MyChild child in master.MyChilds)
          {
            lst.Add(child);
          }
    
          ICollectionView cvw = CollectionViewSource.GetDefaultView(lst);
          try
          {
            cvw.SortDescriptions.Add(new SortDescription("Lookup.Name", ListSortDirection.Ascending));
            MessageBox.Show("Test #3 successful");
          }
          catch
          {
            MessageBox.Show("Error with test #3");
          }
        }
    
        private void ExecuteTests()
        {
          this.Test1();
          this.Test2();
          this.Test3();
        }
    
    
    Monday, August 16, 2010 2:13 PM
  • That does work but I am hesitant to use that solution because I want adds and deletes to be reflected in the data binding on the UI.  I suspect the List object created by that method does not stay in sync with the underlying EntitySet.
    Monday, August 16, 2010 2:29 PM
  • Hi Chris,

    If you want insertions or deletions in the collection update the UI automatically, the collection must implement the INotifyCollectionChanged interface. This interface exposes an event that should be raised whenever the underlying collection changes. WPF provides the ObservableCollection(Of T) class, which is a built-in implementation of a data collection that exposes the INotifyCollectionChanged interface. However, EntitySet doesn't implement INotifyCollectionChanged.The ObservableCollection has a constructor that takes a List as parameter(ObservableCollection(Of T)(List(Of T))). You can construct a new ObservableCollection object passing the lee.Licenses.ToList collection as the parameter. Then use that ObservableCollection instead.

    You can refer to the following link to get some information about How to Create and Bind to an ObservableCollection.
    http://msdn.microsoft.com/en-us/library/ms748365.aspx

    Information about ObservableCollection(Of T) Constructor (List(Of T))
    http://msdn.microsoft.com/en-us/library/ms653202.aspx
     

    Best regards,

    Alex Liang

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, August 17, 2010 2:11 PM
    Moderator
  • I now see that the reason for my original problem probably stems from the fact that EntitySet was never intended to be databound in WPF.  Being that the adds/changes/deletes are being made to my business object, the EntitySet, and there is no way I can directly bind, I will be stuck with synchronization issues.

    My interim solution is to forgo a WPF binding and refresh the ItemsSource for my ListView with the ToList method every time that I make an add or a delete.

    If I can find a way to wrap the EntitySet in a class that does implement INotifyCollectionChanged, that would be my final solution since it is unlikely that EntitySet will ever directly implement INotifyCollectionChanged.  Wrapping the EntitySet would eliminate synchronization issues since a separate collection would not be created.  I don't see a way to wrap the EntitySet within a second class and still use WPF binding within declarative xaml though.

    Wednesday, August 18, 2010 2:39 PM