From b88178b5421adb95b746bbcb6ccd2119f9f930f1 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 1 Dec 2010 19:37:10 -0800 Subject: [PATCH] Avoiding the eager creation of certain proxies to optional records cannot be done in fluent config the IsSelectable = false prevents unused ContentPartRecord proxies from being created for each ContentItemRecord or ContentItemVersionRecord. done for perf reasons - has no other side-effect --HG-- branch : perf --- src/Orchard/Data/SessionFactoryHolder.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Orchard/Data/SessionFactoryHolder.cs b/src/Orchard/Data/SessionFactoryHolder.cs index 56f4038fa..f7ba7389a 100644 --- a/src/Orchard/Data/SessionFactoryHolder.cs +++ b/src/Orchard/Data/SessionFactoryHolder.cs @@ -86,6 +86,23 @@ namespace Orchard.Data { _dataServicesProviderFactory .CreateProvider(parameters) .BuildConfiguration(parameters)); + + #region NH-2.1.2 specific optimization + // cannot be done in fluent config + // the IsSelectable = false prevents unused ContentPartRecord proxies from being created + // for each ContentItemRecord or ContentItemVersionRecord. + // done for perf reasons - has no other side-effect + + foreach (var persistentClass in config.ClassMappings) { + if (persistentClass.EntityName.StartsWith("Orchard.ContentManagement.Records.")) { + foreach (var property in persistentClass.PropertyIterator) { + if (property.Name.EndsWith("Record") && !property.IsBasicPropertyAccessor) { + property.IsSelectable = false; + } + } + } + } + #endregion return config; }