vb.net - How to write one to one LINQ Query -
i beginner , learning linq in vb.net. have 1 table a column
workid (pk) , idaccount.
and table b column
bid(pk), bname , workid(fk) .
there one 1 relationship between table , table b.
now want put/copy both table data table c has column as
workid, idaccount, bname. don't know how write linq query , both table data , put in 3rd table. please me. have tried below till now. below code snippet of project.
public function hello(byval dt a, byval dtm b) dim dtreturn new c if dt isnot nothing andalso dt.any dim row workorderrow `row corresponding c table each r in dt row = dtreturn.newworkrow 'traversing row row .workid = r.workid .idaccount = r.idaccount end dtreturn.addworkorderactivityrow(row) next end if end function
its working totally fine need put data of b too. above code able copy data of table a. kindly guide me how should write linq query , traverse it.
i should able like
row .workid = x.workid .idaccount = x.idaccount .bname = x.bname end
x being row generated query.
you join result of , b first (sample here: https://msdn.microsoft.com/en-us/library/bb311040.aspx), create rows of c. easier.
dim newcs = (from in tablea join b in tableb on a.workid equals b.workid select new tablec { .workid = a.workid, .idaccount = a.idaccount, .bname = b.bname })
Comments
Post a Comment