diff --git a/src/Umbraco.Web/UI/Controls/UmbracoControl.cs b/src/Umbraco.Web/UI/Controls/UmbracoControl.cs index 4d8bd4ce69..9c75a80c9a 100644 --- a/src/Umbraco.Web/UI/Controls/UmbracoControl.cs +++ b/src/Umbraco.Web/UI/Controls/UmbracoControl.cs @@ -83,13 +83,6 @@ namespace Umbraco.Web.UI.Controls { get { return _url ?? (_url = new UrlHelper(new RequestContext(new HttpContextWrapper(Context), new RouteData()))); } } - - /// - /// Returns the legacy SqlHelper - /// - protected ISqlHelper SqlHelper - { - get { return Application.SqlHelper; } - } + } } \ No newline at end of file diff --git a/src/Umbraco.Web/UI/Controls/UmbracoUserControl.cs b/src/Umbraco.Web/UI/Controls/UmbracoUserControl.cs index e82e9392d5..2b2c89df7c 100644 --- a/src/Umbraco.Web/UI/Controls/UmbracoUserControl.cs +++ b/src/Umbraco.Web/UI/Controls/UmbracoUserControl.cs @@ -136,12 +136,5 @@ namespace Umbraco.Web.UI.Controls get { return _url ?? (_url = new UrlHelper(new RequestContext(new HttpContextWrapper(Context), new RouteData()))); } } - /// - /// Returns the legacy SqlHelper - /// - protected ISqlHelper SqlHelper - { - get { return global::umbraco.BusinessLogic.Application.SqlHelper; } - } } } \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/content.cs b/src/Umbraco.Web/umbraco.presentation/content.cs index 811a805456..a6cf23399d 100644 --- a/src/Umbraco.Web/umbraco.presentation/content.cs +++ b/src/Umbraco.Web/umbraco.presentation/content.cs @@ -147,12 +147,7 @@ namespace umbraco { get { return _xmlContent == null; } } - - protected static ISqlHelper SqlHelper - { - get { return Application.SqlHelper; } - } - + #endregion #region Public Methods @@ -493,57 +488,48 @@ where umbracoNode.id in (select cmsDocument.nodeId from cmsDocument where cmsDoc order by umbracoNode.level, umbracoNode.sortOrder"; - - using ( - IRecordsReader dr = SqlHelper.ExecuteReader(sql, - SqlHelper.CreateParameter("@type", - new Guid( - Constants.ObjectTypes.Document))) - ) + foreach (var dr in ApplicationContext.Current.DatabaseContext.Database.Query(sql, new { type = new Guid(Constants.ObjectTypes.Document)})) { - while (dr.Read()) + int currentId = dr.id; + int parentId = dr.parentId; + string xml = dr.xml; + + // fix sortOrder - see notes in UpdateSortOrder + var tmp = new XmlDocument(); + tmp.LoadXml(xml); + var attr = tmp.DocumentElement.GetAttributeNode("sortOrder"); + attr.Value = dr.sortOrder.ToString(); + xml = tmp.InnerXml; + + // Call the eventhandler to allow modification of the string + var e1 = new ContentCacheLoadNodeEventArgs(); + FireAfterContentCacheDatabaseLoadXmlString(ref xml, e1); + // check if a listener has canceled the event + if (!e1.Cancel) { - int currentId = dr.GetInt("id"); - int parentId = dr.GetInt("parentId"); - string xml = dr.GetString("xml"); - - // fix sortOrder - see notes in UpdateSortOrder - var tmp = new XmlDocument(); - tmp.LoadXml(xml); - var attr = tmp.DocumentElement.GetAttributeNode("sortOrder"); - attr.Value = dr.GetInt("sortOrder").ToString(); - xml = tmp.InnerXml; - - // Call the eventhandler to allow modification of the string - var e1 = new ContentCacheLoadNodeEventArgs(); - FireAfterContentCacheDatabaseLoadXmlString(ref xml, e1); - // check if a listener has canceled the event + // and parse it into a DOM node + xmlDoc.LoadXml(xml); + XmlNode node = xmlDoc.FirstChild; + // same event handler loader form the xml node + var e2 = new ContentCacheLoadNodeEventArgs(); + FireAfterContentCacheLoadNodeFromDatabase(node, e2); + // and checking if it was canceled again if (!e1.Cancel) { - // and parse it into a DOM node - xmlDoc.LoadXml(xml); - XmlNode node = xmlDoc.FirstChild; - // same event handler loader form the xml node - var e2 = new ContentCacheLoadNodeEventArgs(); - FireAfterContentCacheLoadNodeFromDatabase(node, e2); - // and checking if it was canceled again - if (!e1.Cancel) - { - nodeIndex.Add(currentId, node); + nodeIndex.Add(currentId, node); - // verify if either of the handlers canceled the children to load - if (!e1.CancelChildren && !e2.CancelChildren) + // verify if either of the handlers canceled the children to load + if (!e1.CancelChildren && !e2.CancelChildren) + { + // Build the content hierarchy + List children; + if (!hierarchy.TryGetValue(parentId, out children)) { - // Build the content hierarchy - List children; - if (!hierarchy.TryGetValue(parentId, out children)) - { - // No children for this parent, so add one - children = new List(); - hierarchy.Add(parentId, children); - } - children.Add(currentId); + // No children for this parent, so add one + children = new List(); + hierarchy.Add(parentId, children); } + children.Add(currentId); } } } diff --git a/src/Umbraco.Web/umbraco.presentation/library.cs b/src/Umbraco.Web/umbraco.presentation/library.cs index dc7ae9da1e..992f546517 100644 --- a/src/Umbraco.Web/umbraco.presentation/library.cs +++ b/src/Umbraco.Web/umbraco.presentation/library.cs @@ -71,16 +71,7 @@ namespace umbraco private page _page; #endregion - - #region Properties - - protected static ISqlHelper SqlHelper - { - get { return umbraco.BusinessLogic.Application.SqlHelper; } - } - - #endregion - + #region Constructors /// @@ -1213,16 +1204,15 @@ namespace umbraco XmlDocument xd = new XmlDocument(); xd.LoadXml(""); - using (IRecordsReader dr = SqlHelper.ExecuteReader("Select id, [value] from cmsDataTypeprevalues where DataTypeNodeId = @dataTypeId order by sortorder", - SqlHelper.CreateParameter("@dataTypeId", DataTypeId))) + foreach (var dr in ApplicationContext.Current.DatabaseContext.Database.Query( + "Select id, [value] from cmsDataTypeprevalues where DataTypeNodeId = @dataTypeId order by sortorder", + new { dataTypeId = DataTypeId })) { - while (dr.Read()) - { - XmlNode n = XmlHelper.AddTextNode(xd, "preValue", dr.GetString("value")); - n.Attributes.Append(XmlHelper.AddAttribute(xd, "id", dr.GetInt("id").ToString())); - xd.DocumentElement.AppendChild(n); - } + XmlNode n = XmlHelper.AddTextNode(xd, "preValue", dr.value); + n.Attributes.Append(XmlHelper.AddAttribute(xd, "id", dr.id.ToString())); + xd.DocumentElement.AppendChild(n); } + XPathNavigator xp = xd.CreateNavigator(); return xp.Select("/preValues"); } @@ -1236,8 +1226,9 @@ namespace umbraco { try { - return SqlHelper.ExecuteScalar("select [value] from cmsDataTypePreValues where id = @id", - SqlHelper.CreateParameter("@id", Id)); + return ApplicationContext.Current.DatabaseContext.Database.ExecuteScalar( + "select [value] from cmsDataTypePreValues where id = @id", + new {id = Id}); } catch { diff --git a/src/Umbraco.Web/umbraco.presentation/macro.cs b/src/Umbraco.Web/umbraco.presentation/macro.cs index 859a719c37..9c222a5dde 100644 --- a/src/Umbraco.Web/umbraco.presentation/macro.cs +++ b/src/Umbraco.Web/umbraco.presentation/macro.cs @@ -60,12 +60,7 @@ namespace umbraco private readonly StringBuilder _content = new StringBuilder(); private const string MacrosAddedKey = "macrosAdded"; public IList Exceptions = new List(); - - protected static ISqlHelper SqlHelper - { - get { return Application.SqlHelper; } - } - + static macro() { _xsltSettings = SystemUtilities.GetCurrentTrustLevel() > AspNetHostingPermissionLevel.Medium diff --git a/src/Umbraco.Web/umbraco.presentation/template.cs b/src/Umbraco.Web/umbraco.presentation/template.cs index 68868e86fd..24f7de4aac 100644 --- a/src/Umbraco.Web/umbraco.presentation/template.cs +++ b/src/Umbraco.Web/umbraco.presentation/template.cs @@ -457,11 +457,7 @@ namespace umbraco #endregion - protected static ISqlHelper SqlHelper - { - get { return Application.SqlHelper; } - } - + #region constructors public static string GetMasterPageName(int templateID) @@ -485,25 +481,25 @@ namespace umbraco var t = ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem