我想对下面的代码提供一些反馈。我将如何在角色中对 FindUsersByName 实施模式匹配,以便不需要与用户名完全匹配?
// MembershipProvider.FindUsersByName
public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
{
MembershipUserCollection users = new MembershipUserCollection();
try
{
Profile.MembershipMapper memberMapper = new MembershipMapper();
List<Profile.Membership> recs = (List<Profile.Membership>)memberMapper.GetMembershipsByUsername(_memberUtil.GetApplicationId(), usernameToMatch, pageIndex, pageSize, out totalRecords);
foreach (Profile.Membership rec in recs)
{
users.Add(GetUserFromModel(rec, usernameToMatch));
}
}
catch (Exception ex)
{
Exception e = CheckEventLog(ex, "FindUsersByName");
throw e;
}
return users;
}