ADO.NET 实体 - 需要帮助
我的数据库中有 3 个表,我从数据库创建了一个实体模型,它看起来像这样:
我想做的是将所有 3 个表绑定到 datagridview,并且我使用这样的查询
var result = from t in db.Transactions
from c in db.Categories
from a in db.Accounts
where t.FkCategoryID == c.CategoryID && t.FkAccountID == a.AccountID
select new { t.Description, t.BankReference, t.TransactionDate, c.CategoryName, a.AccountName, a.AccountNr };
效果很好。 但我需要能够使用绑定导航器工具栏来更新事务表
我无法做到这一点使用 linq 查询并将其绑定到 gridview。
有没有办法通过使用实体框架来实现这一点?我的意思是,当我仅将一个表绑定到绑定源时,我可以使用该工具栏删除更新并添加行,但我必须显示所有表,并且只能编辑事务表
提前致谢
i have 3 tables in my database and i created a entity model from database and it looks like this:
what im trying to do is to bind all 3 tables to datagridview and im using a query like this
var result = from t in db.Transactions
from c in db.Categories
from a in db.Accounts
where t.FkCategoryID == c.CategoryID && t.FkAccountID == a.AccountID
select new { t.Description, t.BankReference, t.TransactionDate, c.CategoryName, a.AccountName, a.AccountNr };
this works well.
But i need to be able to update the Transaction table by using the binding navigator toolbar
im not able to do that by using linq query and binding it to gridview.
Is there any way to accomplish that by using entity framework? I mean when i bind only one table to binding source im able to use that toolbar to delete update and add row but i have to show all tables and only be able to edit Transaction table
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

一个建议是为您的查询创建一个数据库视图并映射到该视图而不是连接的表。
One suggestion is to create a database view for your query and map to that instead of the joined tables.