I mucked around enough to fiqure out what it was doing and use these classes in a form, except one concept has proven a little frustrating: HOW TO USE THE DARNED ENTITYSET
The Problem
When I first attempted to use these EntitySet
<Grid>
<Grid.Resources>
<CollectionViewSource x:Key="SortedBios" Source="{Binding SelectedItem.CGBiographies, ElementName=cbxManagers, Mode=OneWay}">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="Name"/>
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</Grid.Resources>
<ListBox Name="lbxBios" DisplayMemberPath="Name" ItemsSource="{Binding Source={StaticResource SortedBios}}"/>
</Grid>
public partial class CGManager: InvestBase
{
public List BiographyList
{
get { return _CGBiographies.ToList(); }
}
The Answer: No.
Okay, "no" for the EntitySet, but that is fortunately not the end of the story. The EntitySet has a method GetNewBindingList() that returns an IBindingList collection. As it turns out, this interface provides you with everything you need to not only sort, but to notify your UIElements of changes to the underlying collection. Here is my new BiographyList property:
public partial class CGManager: InvestBase
{
private BindingList<CGBiography> _BiographyList;
public BindingList<CGBiography> BiographyList
{
get {
if (_BiographyList == null)
{
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(new CGBiography());
PropertyDescriptor myProp = properties.Find("Name", true);
IBindingList bl = (IBindingList)_CGBiographies.GetNewBindingList();
bl.ApplySort(myProp, ListSortDirection.Ascending);
_BiographyList = (BindingList<CGBiography>)bl;
}
return _BiographyList; }
}
I have to say, this seems like a lot of code for what should have been a much simpler task, and I am still looking for a better way to do this. If you have one, please let me know!
PS: ObservableCollection
How about ObservableCollections? You can create one from an EntitySet
_BiographyList = new ObservableCollection<CGBiography>(CGBiographies);
This results in a collection that can not only be sorted using the above XAML, but will also notify the ListBox of additions and deletions. Unfortunately, the link between it and the EntitySet is non-existant and so additions and deletions will not be reflected in the EntitySet as they are when using the BindingList.