Data Saving Child Records Order Changed

8 posts, 0 answers
  1. devoas
    devoas avatar
    69 posts
    Member since:
    Dec 2009

    Posted 02 Jul 2010 Link to this post

    Hello,

    We have master/detail record, which save an retrieve properly but the sequence in which detail records are added in master collection becomes different after save.  We want make sure the order of Child Records should same as we added in the collection. 

    Please guide how to handle this issue.

    Thanks,
    devoas
  2. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 06 Jul 2010 Link to this post

    Hi Devoas,

    You don't mention if you use forward mapping, but if you do, you can set up (check the box) the "Preserve order" in the forward mapping wizard for your collection property.
    Doing so will add a hidden column in the table so that when you go and fetch the details items (for example Order-OrderLines) you will get them back in the same order they were added.

    Unfortunately, this only works if you map the collection as a "join table" since it needs the extra information on the sequence/order.

    Regards

    Henrik
  3. DevCraft banner
  4. Petko_I
    Admin
    Petko_I avatar
    184 posts

    Posted 06 Jul 2010 Link to this post

    Hi devoas,

    Can you please shed some more light on the scenario which you are trying to handle? Do you use reverse mapping with our Visual Designer or do you use the classic forward mapping wizard? When you forward map a collection Telerik OpenAccess adds a sequence column in the link table so that the collection items are stored in the order of addition.

    We are looking forward to investigating this issue. Do not hesitate to ask other questions in the meantime.


    Greetings,
    Petko_I
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. devoas
    devoas avatar
    69 posts
    Member since:
    Dec 2009

    Posted 06 Jul 2010 Link to this post

    Dear Patko,

     

    Thanks for your reply. Let me explain more on issue we are facing.

     

    We are using Reverse Mapping,  with Master / Detail Table. 

    Now when we add Records in Detail thru Master.Details.Add...  after save in Database we get records in different sequence from what we added to the collection.

    example: records added in OrderLines collection in following sequence.

    Order Lines

    sno.    Product    

    1.    Product1
    2.    Product2
    3.    Product3

    Now after save the resultant records added in Database as following (we have an Identify field in OrderLines Table, which shows the sequence how Telerik added records to database.

    Id    Sno.    Product
    25    3        Product3
    26    1        Product1
    27    2        Product2

    We assume that addition of records to Database should be in the same sequence as added in Collection...

    Hope above details would better explain the problem.

    Thanks,
    devoas.

     

     

  6. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 07 Jul 2010 Link to this post

    Hi Devoas and Petko,

    As I see it the solution is to use the "Preserve order" setting. You can still do this even if you use reverse mapping wizard (not Visual Designer, I think)... after reverse mapping you just do a forward mapping where you set the collection to be mapped as a join table (if not already done during reverse mapping) and specify the Preserve Order on the collection property in the Forward Mapping Wizard.

    Don't you agree Petko?

    Regards

    Henrik
  7. Petko_I
    Admin
    Petko_I avatar
    184 posts

    Posted 08 Jul 2010 Link to this post

    Hi Henrik and devoas,

    That is absolutely correct. Preserving the order can be achieved with a join table and here is a link to our online documentation which further clarifies the case. However, you should be careful, though. When you decide to use the Visual Designer, currently the forward mapping cannot be tricked into understanding the mapped model.  This means that you cannot mix Visual Designer’s features with the Classic Wizard’s ones. Unfortunately, an option for preserving the order of inserts with the Visual Designer reverse mapping is not available yet.

    All the best,
    Petko_I
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Michael
    Michael avatar
    8 posts
    Member since:
    Feb 2012

    Posted 04 Jul 2013 Link to this post

    Hi Petko,

    I am still having the same problem and it appears your link above is broken.

    I am using OpenAccess with SQLite and when I put a list of objects into the database they come out in what appears to be alphabetical order of class type. It is important that they come out in the same order as I put them in. 

    Can you help?

    Regards,
    Michael Baumberger
  9. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 08 Jul 2013 Link to this post

    Hi Michael,

    You could find the article here.

    I am afraid preserving the order of class type is not supported in the product. 

    I am sorry for the inconvenience caused.

    Regards,
    Damyan Bogoev
    Telerik
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
Back to Top
DevCraft banner