简体   繁体   English

如何使用ASP.Net MVC通过“加入视图”显示LINQ lamda表达式结果?

[英]How to display LINQ lamda expression result with Join to a View using ASP.Net MVC?

I have a problem displaying the result from a linq lambda expression to a view. 我在将linq lambda表达式的结果显示到视图时遇到问题。

Here is my code: 这是我的代码:

   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);

This problem was made complicated by the join that I used here so now I don't know how will I transfer the data to the view like I did without a join. 我在这里使用的联接使这个问题变得复杂,所以现在我不知道如何像不使用联接那样将数据传输到视图。

var idSearchJoin = payoutdb.payout_transaction.Include(x => x.payout_remittance).Where(x => x.payout_remittance.Any(y => y.senderRefId == searchTxt)); Try this. 尝试这个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM