简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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