-
-
C# 的Dynamic 类 转为vb怎么实现?
-
发表于: 2015-5-6 11:32 3342
-
这是C#语言
以下是转为vb代码
运行时总是在ret中出错,请问上面的C#如何转为正确的vb语言。
补充一下问题已经解决,代码可以运行了,不过不能显示旧的发帖内容。具体请下载 SocialNetwork.rar
public dynamic GetPosts()
{
var ret = (from post in db.Posts.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 ret;
}以下是转为vb代码
Public Function GetPosts() As IEnumerable(Of Post)
Dim ret = (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 _
} _
}).AsEnumerable()
Return ret
End Function运行时总是在ret中出错,请问上面的C#如何转为正确的vb语言。
补充一下问题已经解决,代码可以运行了,不过不能显示旧的发帖内容。具体请下载 SocialNetwork.rar
[培训]传播安全知识、拓宽行业人脉——看雪讲师团队等你加入!
赞赏
他的文章
- C# 的Dynamic 类 转为vb怎么实现? 3343
- [讨论]C语言变态乱码 7272
- [原创]汇编加密助手 附源码 12026
- [已解决]求一个简单的combobox例子 3871
谁下载
谁下载
谁下载
赞赏
雪币:
留言: