Many to many as default

5 posts, 1 answers
  1. ie
    ie avatar
    7 posts
    Member since:
    Feb 2007

    Posted 31 May 2010 Link to this post

    Hi guys,

    I just started to use the OpenAccess ORM. I want to understand better some designer logic.

    My sample DB script (I'm using SQL Server 2008 Express):

    CREATE TABLE Category 
        Id uniqueidentifier NOT NULL PRIMARY KEY
        Name nvarchar(50) NOT NULL
        Description nvarchar(maxNULL
     
    GO 
     
    CREATE TABLE Product 
        Id uniqueidentifier NOT NULL PRIMARY KEY
        Name nvarchar(255) NOT NULL
        Description nvarchar(maxNULL
     
    GO 
     
    CREATE TABLE Category2Product 
        ProductId uniqueidentifier NOT NULL FOREIGN KEY REFERENCES Product(Id), 
        CategoryId uniqueidentifier NOT NULL FOREIGN KEY REFERENCES Category(Id), 
        PRIMARY KEY (ProductId, CategoryId) 

    The table Category2Product is recognized as a collection. That is what I was expected. But, "Many to many" flag is not set by default (MS did it in their EF editor). 
    I suppose that the only reason of such tables is to define a many-to-many relation. Is "Many to many" flag not set for some reason? If so, please advice. 

    Additionaly, I could suggest to give by default more user-friendly names for field and inverse list. For my case the field name should be "products" and the inverse list name should be "categories".

    Also, I noted that after switch from 'Collection' option to 'Map' and vice versa, combobox 'Owner Class', 'Many to many' flag and 'Inverse List Name' lose theirs value. I think it is not very user friendly, but, of course, nothing serious.

    P.S. I closed 'Telerik ORM Wizard', but I got some visual artifact. See second attached picture.
  2. Answer
    Serge
    Admin
    Serge avatar
    375 posts

    Posted 01 Jun 2010 Link to this post

    Hello ie,

     I am glad you are showing interest in our product. As to you first point as we provide support for 1:n relationships though a join table Telerik OpenAccess ORM cannot be sure whether it is a m:n or a 1:n relationship. That is why this is left to the user if you use the Forward Mapping Wizard.

    As to the names and user interface we have decided to not improve on this matter in the wizards as in the 2010 Q1 release of OpenAccess we introduced the new Domain Model approach which is basically a graphical designer for entities (similar to the one that you have used with Entity Framework). In it we have proper naming strategies for the entity names and a whole new user interface. As a matter of fact in the new designer we by default assume many to many relationships in this case.

    As to the visual glitch you have experienced this might be to the nature of the new WPF architecture of Visual Studio and unfortunately I am unable to reproduce it.

    I do hope this clarifies the big picture here. If you have further question please contact us back.

    Best wishes,
    Serge
    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.
  3. DevCraft banner
  4. ie
    ie avatar
    7 posts
    Member since:
    Feb 2007

    Posted 01 Jun 2010 Link to this post

    Hello Serge,

    Thank you for pointing at the OpenAccess Domain Model approach. I didn't realize that this is a more modern way to work with OpenAccess. I'll try it and contact you back, if I have some question or suggestions.

    Thanks,
    Ivan.
  5. Hugo Augusto
    Hugo Augusto avatar
    55 posts
    Member since:
    Jul 2004

    Posted 30 Jun 2010 Link to this post

    Hi,

    I am also trying the new Domain Model Designer with a database that has these 3 tables:

    Users
        UserID
        ...
    Groups
        GroupID
        ...
    User_groups
        UserID
        GroupID

    After creating the model, i got all the tables but without the obvious "many to many" relationship. Is this normal? How should I create the relationships? Do I make an association from Users to User_groups and then another one from Groups to User_groups? I'm asking because i tried to do this and a class was created for the User_groups table.

    I also hope you don't take too long to include documentation or videos about using this new approach and the designer because I'm in the dark here.

    Finally, I want to ask you opinion on how to proceed with a web application with 3 tiers (Data Access layer, Business Logic layer and Presentation layer) and Open Access ORM using the Domain Model approach. The problem here is that my DAL is database independent since it uses dataproviders to connect to the selected database. The BLL is only making the connection between the presentation layer and the DAL.

    Presentation layer < BLL < DAL using providers for different databases

    Should I replace my current DAL with the new Domain Model? Should I keep the BLL?

    Hope you can help

  6. Serge
    Admin
    Serge avatar
    375 posts

    Posted 02 Jul 2010 Link to this post

    Hi Hugo Augusto,

     This is in fact the correct way to specify many to many relationships. The rule is "if a table has only two columns and they are both foreign keys it is by default an join table". You can have a look at the EmployeeTerritories table in the Northwind database as an example of a setup that is working.

    We are currently in the process of revising our documentation and by Q2 we will have uploaded it to our side. You can have a look through the documentation installed with Telerik OpenAccess ORM on your machine, you can find it in the OpenAccess directory in the start menu.

    The best practices for development of an N-Tier application with Telerik OpenAccess ORM is described in this knowledge base article. You can have a look at the complete source code in this code library example. The example shows the use of OpenAccess object only as a means to retrieving the data and then translating them to plain objects trough the assembler pattern. While this might look as a unnecessary effort in fact in the long run it would save you a lot of time.

    I hope this helps and please do not hesitate to contact us back if you need further assistance.

    All the best,
    Serge
    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
Back to Top
DevCraft banner