From 9e90f67ad3f3cd840a6100537abb5ab86ea39808 Mon Sep 17 00:00:00 2001 From: rpaquay <> Date: Fri, 12 Feb 2010 18:42:16 -0800 Subject: [PATCH] Fix circular foreign key issue ContentItemRecord and ContentItemVersionRecord should not have foreign keys to the other records' id's. Also removed unused alterations --- .../Records/ContentItemAlteration.cs | 50 +------------------ 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/src/Orchard/ContentManagement/Records/ContentItemAlteration.cs b/src/Orchard/ContentManagement/Records/ContentItemAlteration.cs index 196e2a431..55f250435 100644 --- a/src/Orchard/ContentManagement/Records/ContentItemAlteration.cs +++ b/src/Orchard/ContentManagement/Records/ContentItemAlteration.cs @@ -64,6 +64,7 @@ namespace Orchard.ContentManagement.Records { mapping.References(syntheticExpression) .Access.NoOp() .Column("Id") + .ForeignKey("none") // prevent foreign key constraint from ContentItem(Version)Record to TPartRecord .Unique() .Not.Insert() .Not.Update() @@ -71,55 +72,6 @@ namespace Orchard.ContentManagement.Records { } } - class ContentPartAlterationInternal : IAlteration where TPartRecord : ContentPartRecord { - public void Override(AutoMapping mapping) { - - // public TPartRecord TPartRecord {get;set;} - var name = typeof(TPartRecord).Name; - var syntheticMethod = new DynamicMethod(name, typeof(TPartRecord), null, typeof(ContentItemRecord)); - var syntheticProperty = new SyntheticPropertyInfo(syntheticMethod); - - // record => record.TPartRecord - var parameter = Expression.Parameter(typeof(ContentItemRecord), "record"); - var syntheticExpression = (Expression>)Expression.Lambda( - typeof(Func), - Expression.Property(parameter, syntheticProperty), - parameter); - - mapping.References(syntheticExpression) - .Access.NoOp() - .Column("Id") - .Unique() - .Not.Insert() - .Not.Update() - .Cascade.All(); - } - } - - class ContentPartVersionAlterationInternal : IAlteration where TPartRecord : ContentPartVersionRecord { - public void Override(AutoMapping mapping) { - - // public TPartRecord TPartRecord {get;set;} - var name = typeof(TPartRecord).Name; - var syntheticMethod = new DynamicMethod(name, typeof(TPartRecord), null, typeof(ContentItemVersionRecord)); - var syntheticProperty = new SyntheticPropertyInfo(syntheticMethod); - - // record => record.TPartRecord - var parameter = Expression.Parameter(typeof(ContentItemVersionRecord), "record"); - var syntheticExpression = (Expression>)Expression.Lambda( - typeof(Func), - Expression.Property(parameter, syntheticProperty), - parameter); - - mapping.References(syntheticExpression) - .Access.NoOp() - .Column("Id") - .Unique() - .Not.Insert() - .Not.Update() - .Cascade.All(); - } - } private class SyntheticPropertyInfo : PropertyInfo { private readonly DynamicMethod _getMethod;