如何使用 DBContext Generator 将 ICollection 与 EntityFramework 4.1 绑定
我想知道如何使用简单的数据绑定(grid.datasource = xxxx) 使用 DBContext Generator 和实体框架 4.1;
使用 POCO 实体生成器,我能够做到
Grid.DataSource = Entity.MyChildreCollection;
(可能是因为 Poco 实体生成器使用 FixUp Collection),
但是使用 DBContext Generator,此属性是 ICollection,因此无法直接绑定。
将实体集合绑定到网格的最佳实践是什么?
我尝试将 T4 模板从 HashSet
更改为
ObservableListSource<T>
(with ObservableListSource<T> : ObservableCollection<T>, IListSource)
我注意到如果我这样做, 我无法使用,
Item.Collection.Remove(CollectionItem);
因为它不会删除关联
,但我可以这样做,
Contexte.CollectionSet.Remove(CollectionItem);
我的 ICollection 没有这个问题......有什么区别?
此外,将 ICollection 更改为 ObservableListSource 可能会给序列化实体带来麻烦......
最好的方法是什么?
谢谢
I would like to know how to use simple databinding (grid.datasource = 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论