This is a migrated thread and some comments may be shown as answers.

Sorting lazy loaded collections

10 Answers 111 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Robert
Top achievements
Rank 2
Robert asked on 17 Feb 2009, 05:01 PM
Anyone know how I can specify an order by clause for queries that are generated by OpenAccess for lazy loaded collections?

Thanks,
Robert

10 Answers, 1 is accepted

Sort by
0
Accepted
Jan Blessenohl
Telerik team
answered on 19 Feb 2009, 12:35 PM
Hi Robert,
If the collection is mapped to a join table the ordering stays the same as you added the objects.

If you map the collection to backward reference you can set a static ordering in  the mapping. This can not be changed at runtime. To use case specific ordering you have to implement a query in a property.

I have attached an example that shows both cases.

For changing the ordering in the mapping you can use this mapping settings:

          <class name="A">
            <field name="bs">
              <collection>
                <extension key="inverse" value="{auto}" />
                <extension key="ordering" value="name desc" />
              </collection>
            </field>
          </class>

The value can contain fields of the object itself but also fields of referenced objects by specifying the path.

All the best,
Jan Blessenohl
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Robert
Top achievements
Rank 2
answered on 19 Feb 2009, 05:57 PM
Works like a charm!  Is there a way to set this in the Wizards?  I looked and didn't find any and perhaps therein lies my error, in relying on the UI too much.  However, in a scan of the docs, using the keyword "ordering" I didn't find anything there either.  Is this functionality documented anywhere?

Thanks,
Robert
0
Robert
Top achievements
Rank 2
answered on 13 Apr 2009, 09:47 PM
Hi There,

I have  a situation where I have a lazy loaded collection I'd like to order but the Order By field name is not immediately available on the object type of the collection.  The sort field is in a referenced table so how do I sort on it?  I tried a few things and couldn't find one that worked.

Eg.  ProductItem
               Manufacturers collection of Manufacturer
Manufacturer refers to a FIrm table which has a field of Name on which we'd like to sort on.

Thanks,
Robert
0
Jan Blessenohl
Telerik team
answered on 14 Apr 2009, 08:28 AM
Hello Robert,
Using the reference name dot fieldname should work.

       <class name="A">
            <field name="bs">
              <collection>
                <extension key="inverse" value="{auto}" />
                <extension key="ordering" value="flrm.name desc" />
              </collection>
            </field>
          </class>

Sincerely yours,
Jan Blessenohl
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Robert
Top achievements
Rank 2
answered on 15 Apr 2009, 05:29 PM
I can't seem to get this to work.  Judgeing by the error messages I'm getting, it seems as though the order by doesn't work because a join is not occuring to lowest level table on which I need to sort.  Perhaps this lower level table is being lazy loading and as such isn't being included in the original query.

Do I need to create a fetch plan or something to ensure that that child tables are always included in queries?

Thanks,
Robert
0
Jan Blessenohl
Telerik team
answered on 16 Apr 2009, 05:03 PM
Hello Robert,
I have looked into your problem and found some weird behavior as well. I will dig into it tomorrow and see if I can find a way for your to use it.

Sincerely yours,
Jan Blessenohl
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Accepted
Jan Blessenohl
Telerik team
answered on 20 Apr 2009, 03:00 PM
Hello Robert,
We have fixed your problem an we will try to give you a nightly build if it is urgent for you.

Regards,
Jan Blessenohl
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Robert
Top achievements
Rank 2
answered on 20 Apr 2009, 03:14 PM
Excellent!  It is not urgent.  When can we expect another public release?

Also, it sounds like this was a bug.  Does that mean there are some points coming my way? ;-)
0
Dimitar Kapitanov
Telerik team
answered on 21 Apr 2009, 06:13 AM
Hi Robert,
Your Telerik points were updated.

Regards,
Dimitar Kapitanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jan Blessenohl
Telerik team
answered on 24 Apr 2009, 09:32 AM
Hello Robert,
The custom build is now available for download. Please login into the telerik web page and browse the download section.

Best wishes,
Jan Blessenohl
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
Robert
Top achievements
Rank 2
Answers by
Jan Blessenohl
Telerik team
Robert
Top achievements
Rank 2
Dimitar Kapitanov
Telerik team
Share this question
or