Question : LINQ Query

I have the function which uses a 2 LINQ Queries to
1) get all the timesheet entries from a particilur date.
2) count the time for these entries.

Is there a way to make this 1 query?

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
Public Function GetTIMESHEETsMonday() As Double

        Dim Monday As Date = GetThisMondayDate()

        Dim totalTime = From t In Me.ObjectContext.TIMESHEETs
                            Where t.TaskDate = Monday
                            Select t

        If totalTime.Count <> 0 Then
            Return Aggregate T In totalTime Into Sum(T.TaskTime)
        Else
            Return 0
        End If

    End Function

Answer : LINQ Query

Sorry error in last post
1:
2:
3:
4:
5:
Dim query = From t In ObjectContext.TIMESHEETs _
            Where t.TaskDate = Monday _
            Select t.TaskTime

Dim sum As Integer = IIf(query IsNot Nothing, query.Sum(), 0)
Random Solutions  
 
programming4us programming4us