I have a Node with Property startDate and endDate and have its template I need to display the item in the template only if that is within the date range. Otherwise that shouldn't be shown in the page.@Model will give the dynamic node, I would like to know how to check the date range for this, I have tried the .Where and @Model.startDate >=DateTime.Now.Date etc and I am getting an error like DynamicNull cannot use >= with DateTime.Date
Please let me know.
Note: Will update if that is @Model.startDate property returning a string and I need to typecast it.
The beta is going to be released by the end of the month. But you can download a nightly and just use the umbraco.macroengine.dll from it to upgrade the Razor engine. It has been very stable from what I've seen so far.
Dynamic Node Issue checking with Date Property?
I have a Node with Property startDate and endDate and have its template
I need to display the item in the template only if that is within the date range.
Otherwise that shouldn't be shown in the page.@Model will give the dynamic node, I would like to know how to check the date range for this, I have tried the .Where and
@Model.startDate >=DateTime.Now.Date etc and I am getting an error like DynamicNull cannot use >= with DateTime.Date
Please let me know.
Note:
Will update if that is @Model.startDate property returning a string and I need to typecast it.
Thanks,
Rajeev
I have checked first if the node is null and if that is within the range.
if ( (Model!=null) && Model.startDate<=DateTime.Now.Date) and it worked.
Note: Here startDate was a mandatory field, else you have to validate that as well.
Thanks,
Rajeev
In 4.7.1 you don't have to do all of those elaborate checks any more, you can just go:
Thank you.That is great.
When can we expect the stable version of this.?
-Rajeev
The beta is going to be released by the end of the month. But you can download a nightly and just use the umbraco.macroengine.dll from it to upgrade the Razor engine. It has been very stable from what I've seen so far.
Thank you for the update Sebastian.
-Rajeev
is working on a reply...