MembershipUser.TryParse()
有谁知道等值吗?
目前我正在做..
Dim myUsers As New MembershipUserCollection
Dim myUser As MembershipUser
Dim RoleUsers() As String
RoleUsers = Roles.GetUsersInRole("User")
For Each x As String In RoleUsers
Dim roleUser As MembershipUser
roleUser = Membership.GetUser(x)
If Not roleUser Is Nothing Then
myUsers.Add(Membership.GetUser(x))
End If
Next
只是想知道是否有类似..
If MembershipUser.TryParse(Membership.GetUser(x),myUser) Then
myUsers.Add(myUser)
End If
VB 或C# 的东西可以工作。
Anyone know an equiv?
Currently I'm doing..
Dim myUsers As New MembershipUserCollection
Dim myUser As MembershipUser
Dim RoleUsers() As String
RoleUsers = Roles.GetUsersInRole("User")
For Each x As String In RoleUsers
Dim roleUser As MembershipUser
roleUser = Membership.GetUser(x)
If Not roleUser Is Nothing Then
myUsers.Add(Membership.GetUser(x))
End If
Next
Just wondering if there's something like..
If MembershipUser.TryParse(Membership.GetUser(x),myUser) Then
myUsers.Add(myUser)
End If
VB or C# works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是没有方法(无论是在 Roles 中还是在 MembershipUser 中)处理类而不是字符串名称。
因此,直接 SQL 到数据库可能有意义(在使用 SqlMembershipProvider 的情况下)。
使用 LINQ 可以使您的代码更加优雅,但不能解决性能问题。
The problem is no method (neither in Roles nor in MembershipUser ) that deals with class instead of string name.
So may be there is a sense in direct SQL to database (in case of SqlMembershipProvider usage).
Using LINQ makes your code more elegant but doesn't resolve performance issue.