hello can anyone give me an example of return type
(local variable)IEnumerable<'a> ret
Anonymous Types:
'a is new{string Message,int PostedBy,string PostedByName,String PostedByAvatar,DateTime PostedDate,int PostID,IEnumerable<'b> PostComments}
'B is new{int CommentedBy,string CommentedByName,string CommentedByAvatar,DateTime CommentedDate,int Commentid,string Message,int Postid)
and i code like this :
Public Function GetPosts() As IEnumerable(Of Post)
Dim posts = (From post In db.Posts.ToList() Order By post.PostedDate Descending Select New With { _
Key .message = post.Message, _
Key .postedby = post.PostedBy, _
Key .postedbyname = post.UserProfile.UserName, _
Key .postedbyavatar = imgFolder & Convert.ToString((If([String].IsNullOrEmpty(post.UserProfile.AvatarExt), defaultAvatar, post.PostedBy + "." + post.UserProfile.AvatarExt))), _
Key .posteddate = post.PostedDate, _
Key .postid = post.PostId, _
Key .postcomments = From comment In post.PostComments.ToList() Order By comment.CommentedDate Select New With { _
Key .commentedby = comment.CommentedBy, _
Key .commentedbyname = comment.UserProfile.UserName, _
Key .commentedbyavatar = imgFolder & Convert.ToString((If([String].IsNullOrEmpty(comment.UserProfile.AvatarExt), defaultAvatar, comment.CommentedBy + "." + comment.UserProfile.AvatarExt))), _
Key .commenteddate = comment.CommentedDate, _
Key .commentid = comment.CommentId, _
Key .message = comment.Message, _
Key .postid = comment.PostId _
} _
})
Return posts.AsEnumerable
End Function
Aucun commentaire:
Enregistrer un commentaire