Applied patch from uComponents for uQuery - GetContentIdByPropertyId

This commit is contained in:
leekelleher
2012-09-03 18:57:54 -01:00
parent 99cf1e9f6d
commit c345b9f47c
2 changed files with 27 additions and 0 deletions

View File

@@ -1727,6 +1727,9 @@
<Compile Include="umbraco.presentation\umbraco\xslt\eXslt\ExsltSets.cs" />
<Compile Include="umbraco.presentation\umbraco\xslt\eXslt\ExsltStrings.cs" />
<Compile Include="umbraco.presentation\umbraco\uQuery\uQuery.cs" />
<Compile Include="umbraco.presentation\umbraco\uQuery\uQuery-Content.cs">
<DependentUpon>uQuery.cs</DependentUpon>
</Compile>
<Compile Include="umbraco.presentation\umbraco\uQuery\uQuery-DataTypes.cs">
<DependentUpon>uQuery.cs</DependentUpon>
</Compile>

View File

@@ -0,0 +1,24 @@
using System.Collections.Generic;
using umbraco.cms.businesslogic;
namespace umbraco
{
public static partial class uQuery
{
/// <summary>
/// Gets the <c>Content</c> Id by property Id.
/// </summary>
/// <param name="propertyId">The property id.</param>
/// <returns>Returns the <c>Content</c> Id.</returns>
public static int GetContentIdByPropertyId(int propertyId)
{
if (propertyId > 0)
{
var sql = "SELECT contentNodeId FROM cmsPropertyData WHERE id = @propertyId";
return uQuery.SqlHelper.ExecuteScalar<int>(sql, uQuery.SqlHelper.CreateParameter("@propertyId", propertyId));
}
return uQuery.RootNodeId;
}
}
}