So I am working on a tansverse razor script and I want to be able to pass the name of the doctype I want to list out into the helper and then in my foreach loop use a variable that contains the name of the doctype. Is there anyway to do this. This is what i have and it's not working.
When dealing with dynamic objects you can't use the regular .Where linq method that you'd normally use in a standard .NET application. So the Umbraco developers added support by creating their own Where method. This method uses a string replace simular to .NET's String.Format method to add string variables in as parameters of the method, only String.Format uses '{0}' instead of '@0'. The number after the "at" sign is the index of the parameter. So if you were writing a Where statement with more than one parameter, you could do something like the following:
var nodes = Model.Children.Where("NodeTypeAlias == @0 && someOtherProperty == @1","alias","someValue");
Doctype and Traverse
So I am working on a tansverse razor script and I want to be able to pass the name of the doctype I want to list out into the helper and then in my foreach loop use a variable that contains the name of the doctype. Is there anyway to do this. This is what i have and it's not working.
actually thats wrong... my foreach loop looks like this.
This is what you'll want to do:
Doug, thanks, the trick for me was in how you targeted the NodeTypeAlias... I have never seen the ==@0... what does that mean? How does that work?
When dealing with dynamic objects you can't use the regular .Where linq method that you'd normally use in a standard .NET application. So the Umbraco developers added support by creating their own Where method. This method uses a string replace simular to .NET's String.Format method to add string variables in as parameters of the method, only String.Format uses '{0}' instead of '@0'. The number after the "at" sign is the index of the parameter. So if you were writing a Where statement with more than one parameter, you could do something like the following:
Hope that helps you understand it some more.
is working on a reply...