The MSDN documentation states that an EntitySet implements IBindingList
(see \'Binding to EntitySets\' at http://msdn.microsoft.com/en-us/library/bb546190.aspx)
EntitySet
EDIT: Sorting with BindingList:
To sort with a BindingList, you need to expose some kind of interface to allow sorting. Sorting is supported within the BindingList
public class EntitySetBindingWrapper: BindingList
{
public EntitySetBindingWrapper(BindingList root) : base(root)
{
}
public void Sort(Expression> expr, ListSortDirection direction)
{
if (expr == null)
base.RemoveSortCore();
MemberExpression propExpr = expr as MemberExpression;
if (propExpr == null) throw new ArgumentException("You must provide a property", "expr");
PropertyDescriptorCollection descriptorCol = TypeDescriptor.GetProperties(typeof(T));
IEnumerable descriptors = descriptorCol.Cast();
PropertyDescriptor descriptor = descriptors.First(pd => pd.Name == propExpr.Member.Name);
base.ApplySortCore(descriptor, direction);
}
}
You should then be able to sort like so:
var bindingWrapper = new EntitySetBindingWrapper(myEntitySet.GetNewBindingList());
bindingWrapper.Sort(e => e.MyProperty, ListSortDirection.Ascending);
listView.DataSource = bindingWrapper;
There might be additional implementation for the EntitySetBindingWrapper class...such as fortwarding any normally public methods on BindingList