From c4e5bae76eff649f96229031f56a20f8b1020103 Mon Sep 17 00:00:00 2001 From: starfighter83 Date: Fri, 19 Nov 2010 11:37:47 +0000 Subject: [PATCH] Fixes #28732 Macro container slows down big times when allowed macroes int are getting bigger. [TFS Changeset #80227] --- .../editorControls/macrocontainer/MacroEditor.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/components/editorControls/macrocontainer/MacroEditor.cs b/components/editorControls/macrocontainer/MacroEditor.cs index 7c1b5970f0..a469925b80 100644 --- a/components/editorControls/macrocontainer/MacroEditor.cs +++ b/components/editorControls/macrocontainer/MacroEditor.cs @@ -37,7 +37,7 @@ namespace umbraco.editorControls.macrocontainer _macroSelectDropdown.Items.Add(new ListItem(umbraco.ui.Text("choose"), "")); foreach (string item in _allowedMacros) { - _macroSelectDropdown.Items.Add(new ListItem(Macro.GetByAlias(item).Name, item)); + _macroSelectDropdown.Items.Add(new ListItem(GetMacroNameFromAlias(item), item)); } _macroSelectDropdown.AutoPostBack = true; @@ -58,6 +58,20 @@ namespace umbraco.editorControls.macrocontainer this.Controls.Add(_formTable); } + //using this to solve to eager loading, + // replaces _macroSelectDropdown.Items.Add(new ListItem(Macro.GetByAlias(item).Name, item)); + // with _macroSelectDropdown.Items.Add(new ListItem(GetMacroNameFromAlias(item), item)); + private string GetMacroNameFromAlias(string alias) + { + umbraco.DataLayer.IRecordsReader dr = umbraco.BusinessLogic.Application.SqlHelper.ExecuteReader("select macroName from cmsMacro where macroAlias = @alias", + umbraco.BusinessLogic.Application.SqlHelper.CreateParameter("@alias", alias)); + + if (dr.Read()) + return dr.GetString("macroName"); + else + return string.Empty; + + } void _delete_Click(object sender, EventArgs e) { _macroSelectDropdown.SelectedIndex = 0;