How to Bind ICollection with EntityFramework 4.1 with DBContext Generator
I would like to know how to use simple databinding (grid.d开发者_JAVA百科atasource = xxxx) with DBContext Generator and entity framework 4.1;
With POCO entity Generator, i was able to do
Grid.DataSource = Entity.MyChildreCollection;
(probably because Poco entity generator use FixUp Collection)
But with DBContext Generator this property is ICollection so can't be bind directly .
What's the best practise to bind my entity collection to a grid ?
I've try changing T4 template from HashSet<T>
to
ObservableListSource<T>
(with ObservableListSource<T> : ObservableCollection<T>, IListSource)
I've noticed that if i do that, i can't use
Item.Collection.Remove(CollectionItem);
because it doesn't delete the association
but i can do that
Contexte.CollectionSet.Remove(CollectionItem);
i don't have this problem with ICollection ... what is the difference ?
Moreover changing ICollection to ObservableListSource can make trouble to serialize the entities ...
What are the best way to doing that ?
Thanks
精彩评论