Is there a Way to get CodeOnly Mapping working with ObservableCollection

2 posts, 0 answers
  1. Matthias
    Matthias avatar
    2 posts
    Member since:
    May 2015

    Posted 15 Jul 2015 Link to this post

    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.



  2. Kaloyan Nikolov
    Kaloyan Nikolov avatar
    118 posts

    Posted 17 Jul 2015 Link to this post

    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. 

    Kaloyan Nikolov
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  3. DevCraft banner
Back to Top