0
ここで私は全ての投稿とコメントを取得していますが、問題は私がデバッグしたときにGetAllPostに2つ以上のデータが表示されますが、その、一度にすべてのデータを返さないのはなぜたびに、あなたがそれによって前に開催されたものは何でも捨て、GetAllPost
に代入している、ループを通って...オブジェクトのリストを追加して返す方法
public dynamic getalldetails(int friendsid)
{
var GetAllPost = (dynamic)null;
FriendsId =dbContext.Usertable.where(u=>u.userID==friendsid).tolist();
if(FriendsId!=null)
foreach(var item in FriendsId)
{
GetAllPost = (from post in db.Posts.where(item.userID==post.userID).ToList()
orderby post.PostedDate descending
select new
{
Message = post.Message,
PostedBy = post.PostedBy,
PostedByName = post.UserProfile.UserName,
PostedByAvatar =imgFolder + (String.IsNullOrEmpty(post.UserProfile.AvatarExt) ? defaultAvatar : post.PostedBy + "." + post.UserProfile.AvatarExt),
PostedDate = post.PostedDate,
PostId = post.PostId,
PostComments = from comment in post.PostComments.ToList()
orderby comment.CommentedDate
select new
{
CommentedBy = comment.CommentedBy,
CommentedByName = comment.UserProfile.UserName,
CommentedByAvatar = imgFolder +(String.IsNullOrEmpty(comment.UserProfile.AvatarExt) ? defaultAvatar : comment.CommentedBy + "." + comment.UserProfile.AvatarExt),
CommentedDate = comment.CommentedDate,
CommentId = comment.CommentId,
Message = comment.Message,
PostId = comment.PostId
}
}).AsEnumerable();
}
return GetAllPost;
}
あなたのコードを読むのはとても難しいです。あなたは適切なシンボルを含めることができますか?そしてドット? –
コードは正しくコンパイルされませんので、最初に修正してください。私たちが助けてくれるのをやめさせたら、私たちの助けを期待しないでください。 –