views:

251

answers:

0

how i can insert a table from one datacontext say table1 to be inserted into other datacontext using linq in mvc without using insertonsubmit(). my user code is following

Public Class PayController Inherits System.Web.Mvc.Controller

'
' GET: /Pay/
Private t As New PayRollMVC.DataContext1()
Private c As New PayRollMVC.DataContext2()

Function pay() As ActionResult
    Dim n = t.ExecuteCommand( _
                    ("insert into database2.dbo.pay ( PKey,StaffMember,StaffMemberBranch,BranchCode,FirstName,LastName,Till,Action,OriginalDateTime,ShiftId) " & _
                     "Select t.PKey,t.StaffMember,t.StaffMemberBranch,t.BranchCode,e.FirstName,e.LastName,t.Till, t.Action,t.OriginalDateTime,s.ShiftID" & _
                    "From database1.dbo.TimeClockData t Join database1.dbo.EEEUser e On t.StaffMember=e.UserCode " & _
                    "And t.StaffMemberBranch = e.BranchCode left join database2.dbo.Shift s on (convert(varchar(20),t.OriginalDateTime,108) " & _
                    "between s.Start And s.[End])where t.Pkey not in (select Pkey from database2.dbo.pay)"), c.pays)

    Dim p = From l In c.pays _
            Select l

    Return View(p)

End Function

End Class