0

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.

Salah Akbari
  • 39,330
  • 10
  • 79
  • 109
  • So can you not add another join? – kaffekopp Nov 06 '18 at 07:48
  • 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? – beginnerlaravelvue Nov 06 '18 at 07:50
  • possible duplicate: https://stackoverflow.com/questions/373541/how-to-do-joins-in-linq-on-multiple-fields-in-single-join – Prasad Telkikar Nov 06 '18 at 07:52
  • 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? – Abdullah Wajahat Nov 06 '18 at 07:52
  • Yes it is a duplicate. Thanks for this – beginnerlaravelvue Nov 06 '18 at 07:57
  • 1
    Possible duplicate of [How to do joins in LINQ on multiple fields in single join](https://stackoverflow.com/questions/373541/how-to-do-joins-in-linq-on-multiple-fields-in-single-join) – Abdullah Wajahat Nov 06 '18 at 08:02

1 Answers1

2

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

on new { t1.TRANSACTIONID, t1.STORE } equals new { t2.TRANSACTIONID, t2.STORE }
Salah Akbari
  • 39,330
  • 10
  • 79
  • 109