diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index c92973b26d..fbb9496646 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -1727,6 +1727,9 @@ + + uQuery.cs + uQuery.cs diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/uQuery-Content.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/uQuery-Content.cs new file mode 100644 index 0000000000..eb5d3954a4 --- /dev/null +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/uQuery-Content.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using umbraco.cms.businesslogic; + +namespace umbraco +{ + public static partial class uQuery + { + /// + /// Gets the Content Id by property Id. + /// + /// The property id. + /// Returns the Content Id. + public static int GetContentIdByPropertyId(int propertyId) + { + if (propertyId > 0) + { + var sql = "SELECT contentNodeId FROM cmsPropertyData WHERE id = @propertyId"; + return uQuery.SqlHelper.ExecuteScalar(sql, uQuery.SqlHelper.CreateParameter("@propertyId", propertyId)); + } + + return uQuery.RootNodeId; + } + } +} \ No newline at end of file