This project is read-only.


Topics: Core, Customizing Orchard, Writing modules
Aug 25, 2013 at 3:48 PM
I'm creating some classes and I need to create one inheritance into my project.
I have my Model classes similar that below:

public class AnimalRecord : ContentPartRecord
public virtual String Name { get; set; }

public class DogRecord : AnimalRecord
public virtual String Race { get; set; }

To creating my tables, I have my migration.cs like below:

public class Migrations : DataMigrationImpl {
public int Create() {
    SchemaBuilder.CreateTable("AnimalRecord", table => table
    return 1;

How is the code to creating the DogRecord into my migration.cs and how I do to recover one DogRecord record ?
Can I turn my AnimalRecord class in a abstract class ?
Aug 25, 2013 at 4:01 PM
Is Race a property or a method ?
if it is a property, then you'll need to create another content part.

the way i see it, your dog will be a content type. and to retrieve the record, you can use ContentManager.

ps: i'm newbie too :D

Aug 26, 2013 at 10:14 PM
Thanks for you help arjunatantri.
I'm try to create a table that inherit for other table.
At realy, this is a little weird, because a table is a relational concept and inheritance is a object oriented concept, but NHibernate support that and I want to know if its possible use this philosophy into Orchard to build my own modules.
In my example, Race is a property of Dog and the Name is a property of animal. How the Dog IS a animal, name is a property of dog too.

Aug 26, 2013 at 10:20 PM
Orchard favors composition over inheritance. Do you have a more realistic scenario than dog/animal?
Aug 26, 2013 at 10:54 PM
At this time I'm just learning the Orchard features and all of my problems are just conceptuals.
I have some customer and I am studing if is possible replace your actual solutions by the Orchard.
I dont have a realistic scenario, but In my example of Dog/animal, I woud like to create other table that refers to a animal colection and animal can be a abstract class.
Is it possible into Orchard ?
Aug 27, 2013 at 1:27 AM
I'm pretty sure you are looking at the problem from the wrong perspective. Give me an example of real content where you think you need inheritance, and I'll show you why composition is a better solution. Orchard is an opinionated system, and it's best to get on board with its conventions and idioms. Otherwise, you are going to fight the system constantly and may find out it's a bad match for you.
Sep 2, 2013 at 1:36 PM
Dear BertrandLeRoy,
First, my sincere thanks for your cooperation, but to clarify my problems, I have to put you my cenario.
I work into a developers company and at this time I want know if is possible change our customer sites, where we have some especific solution that use OO concepts and all of them are developed in .NET.
I don't want start one polemic discussion if OO is better than composition ... I just want to know if is possible use this concepts into Orchard, because that solves some problems of customizations of our customer.
At this moment, we consider only change the presentation layer and, if an easy solution, the data access layer too.
Into our development, we using one propietary solution were convert one "class diagram" into some "business logic" and "data access" classes. That is very similar to NHibernate and we consider change our propietary solution to the NHibernate some times.
How the Orchard is building using the NHibernate, I think that possible use all NHibernate features into my problems, but using the Migration.cs notation and IRepository objects.
This convertion don't be a expensive conversion, because the most of our work is into the "business logic" layer and some Views.
Is it possible use the OO concept to build my data into a Orchard, using the object relational solution ?
I think that composite solution is a good solution to little problems and small team. But I have afraid to use this solution into big systems.
My apologise if all of my problems now are conceptuals, and we can't discuss over a real problem, but my decision to use or not a Orchard depends of this step.
Maybe I never use that, and, in future, I can understand that the Composition solution is better than OO, but our team have a large experience with OO and all of our development processes are based on OO. Changing this now is a complex decision.
Independ of my decision and of my especific problems, congratulation for the Orchard ... it's a great solution.
Sep 2, 2013 at 1:39 PM
One more thing ... My native language is Portuguese and a few sentences can not express exactly what I wanted to talk.
I apologize for possible abuses. I hope you understand that it is not my intention in any way.
Sep 2, 2013 at 9:44 PM
Your English is just fine, don't worry about it.

First, you could in principle do everything you currently do, in a module, and that should still work. The real question would be what level of integration you want with Orchard itself. If you went all the way and wanted your objects to become real content parts, then I would still strongly advise against attempting any form of inheritance. If on the other hand you want to use less intrusive services (theming, permissions, etc.), you should be able to leave your existing code nearly unchanged, in principle.

It seems, however, that you are considering going halfway, using our migrations and repository structures. In that case, I have to warn you that these were built exclusively to answer the specific problems linked with storing composite content items, and thus may not easily yield to very different object models. We do in fact actively discourage people from using IRepository if possible. In that sense, Orchard's composition philosophy is going to get in the way.

In conclusion, I would not try too hard to bring your existing object model into the Orchard world, unless that's exactly what you want to do, because you have very good reasons to. Otherwise, I would keep everything as much as possible as it is today, and only bring Orchard services in as needed.

Does this make sense?