Fluent API Ordering of One-to-Many

Thread is closed for posting
2 posts, 1 answers
  1. John
    John avatar
    5 posts
    Member since:
    Sep 2012

    Posted 26 Jul 2011 Link to this post


    I was wondering if there is a way to specify the ordering of list elements when defining a one-to-many association using the Fluent API?

    For example - an equivalent of the following which can be specified in the config file mapping.


    <field name="studentList">
     <collection> <!-- ItemType is Student -->
       <extension key="ordering"
         value="addr.city ascending, addr.street ascending" />
  2. Answer
    PetarP avatar
    754 posts

    Posted 29 Jul 2011 Link to this post

    Hello John,

     You can use the OrderBy method. Here is an example:

    string orderByClause = "Ascending myColum, descending OrderId";
                MappingConfiguration<Product> customerMapping = new MappingConfiguration<Product>();
                TestFluentMappingSource source = new TestFluentMappingSource();
                customerMapping.HasAssociation(x => x.Stores).OrderBy(orderByClause);
    Please have in mind that the OrderBy method is in the 
    Telerik.OpenAccess.Metadata.Fluent.Advanced namespace.

    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top