Migrations for complex and composed objects

Topics: Writing modules
Oct 16, 2012 at 5:55 PM
Edited Oct 16, 2012 at 5:57 PM

I'm trying to write and read a complex object from/to DB in a controller. It has properties of type IDictionary<string, bool> and of another class I've created. It looks to me that Orchard migrations only support string, int, DateTime, bool and enums - that are the types in Orchard.Data.Migration.Schema.SchemaUtils.ToDbType.

 

What would be the most straightforward way to read/write objects like this from a controller?

Coordinator
Oct 16, 2012 at 6:22 PM

Migration supports anything a database supports. You can also rely on Xml serialization if you need to serialize complex objects and don't want a specific table mapping for that.

Oct 16, 2012 at 6:30 PM

Thanks a lot, Mr Ros.

 

How exactly do I get Orchard/nHibernate to save an IDictionary virtual property? Also say an ObjectA has a virtual property of type ObjectB, how do I save A and B ?

Coordinator
Oct 16, 2012 at 7:13 PM

You don't. You can do as Sébastien suggests, or you can establish relationships: http://docs.orchardproject.net/Documentation/Creating-1-n-and-n-n-relations