There have been a couple of discussions on the .NET RIA Services Forums regarding the DomainDataSource.DataView property. Colin Blair tossed in a comment that relates to something we’re working on:
This looks like as good a place as any to say I would like to see the actual object behind IEditableCollectionView exposed publically.
…
Right now, the DomainDataSource’s Data and DataView properties are returned as interfaces: Data is an IEnumerable, and DataView is an ICollectionView. But behind the scenes, both of these properties return an instance of an EntityCollectionView, which is an internal class.
Returning DataView as an ICollectionView is pretty painful though, because in actuality, the class implements other extremely valuable interfaces too: IEditableCollectionView and IPagedCollectionView. You can cast the DataView property to either of these interfaces and find many features that you may not have otherwise known about.
The first suggestion was to just make EntityCollectionView public, but EntityCollectionView is a very implementation-specific class, and it was never intended to be public. Therefore, it has properties and methods that wouldn’t be relevant to include in a public class, and I’m not hip on having tons of internal properties and methods on a public class. But we know that having to cast the DataView property to the interfaces is painful, so we want to address that issue.
The idea on the table is to create a public class that implements the following interfaces:
- ICollectionView
- IEditableCollectionView
- IPagedCollectionView
- INotifyPropertyChanged
The DomainDataSource.DataView property would return an instance of this class, so that the full API of those interfaces would be easily discovered. For now, let’s call this class the DataView class (name to be determined).
We’ve also discussed adding other API features to this class, to simplify common scenarios around adding entities from the list. Right now, the only way to add an entity into the DomainDataSource is to use the AddNew method from IEditableCollectionView. This method will construct the entity and return it back. But what if you already have an entity and you simply want to “attach” it to the DomainDataSource’s data?
There are likely other scenarios that could be simplified with a DataView class too. If you know of any, please share them here (and/or on the RIA Services forums).