Having the same complex type multiple times in a table

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
ashlar64
Posts: 75
Joined: Thu 04 May 2006 18:56

Having the same complex type multiple times in a table

Post by ashlar64 » Wed 09 May 2012 11:56

Is there a way to have the same complex type in a table multiple times?

I have a Complex Type called cChance and I have 6 of them in my table and I try to generate the script for the database none of them are in the script. But if I remove all but 1 of the cChances it appears in the script when I generate it.

I also tried making a simple project and I am seeing this happen as well.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Having the same complex type multiple times in a table

Post by MariiaI » Thu 10 May 2012 13:10

To have the same complex type in a table multiple times, you should change Source column for each property of the each complex type. This can be done in the Entity Сlass Mapping Details (available from the shortcut menu of your Entity Class). You should change the Column name for each type to the corresponding column in the database table, or, if table doesn't exist yet, modify them so that they differ from each other.

ashlar64
Posts: 75
Joined: Thu 04 May 2006 18:56

Re: Having the same complex type multiple times in a table

Post by ashlar64 » Thu 10 May 2012 17:24

Ahh well that is a relief. Could you guys add some sort of automation so that you don't have to type all these mappings out by hand? I had one table that had 20+ complex types in it is a big pain having to type them all out by hand.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Having the same complex type multiple times in a table

Post by MariiaI » Fri 11 May 2012 10:49

Thank you for your suggestion. We currently have no plans for implementing it, but you can post it at our UserVoice (devart.uservoice.com) so that other users can support it.
Also, we would be grateful if you describe how exactly you see this feature (precisely, what algorithm should be used for renaming the complex type fields).

ashlar64
Posts: 75
Joined: Thu 04 May 2006 18:56

Re: Having the same complex type multiple times in a table

Post by ashlar64 » Fri 11 May 2012 14:53

Thanks again for the aid.

When you do Model first I know Microsoft's Entity Framework is smart enough to do the mappings for you. It would be nice in your designer did this as well. I had a situation where I had a complex type that has 6 properties and this complex type was used about 20 times in a single table. Doing this by hand in the Mapping dialog was not very easy and it was very time consuming. Try doing this scenario yourself and you will have a seriously cramped wrist as well since that dialog doesn't make doing mass edits very easy.
It would be nice to have a option for it to do the mapping for you perhaps like:
TableCProperty_ComplexProp0
TableCProperty_ComplexProp1
TableCProperty_ComplexProp2
TableCProperty_ComplexProp3
TableCProperty_ComplexProp4
TableCProperty_ComplexProp5

I will also post this suggestion in the UserVoice.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Having the same complex type multiple times in a table

Post by MariiaI » Mon 14 May 2012 07:32

Thank you, we will consider the possibility of adding this functionality and inform you about the results. However, there is no timeframe available at the moment.

ashlar64
Posts: 75
Joined: Thu 04 May 2006 18:56

Re: Having the same complex type multiple times in a table

Post by ashlar64 » Mon 23 Dec 2013 14:59

Hello,

Could I urge you guys to consider adding this feature (perhaps as a option that you can turn on and off)? I had to re-map by hand about 80 complex types (each with 6-12 properties) in a project of mine. I have also had to do this many times in the past. This is causing me to lose a significant amount of time doing this plus it is killing my wrist.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Having the same complex type multiple times in a table

Post by MariiaI » Tue 24 Dec 2013 09:35

Currently, LinqConnect supports such scenarios for Model First approach. To implement such a scenario, you can use advanced database naming rules - set database naming rules and names for the properties in the entity class. Please refer to the Entity Developer documentation: Orm Support-> NHibernate-> Customizing Model Properties-> Synchronization-> Database Naming-> Advanced
The article is about NHibernate, but the principle is the same. We will add the similar description for LinqConnect models, too.

We are sending you a test model to the e-mail address you have provided in your forum profile. Please check that the letter is not blocked by your mail filter.

Please tell us if this helps.

ashlar64
Posts: 75
Joined: Thu 04 May 2006 18:56

Re: Having the same complex type multiple times in a table

Post by ashlar64 » Tue 24 Dec 2013 15:20

Awesome! I did a few small tests and it seems to be working the way I like. Was this a new feature?

Thanks for the help!!!

:D

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Having the same complex type multiple times in a table

Post by MariiaI » Wed 25 Dec 2013 11:17

Yes, the capability for setting special rules for generating default names of database objects when using the Model First approach was implemented starting from LinqConnect 4.2.222 (a new Advanced page was added to the Synchronization->Database Naming section of the Model Settings dialog box).

Post Reply