That's how I did it but I'm really not happy with my solution. I sure there is a better way to do it I just don't know what that is.
This is what I've added to my TimeOff Entity class
Private _reportDate As DateTime
Public Property ReportDate() As Date
Get
Return _reportDate
End Get
Set(ByVal value As Date)
_reportDate = value
End Set
End Property
Public ReadOnly Property DailyStatus() As String
Get
Dim sTime, eTime As DateTime
sTime = _reportDate.AddHours(8)
eTime = _reportDate.AddHours(17)
If StartDate <= sTime And EndDate >= eTime Then
Return "All Day"
ElseIf StartDate <= sTime Then
Return "8 AM to " + EndDate.ToShortTimeString
ElseIf EndDate >= eTime Then
Return StartDate.ToShortTimeString + " to 5 PM"
Else
Return StartDate.ToShortTimeString + " to " + EndDate.ToShortTimeString
End If
End Get
End Property
And I've added this to my TimeOffCollection Class
Public Function GetTimeOffByDay(ByVal myDate As Date) As TimeOffCollection
Dim pe As IPredicateExpression = New PredicateExpression
pe.Add(PredicateFactory.CompareValue(TimeOffFieldIndex.StartDate, _
ComparisonOperator.LessEqual, myDate.AddDays(1).AddMilliseconds(-1)))
pe.AddWithAnd(PredicateFactory.CompareValue(TimeOffFieldIndex.EndDate, _
ComparisonOperator.GreaterThan, myDate))
Dim TimeOff As New TimeOffCollection
TimeOff.GetMulti(pe)
Dim aTimeOff As TimeOffEntity
For Each aTimeOff In TimeOff
aTimeOff.ReportDate = myDate
Next
Return TimeOff
End Function
I can then bind this to a gridview to display the name and daily status.
This works but, like I said, I'm sure it's really the wrong way to go about doing it.
My initial thought is that DailyStatus should be a function (not a property) that takes the date as a parameter and returns a string. Doing it that way I wasn't able to bind it to my gridview.
I also don't like the idea of adding the reportdate property since it really has nothing to do with my entity.
I realize these are more OO type questions than LLBLGen but I've yet to find a good OO programming forum.
Thanks,
Warren