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

Reverse Engineering

8 Answers 178 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
acm2001
Top achievements
Rank 2
acm2001 asked on 04 Feb 2009, 03:27 PM
I have been using OpenAccess with some simple tables 1-1 relationships and some 1-m relationships. Everything was going fine. I then set up a m-m relationship in the SQL database and tried to reverse engineer it.

I took a look at http://www.telerik.com/help/openaccess-orm/map-collection-fields-many-many.html which i only found tonight even though i was using the product for over 2 months.

and want to do "OpenAccess ORM supports many-to-many mappings where two collections share a common link table."

I saw the page http://www.telerik.com/help/openaccess-orm/reverse-engineering-field-many-to-many.html but cant get the many to many check box to come on. it is grayed out.

my table has 2 primary key ids which relate back either side to the other 2 tables and their corresponding primary keys.

should i be setting the middle link table as a collection or a map? i am trying map but the many to many box wont come up.

thanks
alan

8 Answers, 1 is accepted

Sort by
0
acm2001
Top achievements
Rank 2
answered on 04 Feb 2009, 03:59 PM
Thanks
I have found the answer by chance.

I only saw the list of integers, string characters etc and didnt realise that in the list was also my other class objects. when i chose a class object i was able to then choose the check box. everything working really well now.

the doucmentation is good but i could only find it coming through google. it might be useful to put a link to it from the demo pages.
the demos are so good for asp.net controls that automatically many people may go to the demos and then be stuck

thanks
issue resolved
great product.
0
Alexander
Telerik team
answered on 05 Feb 2009, 08:53 AM
Hello Alan,

It is great to hear that you are satisfied with our product.
The documentation and other materials for all our products are available on the support page. You could also take a look at our Knowledge base and Code library. Any further feedback would be greatly appreciated.

Kind regards,
Alexander
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
acm2001
Top achievements
Rank 2
answered on 05 Feb 2009, 08:55 AM
As a follow up to this,
I saw the article at
http://www.telerik.com/support/kb/orm/general/handling-m-n-relation-with-additional-link-information.aspx

which discussed the following:

Handling m:n relation with additional link information

OpenAccess can handle collections of persistence capable objects. Both one-to-many (1:n) and many-to-many (m:n) type of relations are supported. To maintain an m:n relation between 2 classes, say A and B, OpenAccess uses a join table. This join table stores the primary key values of the related objects. In some cases we might want to have some additional data pertaining to each m:n record. Such cases cannot be handled by the built-in join table mechanism."

I have a database situation exactly as described and want to reverse enginneer it. If I select Collection then i lose the class. If i select class than i dont get the m-n mapping relationship.

Also I dont understand the difference between Collection Mapping and Map Mapping ?

What am i missing?

Thanks
Alan
0
Ady
Telerik team
answered on 05 Feb 2009, 03:09 PM
Hi Alan,

The article was written to target the basic concept of handling a m:n relation with extra link information. It was mapped using the forward engineering.

You could use the Reverse engineering wizard to generate the basic source for the 3 classes - A, B, AB but beyond that I'm afraid you would have to add the collection and Add/Remove methods in each class manually and use the forward mapping to complete the mapping.

The collection in A - say 'ab', has to be mapped to to '1-n' collection without a join table with 'a' as the inverse field and the same for the collection is class B.

Hope this helps

Kind regards,
Ady
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
acm2001
Top achievements
Rank 2
answered on 05 Feb 2009, 03:51 PM
Whenever I hand code the data and then run the reverse engineer again it overrides my code. Is this correct?

Also, i didnt follow exactly your explanation. could you try to tell me again what you said?

thanks
Alan

0
Ady
Telerik team
answered on 05 Feb 2009, 05:05 PM
Hello Alan,

The Reverse Engineering (RE) wizard over-writes the Class.OpenAccess.cs/vb file. If you make your changes in the Class.cs/vb file it won't be over-written.

Regarding the m:n relation -

I assume you have 3 tables similar to A,B, AB

1)You can use the RE wizard and map these tables to classes and generate them. So now you have 3 classes - A, B, AB.

2) You can now add a collection of AB instances to both A and B manually.

3) Use the forward mapping dialog  and select the 'ab' collection in A and map it to a 1-n collection. Uncheck the 'Use join table' and specify the inverse field 'a' in class AB. Do exactly the same thing for the 'ab' field in Class B

4) You will also need to add the Add, Remove and RemoveInverse methods present in the sample code, manually

I know this is slightly complicated but hope you can achieve what you want now.

Sincerely yours,
Ady
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
acm2001
Top achievements
Rank 2
answered on 06 Feb 2009, 10:47 AM
thank you. I will try this.

your comment said "Class.OpenAccess.cs/vb file. If you make your changes in the Class.cs/vb file it won't be over-written."

I dont have any  Class.OpenAccess.vb files I have just [nameofclass[.vb files like Blog.vb Post.vb Domain.vb etc

I have the checkmark for Persistent Objects checked but DAL unchecked.

should i be checking DAL also?

thanks
alan

0
Ady
Telerik team
answered on 06 Feb 2009, 11:02 AM
Hi Alan,

For VB projects you don't see the ClassName.OpenAccess.vb file by default. Select a class or the project node and press the 'Show All Files' toolbar button in the Solution Explorer. You can then expand a class node to see the other file.

If your assembly will contain only Persistent classes and no data access code, then you need not check the 'DAL' option. The 'DAL' option adds a helper class that is useful in obtaining an IObjectScope instance.

Hope this helps.

Sincerely yours,
Ady
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Databases and Data Types
Asked by
acm2001
Top achievements
Rank 2
Answers by
acm2001
Top achievements
Rank 2
Alexander
Telerik team
Ady
Telerik team
Share this question
or