【发布时间】:2019-06-10 09:26:24
【问题描述】:
我在将 linq lambda 表达式的结果显示到视图时遇到问题。
这是我的代码:
var idSearchJoin = payoutdb.payout_transaction // your starting point - table in the "from" statement
.Join(payoutdb.payout_remittance, // the source table of the inner join
transaction => transaction.transid, // Select the primary key (the first part of the "on" clause in an sql "join" statement)
remit => remit.transid, // Select the foreign key (the second part of the "on" clause)
(transaction, remit) => new { Transaction = transaction, Remit = remit }) // selection
.Where(transactremit => transactremit.Transaction.senderRefId == searchTxt);
我在这里使用的连接使这个问题变得复杂,所以现在我不知道如何将数据传输到视图,就像没有连接时那样。
【问题讨论】:
-
.Select(x => x.Transaction)?而且:不要使用join,而是使用导航属性。 -
你能举例说明我应该怎么做吗?我想向视图显示 2 个表的两个值。
标签: asp.net-mvc entity-framework linq lambda