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

Data Saving Child Records Order Changed

7 Answers 75 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
devoas
Top achievements
Rank 1
devoas asked on 02 Jul 2010, 01:21 PM
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

7 Answers, 1 is accepted

Sort by
0
IT-Als
Top achievements
Rank 1
answered on 06 Jul 2010, 04:43 PM
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
0
Petko_I
Telerik team
answered on 06 Jul 2010, 06:48 PM
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
0
devoas
Top achievements
Rank 1
answered on 06 Jul 2010, 07:50 PM

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.

 

 

0
IT-Als
Top achievements
Rank 1
answered on 07 Jul 2010, 07:57 AM
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
0
Petko_I
Telerik team
answered on 08 Jul 2010, 08:06 PM
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
0
Michael
Top achievements
Rank 1
answered on 04 Jul 2013, 07:53 PM
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
0
Damyan Bogoev
Telerik team
answered on 08 Jul 2013, 01:31 PM
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.
Tags
Getting Started
Asked by
devoas
Top achievements
Rank 1
Answers by
IT-Als
Top achievements
Rank 1
Petko_I
Telerik team
devoas
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Damyan Bogoev
Telerik team
Share this question
or