I have just upgraded from 4.0.4.1 to 4.7RC and started to play around with Razor, but I have problems accessing custom node properties. When I try this (custom property on the node is SiteName)
Error Loading Razor Script (file: myTest) Umbraco Exception (DataLayer): SQL helper exception in ExecuteScalar at umbraco.DataLayer.SqlHelper`1.ExecuteScalar[T](String commandText, IParameter[] parameters) at umbraco.cms.businesslogic.ContentType.GetDataType(String contentTypeAlias, String propertyTypeAlias) at umbraco.MacroEngines.DynamicNode.TryGetMember(GetMemberBinder binder, Object& result) at CallSite.Target(Closure , CallSite , Object ) at ASP._Page_macroScripts_test_cshtml.Execute() in d:\web\localuser\tarrild.dk\test\macroScripts\test.cshtml:line 1 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) at System.Web.WebPages.WebPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage) at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
If I try this:
@{
@Model.Name
}
It works just fine. I have tried with upper and lower case and with different custom node properties. Any ideas? Thanks
Should be fairly simple, by the looks of it but I can't quite see it at the moment, what is the exact Alias of the SiteName property? Try changing its name completely, it could be conflicting with something..
Does this work (using the correct casing of the SiteName alias)?
Hmmm, unfortunately it's quite hard to say what is going wrong, the only thing I can think of right now is debugging the umbraco source and looking at the query that is being performed.
Hmm, I am only running umbraco hosted at unoeuro so I don't think debugging is possible. I guess the only way foreward is starting from scratch in a clean installation or perhaps wait until the final release of 4.7?
Well, it's always a good idea to have a local install first before you deploy, makes it much easier to debug! ;-) It COULD have something to do with your hosting environment, although I can't think what it could be though.
Access custom node properties with Razor
Hi
I have just upgraded from 4.0.4.1 to 4.7RC and started to play around with Razor, but I have problems accessing custom node properties. When I try this (custom property on the node is SiteName)
@{
@Model.SiteName
}
I get this error on the webpage:
Error loading Razor Script test.cshtml
Umbraco Exception (DataLayer): SQL helper exception in ExecuteScalar
and the trace shows:
Error Loading Razor Script (file: myTest) Umbraco Exception (DataLayer): SQL helper exception in ExecuteScalar at umbraco.DataLayer.SqlHelper`1.ExecuteScalar[T](String commandText, IParameter[] parameters)
at umbraco.cms.businesslogic.ContentType.GetDataType(String contentTypeAlias, String propertyTypeAlias)
at umbraco.MacroEngines.DynamicNode.TryGetMember(GetMemberBinder binder, Object& result)
at CallSite.Target(Closure , CallSite , Object )
at ASP._Page_macroScripts_test_cshtml.Execute() in d:\web\localuser\tarrild.dk\test\macroScripts\test.cshtml:line 1
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors)
at System.Web.WebPages.WebPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
If I try this:
@{ @Model.Name }
It works just fine. I have tried with upper and lower case and with different custom node properties. Any ideas? Thanks
Should be fairly simple, by the looks of it but I can't quite see it at the moment, what is the exact Alias of the SiteName property? Try changing its name completely, it could be conflicting with something..
Does this work (using the correct casing of the SiteName alias)?
The alias is SiteName. I have tried with different properties on different document type, but with identical results. When I try
i get the value of the property with no errors!
Hmmm, unfortunately it's quite hard to say what is going wrong, the only thing I can think of right now is debugging the umbraco source and looking at the query that is being performed.
Hmm, I am only running umbraco hosted at unoeuro so I don't think debugging is possible. I guess the only way foreward is starting from scratch in a clean installation or perhaps wait until the final release of 4.7?
Well, it's always a good idea to have a local install first before you deploy, makes it much easier to debug! ;-) It COULD have something to do with your hosting environment, although I can't think what it could be though.
Upgraded to the latest nightly build of umbraco 4.7 which solved the problem.
Thanks for the help.
is working on a reply...