UmbracoのブログコンテンツをXMLにエクスポートするブログのエクスポートパッケージがあります。Umbraco子ノードをリストに設定するには<T>
NewsItemノードでコメントセクションをchildNodeとして設定していますが、このフォーマットを使用してchildNodeからリストにデータを取り込むにはどうすればよいですか?ここで
が私のコードです:
public List<BlogPosts> getPostList()
{
var contentType = ApplicationContext.Current.Services.ContentTypeService
.GetContentType("umbNewsItem");
var nodes = ApplicationContext.Current.Services.ContentService
.GetContentOfContentType(contentType.Id).Select(content => new Node(content.Id));
return nodes.Select(node => new BlogPosts()
{
Title = node.GetProperty("title").ToNullSafeString(),
BodyText = node.GetProperty("bodyText").ToNullSafeString(),
PublishDate = node.GetProperty("publishDate").ToNullSafeString(),
Author = node.GetProperty("author").ToNullSafeString(),
Image = node.GetProperty("image").ToNullSafeString(),
//This is where I want to grab the blog comments content
Comments = node.ChildrenAsList.Add("comments")
}).ToList();
}
これで私の最初の試み、私は.Add上のエラー( "コメント")を取得読み込む行:
The best overloaded method match for 'System.Collections.Generic.List<umbraco.interfaces.INode>.Add(umbraco.interfaces.INode)' has some invalid arguments
次の事I
Comments = node.ChildrenAsList<BlogComment>.Add("comments").ToList()
次のエラーを返す:
このでしてみましたこのエラーを返さComments = node.ChildrenAsList.Add("comments").ToList()
:
The best overloaded method match for 'System.Collections.Generic.List<umbraco.interfaces.INode>.Add(umbraco.interfaces.INode)' has some invalid arguments
これは私のブログ記事のモデルである:
public class BlogPosts
{
public string Title { get; set; }
public string BodyText { get; set; }
public string PublishDate { get; set; }
public string Author { get; set; }
public string Image { get; set; }
public List<BlogComment> Comments { get; set; }
}
public class BlogComment
{
public string Comment { get; set; }
public string CommentDate { get; set; }
}
これはUmbracoの一例である
The property 'umbraco.NodeFactory.Node.ChildrenAsList' cannot be used with type arguments
は私もこれを試してみましたバックオフィスページ: Image
私はstackoverflowの全体検索し、リストにchildNodeがからデータを呼び出すことを意味しますが、これを使用するときに、ここでリストタイプは、iノードである何のためにグーグルました:
Comments = node.ChildrenAsList
それがこのエラーを返します。
オーケーCannot implicitly convert type 'System.Collections.Generic.List<umbraco.interfaces.INode>' to 'System.Collections.Generic.List<UmbracoBlogsExportPackage.Models.BlogComment>'
Dude。あなたはあなたが試したことを説明しなければなりません。スタックオーバーフローを尋ねる前に少しだけ調べたことを示す必要があります。あなたは働いていないものを説明しなければなりません。さもなければ私達はあなたを助けることができません。私はこの質問を見て、「彼は何が問題になっていますか?あなたが既に試したことに関するエラー情報や情報を含んでいないからです。 良い質問をする助けがあります: –
Stack Overflowあなたが本当に立ち往生して、あなたがすべてを研究したときに、あなたがそれをして、それから学習しなければならない、あなたが考えることができるすべてを試しましたが、あなたの質問にすべてを入れることができ、より良い助けを得ることができます。 –
私も試しました: 'Comments = node.ChildrenAsList.Find(System.Predicate .Find(System.Predicate < (umbraco.interfaces.INode>)に無効な引数があります。 –