One to Many Relation

Thread is closed for posting
4 posts, 1 answers
  1. Bernard
    Bernard avatar
    6 posts
    Member since:
    Feb 2009

    Posted 11 Mar 2009 Link to this post


    I'm starting with Open Access ORM and i'm making some experiment to try to understand how to work efficiently with it.  But it's not clear at all.

    Let say i have a class Customer and a class CustomerContact.  There can be many CustomerContact for a customer.  So in the reverse engeneer wizard i selected both class and went to the client reference into CustomerContact class to check the one to many relation.

    When i add Customer it work fine.  If i add a CustomerContact to the CustomerContact collection from Customer it does not work.  I have to reference and existing Customer before adding it to the collection??? 

    Honestly, the fact of adding the CustomerContact to this collection should be enough to associte them.  Am i missing something?

    Another Question is What is the best way to create those relation?  In visual studio ado net we have a nested relation that work fine?  There is nothing like this in ORM?  When i try to add Customer as datasource, i see contact but like a field, not like a nested table


  2. Chris
    Chris avatar
    23 posts
    Member since:
    Feb 2009

    Posted 11 Mar 2009 Link to this post

    Are you commiting the transaction?
  3. Bernard
    Bernard avatar
    6 posts
    Member since:
    Feb 2009

    Posted 11 Mar 2009 Link to this post

    Yes i do commit the transaction.
    If i add only a customer it's fine.
    if i try to add a customercontact to the contact list of the new customer it hang on the commit
    saying the the idclient of the customercontact need to be set.
    so to solve it i need to refer the customer object to which i add the contact before adding it to the list
    then the commit work fine.

    Why do i have to do this?  Juste add the contact to the customer should work no?
    I Have checked the CRUD example with Telerik OpenAccess ORM and i see that it work like i want, why my reverse engeneering does not work....   If there was clear documentation it would help a lot.    I spend more time searching for answer thant producing anything.

  4. Answer
    Alexander avatar
    727 posts

    Posted 12 Mar 2009 Link to this post

    Hi Bernard,

    Although you have reverse mapped your classes you can still use some of the Forward mapping wizard options. Open the wizard and select the CustomerContact collection from the treeview on the left. Enable the "Manage collection" checkbox and you will have this reference automatically set in the CustomerContact object.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top