Convert sql statement to linq with entity framework

2814 views c#
6

How to put multiple on in LINQ Like

var retailTransactionDiscountTrans = 
    (from t1 in context.RETAILTRANSACTIONPAYMENTTRANS
     join t2 in context.RETAILTRANSACTIONTABLEs
     on t1.TRANSACTIONID equals t2.TRANSACTIONID && t1.STORE equals t2.STORE)....;  

I just want to include other ON in LINQ for that join.

answered question

So can you not add another join?

is it the same like INNER JOIN RETAILTRANSACTIONTABLE AS t2 ON t2.TRANSACTIONID = t1.TRANSACTIONID AND t2.STORE = t1.STORE AND t2.TERMINAL = t1.TERMINAL AND t2.DATAAREAID = t1.DATAAREAID If I add multiple joins with the same table?

what exactly are you trying to do here. on is used to reference a column thats common between the tables i don't see the point of having multiple on on the same join could you explain what you are trying to do?

Yes it is a duplicate. Thanks for this

1 Answer

0

You can use anonymous type for this purpose. Something like this:

on new { t1.TRANSACTIONID, t1.STORE } equals new { t2.TRANSACTIONID, t2.STORE }

posted this

Have an answer?

JD

Please login first before posting an answer.