Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> EntityView2 VS FindMatches
 

Pages: 1
LLBLGen Pro Runtime Framework
EntityView2 VS FindMatches
Page:1/1 

  Print all messages in this thread  
Poster Message
tprohas
User



Location:
Tucson, AZ
Joined on:
23-Mar-2004 00:00:43
Posted:
257 posts
# Posted on: 06-Mar-2008 19:50:53.  
Version: 2.5
Runtime: 2.0.50727

I having been playing around with these two methods of searching a collection and was wondering if anyone can explain why FindMatches is not doing what I expect.

I have the following two rows in a database table.
EventDescription    StartTime        EndTime
Event 1 description.    3/20/2008 9:00:00 AM    3/20/2008 12:00:00 PM
Event 2 description.    3/17/2008 3:00:00 PM    3/17/2008 6:00:00 PM

I am using the following two blocks of code to search for these events. This code is in the Calendar control DayRender event so it's looping through each day of the month and e.Day is the current day of month in the iteration.

Code:

PredicateExpression filter = new PredicateExpression();
DateTime startDate = e.Day.Date;
DateTime endDate = e.Day.Date.AddDays(1);
filter.Add(new FieldBetweenPredicate(ScheduledVisitFields.StartTime, null, startDate, endDate));
EntityView2<ScheduledVisitEntity> view = this.scheduledVisits.DefaultView;
view.Filter = filter;
if (view.Count > 0)
{
    ScheduledVisitEntity scheduledVisit = view[0];
    if (scheduledVisit != null)
    {
        DateTime startTime = (DateTime)scheduledVisit.StartTime;
        DateTime endTime = (DateTime)scheduledVisit.EndTime;
        e.Cell.Text = scheduledVisit.EventDescription + "<br />" + startTime.ToString("hh:mm tt") + " - " + endTime.ToString("hh:mm tt");
    }
}


Code:

PredicateExpression filter = new PredicateExpression();
DateTime startDate = e.Day.Date;
DateTime endDate = e.Day.Date.AddDays(1);
filter.Add(new FieldBetweenPredicate(ScheduledVisitFields.StartTime, null, startDate, endDate));
List<int> matches = this.scheduledVisits.FindMatches(filter);
if (matches.Count > 0)
{
    for (int i = 0; i < matches.Count; i++)
    {
        ScheduledVisitEntity scheduledVisit = this.scheduledVisits[i];
        DateTime startTime = (DateTime)scheduledVisit.StartTime;
        DateTime endTime = (DateTime)scheduledVisit.EndTime;
        e.Cell.Text = scheduledVisit.EventDescription + "<br />" + startTime.ToString("hh:mm tt") + " - " + endTime.ToString("hh:mm tt");
    }
}


The filter using EntityView2 works correctly and returns the correct entity for the correct day. The FindMatches method always returns the the first row Event 1. I would have expected that both groups of code would return exactly the same thing.

Why is FindMatches not returning the correct match for each day based on the between predicate?
Aaron Prohaska
http://www.verdesoft.com/
 
Top
tprohas
User



Location:
Tucson, AZ
Joined on:
23-Mar-2004 00:00:43
Posted:
257 posts
# Posted on: 06-Mar-2008 19:58:52.  
I think the act of posting a question always makes you think harder about your problem.

My problem isn't that the FindMatches method is returning the incorrect entity, I think. It's really that the for loop I'm using to get my matching entity is incorrect. I'm using a zero based loop and with count of one always returns 0 as the index. So the first entity in the collection is always return. In this case I am expecting the index to be 1 to bring back the second database row.

So how do I get the correct index to pass to the collection?


Aaron Prohaska
http://www.verdesoft.com/
 
Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8060 posts
# Posted on: 06-Mar-2008 21:24:29.  
tprohas wrote:
So how do I get the correct index to pass to the collection?

Code:
ScheduledVisitEntity scheduledVisit = this.scheduledVisits [ matches[i] ];

David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.