The initial filter on BoxCollection returns correct.
BoxCollection = 552
Running the releaseId filter on boxView, returns a count of 0. It should return a count of 28.
I switched it to where i'm not running the releaseId filter on the view, which I realized was unneccesary and made it to run on the boxCollection, so...
Dim boxCollection As New BoxOfficeTransactionHistoryCollection()
Dim filter As New PredicateExpression()
filter.Add(PredicateFactory.CompareValue(BoxOfficeTransactionHistoryFieldIndex.UnitNumber, ComparisonOperator.Equal, unitNumber))
filter.Add(PredicateFactory.CompareValue(BoxOfficeTransactionHistoryFieldIndex.ShowDateTime, ComparisonOperator.GreaterEqual, startDate))
filter.Add(PredicateFactory.CompareValue(BoxOfficeTransactionHistoryFieldIndex.ShowDateTime, ComparisonOperator.LesserThan, endDate))
filter.Add(PredicateFactory.CompareValue(BoxOfficeTransactionHistoryFieldIndex.ReleaseId, ComparisonOperator.Equal, releaseId))
boxCollection.GetMulti(filter)
This sucessfully returns a boxCollection.Count = 28, which is correct. Now I did the following...
Dim boxView As New EntityView(Of BoxOfficeTransactionHistoryEntity)(boxCollection)
Dim proj As New List(Of IEntityPropertyProjector)()
proj.Add(New EntityPropertyProjector(BoxOfficeTransactionHistoryFields.ReleaseId, "ReleaseId"))
proj.Add(New EntityPropertyProjector(BoxOfficeTransactionHistoryFields.BookingNumber, "BookingNumber"))
proj.Add(New EntityPropertyProjector(BoxOfficeTransactionHistoryFields.ShowDateTime, "ShowDateTime"))
Dim projection As New DataTable
boxView.CreateProjection(proj, projection, False)
Return projection
EDIT: I managed to fix this and get it to where it returns with a count of 28. I realized the problem as well, as explained below...
Here is the SQL I have been using on the 28 rows to return my 4 distinct rows...
SELECT DISTINCT
ReleaseId,
BookingNumber,
Convert(varchar, ShowDateTime, 108) As ShowDateTime
FROM @TempTable
As Otis said, I believe it IS due to the ShowDateTime field. As you can see in the SELECT DISTINCT, I am converting the ShowDateTime to a varchar, the 108 trims the date off, effectively making it just a time in the hh:mm:ss format. So the DISTINCT is ran and looks for unique Times, instead of unique Date/Times. This is why the projection returns 28 rows, because there is 4 unique times for each of the 7 days (thus 2
.
Is there a way I can filter it this way, where I tell the view or the projection to filter the ShowDateTime by Time only, just how i'm doing it in the SQL above?