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

Is there a Way to get CodeOnly Mapping working with ObservableCollection

1 Answer 33 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.
Matthias
Top achievements
Rank 1
Matthias asked on 15 Jul 2015, 12:18 PM

Is there a Way to get CodeOnly Mapping working with ObservableCollection instead of IList the Subject says all.

In many of our Projects we customized the Codegeneration to ObservableCollection.

 

 

1 Answer, 1 is accepted

Sort by
0
Kaloyan Nikolov
Telerik team
answered on 17 Jul 2015, 11:32 AM
Hello Matthias,

Telerik Data Access supports collection properties of type ObservableCollection<T>, TrackedList<T>, TrackedBindingList<T> and IList<T> and all derived classes. 

Duo to slide issue with the type inference you are most probably not able to map those properties correctly. To solve this problem you should hint the inverse type when you map this collection as shown bellow: 
configuration.HasAssociation<Book>(x => x.Books).WithOpposite(x => x.Publisher);

If you map the properties in this way you will be able to use ObservableCollection<T>.

You should be informed that there are some known issues with the ObservableCollections like if you add an element in a managed collection it will not get persisted if you haven't added it in the context explicitly. if you experience those issues you could consider using TrackedBindingList<T> instead. It is designed to work like the ObservableCollection and you can freely bind it in WPF application for example. The TrackedBindingList<T> should not have the problem mentioned for ObservableCollection.

I've registered this issue in our bug tracking system so that we can fix it in our upcoming releases.

Should you have any further questions do not hesitate to get back to us. 

Regards,
Kaloyan Nikolov
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Tags
General Discussions
Asked by
Matthias
Top achievements
Rank 1
Answers by
Kaloyan Nikolov
Telerik team
Share this question
or