Anup
Anup

Reputation: 9738

Linq Update Query with Multiple Tables

I am confused how to convert the following query in Linq.

UPDATE TABLETEMP 
SET FLD1= A.SCODE,FLD2=B.STATUS 
FROM TABLETIME A,TABLETIME1 B,TABLETEMP C 
WHERE A.COM=B.COM 
AND A.SCODE=B.SCODE 
AND A.CODE=C.CODE 
AND A.SDATE=C.TDATE1

Anyone having any idea How to do this with all the conditions?

Upvotes: 0

Views: 749

Answers (1)

Shilpa Soni
Shilpa Soni

Reputation: 2142

var tble =   (from A in datacontext.TABLETIMEs
              from B in datacontext.TABLETIME1
              from C in datacontext.TABLETIME3 
              from D in datacontext.TABLETEMP
               where A.COM=B.COM &&
               A.CODE=C.CODE &&
               A.SDATE=C.TDATE1
               select new {A, B, C, D}).FirstOrDefault();

   if(tble !=null )
  {
    tble.FLD1=tble.SCODE;
    tble.FLD2=tble.STATUS;
    datacontext.Submitchanges();
  }

Upvotes: 1

Related Questions