PrefetchPath

Posts   
 
    
MikeG
User
Posts: 23
Joined: 17-Dec-2006
# Posted on: 05-Feb-2007 12:27:46   

Hi,

I'm beginning to make some progress with the learning curve, and am experience progress! Yay! simple_smile

Thank you to everyone who has answered my questions! I would have said it on the other messages, but they were closed simple_smile

THANK YOU!

And... Can you please help me understand how to do this:

We have two tables:

Table: Venue Fields: Id, Name, Address

Table: Note Fields: Id, VenueId, Comment, CreatedDateTime

Venue is the parent table, and Note is the child table. They are related on Venue:Id <--> Note.VenueId

I am building a webform that shows Venues, and all of the Notes associated with that Venue. So it might look like this:

Venue 1 Note 1 Note 2 Note 3

Venue 2 Note 1 Note 2

I would like the sorting to work, so that the most recent note, along with it's Venue and the rest of its notes is shown first.

So if the most recent Note recorded is associated to Venue 2, then the output would be:

Venue 2 Note 2 Note 1

Venue 1 Note 3 Note 2 Note 1

So, the sorting is really happening on the Note, based on the CreatedDateTime.

I am beginning to understand that somehow PrefetchPath and Sort should work together to make this happen.

Can you please tell me how?

And, after the data is fetched, how can I access it?

Right now, I am doing it like this (it isn't sorting yet):


   VenueCollection venues = new VenueCollection();
   venues.GetMulti(null);

   StringBuilder sb = new StringBuilder();

   if (venues.Count > 0)
   {
       foreach (VenueEntity venue in venues)
       {
           sb.Append("<table>");
           sb.Append("<tr><td>" + venue.Name + "</td></tr>");

           NoteCollection notes = venue.Note;
           if (notes.Count > 0)
           {
               foreach (NoteEntity note in notes)
               {
                   sb.Append("<tr><td>" + note.Note + "</td></tr>");
               }
           }
           else
           {
               sb.Append("<tr><td>We have no notes for this venue yet.</td></tr>");
           }
           sb.Append("</table><BR>");
       }
   }
   else
   {
       sb.Append("Add some Venues please.");
   }
    
   return sb.ToString();


Thank you in advance for your help!

As the learning curves unfolds, I become more and more excited about what LLBLGen is making possible. There is so much to learn, and yet, bit by bit, it begins to come together.

Whew!

Frans, it's so awesome how you're able to create such great work! Cheers!

Mike

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 05-Feb-2007 15:48:43   

Hello,

you can use the getmulti as it:

RelationPredicateBucket rpb=new relationpredicatebucket();
rpb.relation.add(EntityClasses.VenueEntity.Relations.NoteEntityUsingVenueId)
SortExpression sort =new sortExpression(new sortClause(HelperClasses.NoteFields.CreatedDateTime,SortOperator.Descending))

VenueCollection venues = new VenueCollection();
venues.GetMulti(null,0,sort,rpb.relations);

It will sort the result by the createddatetime of your note.