@{ //retrive all Posts dynamic artikelListe = Model.AncestorOrSelf(1).DescendantsOrSelf("uBlogsyPost"); string catSelect = @Parameter.kategorieName; <---- This is my Macroparameter i need to input the Categoryname } @foreach(dynamic n in artikelListe.Where("uBlogsyPostCategories.Contains(\"Nachtleben\")").Take(4).OrderBy("uBlogsyPostDate desc"))
Code works this way, but it is not working with dynamic n in articleList.Where("uBlogsyPostCategories.Contains(@catSelect)......
not working too :): articleList.Where("uBlogsyPostCategories == catSelect").....
@foreach(dynamic n in artikelListe.Where("uBlogsyPostCategories.Contains(catSelect)").Take(4).OrderBy("uBlogsyPostDate desc"))
this error is showing up:
Expression of type 'System.Func`2[umbraco.MacroEngines.DynamicNode,System.Object]' cannot be used for parameter of type 'System.String' of method 'Boolean Contains(System.String)'
Get Paramter to use with .Where and contains
Somebody have an idea how to solve this.
@{
//retrive all Posts
dynamic artikelListe = Model.AncestorOrSelf(1).DescendantsOrSelf("uBlogsyPost");
string catSelect = @Parameter.kategorieName; <---- This is my Macroparameter i need to input the Categoryname
}
@foreach(dynamic n in artikelListe.Where("uBlogsyPostCategories.Contains(\"Nachtleben\")").Take(4).OrderBy("uBlogsyPostDate desc"))
Code works this way, but it is not working with dynamic n in articleList.Where("uBlogsyPostCategories.Contains(@catSelect)......
not working too :):
articleList.Where("uBlogsyPostCategories == catSelect").....
Any Ideas. ????
Hey Toni,
Try using String.Format to inject your variable value into the string. Something like this:
Where(String.Format("uBlogsyPostCategories == {0}", catSelect))
nope nothings happen, no html rendering :/
If i try this
@foreach(dynamic n in artikelListe.Where("uBlogsyPostCategories.Contains(catSelect)").Take(4).OrderBy("uBlogsyPostDate desc"))
this error is showing up:
Expression of type 'System.Func`2[umbraco.MacroEngines.DynamicNode,System.Object]' cannot be used for parameter of type 'System.String' of method 'Boolean Contains(System.String)'
No one has an idea? I think should be possible somehow.
Slight error in my previous post, you need to surround the variable value in escaped double quotes, like this:
Where(String.Format("uBlogsyPostCategories == \"{0}\"", catSelect))
will test it out and give you feedback in 5 mins. Thanks so long, hope this will work :)
worked, thanks to alex
is working on a reply...