views:

188

answers:

2

I'm building a core engine for my blog and would like to be able to extend it very easily. At the moment my code looks like this:

[Table(Name = "dbo.ContentItem")]
[InheritanceMapping(Code = "MyNameSpace.Items.SysRoot", Type = typeof(SysRoot), IsDefault = true)]
[InheritanceMapping(Code = "MyNameSpace.Items.SysRecycleBin", Type = typeof(SysRecycleBin))]
public partial class ContentItem : ICloneable, INotifyPropertyChanging, INotifyPropertyChanged {
// some code here
}

The code above is in my core project and and I would like to map new pagetypes in my blog project by for example adding the inheritancemapping attribute on a class like this:

[InheritanceMapping(Code = "MyNamespace.Blog.Items.BlogPostContainer", Type = typeof(BlogPostConntainer))]
    public partial class BlogPostContainer : ContentItem {
// some code here
}

This does not work so I wonder if anyone has a solution for this problem? Maybe it's possible to write the mapping in an external xml file to get the inheritance between projects to work?

A: 

It's possible to write the mapping in an xml file. See:

http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/09/27/25294.aspx http://weblogs.asp.net/dwahlin/archive/2008/08/18/using-linq-to-sql-xml-mapping-files-step-by-step.aspx

Castrohenge
I have tried that but my when I use an xml-based mapping my castle windsor container stops working. Do you know if it is possible to use castle windsor with xml-based mapping?
Marcus
Another error I get when i use xml-based mapping is that one of my members has no supported translation to SQL?My mappingfile looks like this for that member <Column Name="ParentID" Member="ParentID" Storage="_parentID" DbType="Int" />
Marcus
I've never used castle windsor and linq to sql together I'm afraid. I personally use NHibernate and have found this to be a lot easier to work with than linq to sql. If you can make the switch I would.
Castrohenge
Okay, is it possible to create that type of inheritance i'm looking for in my question with NHibernate?
Marcus
Yes. Take a look at http://ayende.com/Blog/archive/2009/04/10/nhibernate-mapping-ndash-inheritance.aspx. Also check at the Nhibernate documentation http://nhforge.org/doc/nh/en/index.html#inheritance.
Castrohenge
A: 

I had made some errors in my mapping-file and now it works ok though it should be better to get this working without xml-mappings and stuff like that but i guess that there is no other solution for this.

Marcus