I'm using EF4 to generate a model. My architecture looks like this:
IMyEntity (custom interface)
-> MyEntity - EF generated class
IMyOtherEntity (custom interface)
-> MyExtendedEntity (Customn Partial class) : MyOtherEntity (EF Generated)
The fi开发者_C百科rst entity has a list of MyExtendedEntity. Is there any way I can bind this with the entity framework. I'm targetting ASP.NET and WPF. The main probnlem I have is that I need an ObservableCollection in WPF, while the EF generated class only has an EntityCollection which doesn't even seem to derive from ObservableCollection.
You should add a partial class whose name and namespace matches that of the EF generated entities. Inside this class, add an ObserableCollection property that wraps around the EntityCollection property and bind to that instead.
Alternatively you can map your entities to view-specific ViewModel classes instead. Search for MVVM to find plenty of information on this topic.
精彩评论