0

I try to migrate my website from Umbraco 7 to 11

I have the following code on 7:

var Section_node = Umbraco.Content(1234);    

var Section_pages = @Section_node.Children.Where("Visible");
Section_pages = Section_node.DescendantsOrSelf().Where("NodeTypeAlias == @0", "blogPosts");

So I try to convert it to 11 (.net 7) as follow:

var Section_node = Umbraco.Content(1234);    

var Section_pages = Section_node.Children.Where(x => x.IsVisible());
Section_pages = Section_node.DescendantsOrSelf().Where(NodeTypeAlias("@0")).And().Field("NewsPage");

But I'm still getting errors - any idea ?

Thanks.

Menahem Gil
  • 787
  • 2
  • 15
  • 39
  • Can you show us what is the error you get? – Talkhak1313 Jan 26 '23 at 03:11
  • The type arguments for method 'NPocoSqlExtensions.Where(Sql, Expression>, string?)' cannot be inferred from the usage. Try specifying the type arguments explicitly. – Menahem Gil Jan 26 '23 at 03:25
  • Filters a sequence of values based on a predicate. Returns: An IEnumerable that contains elements from the input sequence that satisfy the condition. Exceptions: ArgumentNullException The type arguments for method 'NPocoSqlExtensions.Where(Sql, Expression>, string?)' cannot be inferred from the usage. Try specifying the type arguments explicitly. – Menahem Gil Jan 26 '23 at 03:26
  • What I try to do is to get all the Childs of a DocumentType, since in the node I have folders, years, etc. I only want the items of Document Type blogPosts – Menahem Gil Jan 26 '23 at 03:27
  • If I understand correctly you want to get all blogPosts document types in `Section_node`. in that case try `Section_pages = Section_node.DescendantsOrSelf().ChildrenOfType("blogPosts");` also, you can use the other overload of `DescendantsOrSelf()` – Talkhak1313 Jan 26 '23 at 04:55

0 Answers0