J
john
LINQ works a lot like an Access DB Recordset in the way it functions, one of
the things I could do in Access is refer to the Fields thru a Variable as
below allowing me to Iterate over the Recordset with a test or slight change
to field names. Is there a way to Replicate this Method in LINQ, I've tried
setting the Variable as an Object "Dim tDayID AS Object = "tem.Day" & 1" but
it did not work?
IN ACCESS:
Dim DaI As String
DaI = "DayID" & 1
For da = 1 To 7
With RS1
If RS2.Fields(DaI) <> 0 Then
.Edit
Else
.AddNew
End If
!TimeValue = RS2.Fields("Day" & da)
!DayDate = dat
!Locked = False
!MemoNote = RS2.Fields("M" & da)
!LogID = RS2!GroupID
.Update
End With
Next da
Here is a snippet of the LINQ where I would like the tDayID to be the
Variable of LINQ Field and get its Value for testing (Code snippet not
Complete just a Sample):
Dim tDayID As Object
Dim dbTemp As New DataTempDataContext
Dim GetTemp = (From tem In dbTemp.tblTemps _
Where tem.EmployeeID = Me.HiddenEmplID.Value _
Select tem)
'Iterate over Temp Table records to Update Existing TimeRecord
For Each tem In GetTemp
tDayID = "tem.Day" & 1
da = 0
For da = 1 To 7 'Iterate over Temp Days to write Time Values to
Time Record
For Each ti In time 'Iterate over TimeRecord Table records
to find match
'HERE IS WHERE THE FIELD VARIABLE IS USED AND WOULD BE RESET DURING LOOP
If ti.DayID = tDayID Then
ti.ClientID = tem.ClientID
ti.ClientDesc = tem.Client
ti.LogID = tem.LogID
ti.PeriodID = tem.PeriodID
ti.ProjectDesc = tem.Project
ti.ProjectID = tem.ProjectID
ti.Task = tem.TaskID
ti.TaskDesc = tem.Task
ti.DayDate = dat
ti.TimeValue = tem.Day1
ti.Memo = tem.M1
ti.DayID = tDayID
End If
Next
Next da
Next
the things I could do in Access is refer to the Fields thru a Variable as
below allowing me to Iterate over the Recordset with a test or slight change
to field names. Is there a way to Replicate this Method in LINQ, I've tried
setting the Variable as an Object "Dim tDayID AS Object = "tem.Day" & 1" but
it did not work?
IN ACCESS:
Dim DaI As String
DaI = "DayID" & 1
For da = 1 To 7
With RS1
If RS2.Fields(DaI) <> 0 Then
.Edit
Else
.AddNew
End If
!TimeValue = RS2.Fields("Day" & da)
!DayDate = dat
!Locked = False
!MemoNote = RS2.Fields("M" & da)
!LogID = RS2!GroupID
.Update
End With
Next da
Here is a snippet of the LINQ where I would like the tDayID to be the
Variable of LINQ Field and get its Value for testing (Code snippet not
Complete just a Sample):
Dim tDayID As Object
Dim dbTemp As New DataTempDataContext
Dim GetTemp = (From tem In dbTemp.tblTemps _
Where tem.EmployeeID = Me.HiddenEmplID.Value _
Select tem)
'Iterate over Temp Table records to Update Existing TimeRecord
For Each tem In GetTemp
tDayID = "tem.Day" & 1
da = 0
For da = 1 To 7 'Iterate over Temp Days to write Time Values to
Time Record
For Each ti In time 'Iterate over TimeRecord Table records
to find match
'HERE IS WHERE THE FIELD VARIABLE IS USED AND WOULD BE RESET DURING LOOP
If ti.DayID = tDayID Then
ti.ClientID = tem.ClientID
ti.ClientDesc = tem.Client
ti.LogID = tem.LogID
ti.PeriodID = tem.PeriodID
ti.ProjectDesc = tem.Project
ti.ProjectID = tem.ProjectID
ti.Task = tem.TaskID
ti.TaskDesc = tem.Task
ti.DayDate = dat
ti.TimeValue = tem.Day1
ti.Memo = tem.M1
ti.DayID = tDayID
End If
Next
Next da
Next