Ensure that getdatatype doesn't throw an exception

http://our.umbraco.org/forum/developers/razor/18085-Access-custom-node-properties-with-Razor
This commit is contained in:
agrath@gmail.com
2011-03-08 18:22:31 -13:00
parent bc8f21f92d
commit 9b74eee10c
2 changed files with 27 additions and 11 deletions

View File

@@ -149,22 +149,38 @@ namespace umbraco.cms.businesslogic
"left join cmsDataType on (cmsPropertyType.dataTypeId = cmsDataType.nodeId) and cmsPropertyType.Alias = @propertyAlias " +
"left join cmsContentType masterContentType on masterContentType.nodeid = cmsContentType.masterContentType " +
"where cmsContentType.alias = @contentTypeAlias";
//Ensure that getdatatype doesn't throw an exception
//http://our.umbraco.org/forum/developers/razor/18085-Access-custom-node-properties-with-Razor
//grab the controlid or test for parent
Guid controlId = Guid.Empty;
var reader = Application.SqlHelper.ExecuteReader(sql,
Application.SqlHelper.CreateParameter("@contentTypeAlias", contentTypeAlias),
Application.SqlHelper.CreateParameter("@propertyAlias", propertyTypeAlias)
);
if (reader.Read())
IRecordsReader reader = null;
try
{
if (!reader.IsNull("controlId"))
controlId = reader.GetGuid("controlId");
else if (!reader.IsNull("masterAlias") && !String.IsNullOrEmpty(reader.GetString("masterAlias")))
reader = Application.SqlHelper.ExecuteReader(sql,
Application.SqlHelper.CreateParameter("@contentTypeAlias", contentTypeAlias),
Application.SqlHelper.CreateParameter("@propertyAlias", propertyTypeAlias)
);
if (reader.Read())
{
controlId = GetDataType(reader.GetString("masterAlias"), propertyTypeAlias);
if (!reader.IsNull("controlId"))
controlId = reader.GetGuid("controlId");
else if (!reader.IsNull("masterAlias") && !String.IsNullOrEmpty(reader.GetString("masterAlias")))
{
controlId = GetDataType(reader.GetString("masterAlias"), propertyTypeAlias);
}
}
}
reader.Close();
catch (UmbracoException)
{
_propertyTypeCache.Add(key, controlId);
}
finally
{
reader.Close();
}
//add to cache
_propertyTypeCache.Add(key, controlId);

View File

@@ -8,7 +8,7 @@
</xsl:template>
<xsl:template match="/configuration/appSettings/add[@key='umbracoConfigurationStatus']/@value">
<xsl:attribute name="value">4.7.0.beta</xsl:attribute>
<xsl:attribute name="value">4.7.0.RC</xsl:attribute>
</xsl:template>
<!-- Default templates to match anything else -->