实体框架 Datagridview 绑定
我希望能够将 datagridview 绑定到实体框架数据库中存储的信息。我只想显示实体框架中存储的信息的子集,并且到目前为止一直使用类似于以下内容的命令来执行此操作。
Dim x = (from store as stores
in storeentity select store.name,
store.number, store.store_manager.name)
datagridview1.datasource = x
我现在希望能够做到这一点,但能够修改 datagridview 中返回的行并将更改返回到数据库。目前这不起作用,因为我返回的是匿名类型。 store.store_manager.name
是存储在由 FK 链接的另一个表中的属性。
任何人都可以提供有关如何执行此操作并仍然跟踪对象的任何指导吗?在过去的四个小时里,我尝试使用各种方法来实现此功能,但没有成功。
非常感谢任何帮助,非常感谢。
I want to be able to bind a datagridview to information stored in my entity framework database. I only want to display a subset of the information stored in my entity framework and have so far been carrying this out with a command similar to the following.
Dim x = (from store as stores
in storeentity select store.name,
store.number, store.store_manager.name)
datagridview1.datasource = x
I now want to be able to do this but be able to modify the returned rows in the datagridview and return the changes to the database. This doesnt work at the moment because I am returning an anonymous type. store.store_manager.name
is a property stored in another table linked by a FK.
Can anyone offer any guidance on how to do this and still have it track the objects. I have spent the last four hours trying to get this workng using various methods and have had no luck.
Any help is greatly appreciated, many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 ADO Entity Framework 创建不需要的实体密钥 和 将实体框架对象绑定到 Datagridview C# 了解如何修改 EF 中视图的内容以便可以绑定和编辑。他们可能对你有帮助。
Have a look at ADO Entity Framework creating unwanted Entity Key and Binding Entity Framework objects to a Datagridview C# for how to modify the contents of a view in EF such that you can bind and edit. They might be helpful to you.