问题描述
我有一个membershipusercollection,我想从一个特定的用户。不幸的是我不能用户 MembershipUser.GetUser()
方法。因此,目前我有所有成员资格用户的集合,像这样:
I have a membershipusercollection that I am trying to get one specific user from. Unfortunately I cannot user the MembershipUser.GetUser()
method. So currently I have a collection of all membership users like so:
MembershipUserCollection mc = Membership.GetAllUsers();
我想这样做的就是这些用户的其中一两种账号或电子邮件(并不重要)。我知道我可以做一个foreach循环的收集和比较,但我想像有一个更好的办法......
What I would like to do is get one of these users by either login or email (doesn't matter which). I realize I can do a foreach loop on the collection and compare but I have to imagine there is a better way....
在此先感谢...
对于那些好奇,为什么我不能用户的getUser方法,让只说这是由于SharePoint的。
For those curious why I cannot user the getuser method, lets just say it is because of sharepoint.
推荐答案
试试这个
mc.Cast<MembershipUser>().SingleOrDefault(m => m.UserName == "username");
这篇关于获得从MembershipUserCollection其中的MembershipUser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!