E
EagleRed
I am writing a custom MembershipProvider. A snippet for the GetAllUsers
method follows.
// vw_lion_Apps_Membership is a view containing membership data.
Table<vw_lion_Apps_Membership> lionMembers =
_dbContext.GetTable<vw_lion_Apps_Membership>();
var members = from m in lionMembers
where (m.ApplicationId == appId)
select m;
List<vw_lion_Apps_Membership> memberList =
members.ToList<vw_lion_Apps_Membership>();
totalRecords = memberList.Count;
bool approved = false;
bool lockedOut = false;
foreach(vw_lion_Apps_Membership member in memberList)
{
if (member.IsApproved != null) approved =
(bool)member.IsApproved;
else approved = false;
if (member.IsLockedOut != null) lockedOut =
(bool)member.IsLockedOut;
else approved = false;
MembershipUser user = new MembershipUser(
this._name,
_name,
member.UserId,
member.LoweredEmail,
member.PasswordQuestion,
member.Comment,
approved,
lockedOut,
(DateTime)member.CreateDate,
(DateTime)member.LastLoginDate,
(DateTime)member.LastActivityDate,
(DateTime)member.LastPasswordChangedDate,
(DateTime)member.LastLockoutDate
);
users.Add(user);
} // end foreach(vw_lion_Apps_Membership member in memberList)
The problem arises from the providerName parameter in the MembershipUser
constructor which is the same for each instance to be added to the
collection.
This causes the statement, users.Add(user);, to throw an exception because
apparently the providerName is a key in the MembershipUserCollection. How
can I deal with this? (I have tried using the UserName in this and I get
another exception for an invalid providerName.)
This is confusing.
Any input would be greatly appreciated.
Thanks,
Eagle
method follows.
// vw_lion_Apps_Membership is a view containing membership data.
Table<vw_lion_Apps_Membership> lionMembers =
_dbContext.GetTable<vw_lion_Apps_Membership>();
var members = from m in lionMembers
where (m.ApplicationId == appId)
select m;
List<vw_lion_Apps_Membership> memberList =
members.ToList<vw_lion_Apps_Membership>();
totalRecords = memberList.Count;
bool approved = false;
bool lockedOut = false;
foreach(vw_lion_Apps_Membership member in memberList)
{
if (member.IsApproved != null) approved =
(bool)member.IsApproved;
else approved = false;
if (member.IsLockedOut != null) lockedOut =
(bool)member.IsLockedOut;
else approved = false;
MembershipUser user = new MembershipUser(
this._name,
_name,
member.UserId,
member.LoweredEmail,
member.PasswordQuestion,
member.Comment,
approved,
lockedOut,
(DateTime)member.CreateDate,
(DateTime)member.LastLoginDate,
(DateTime)member.LastActivityDate,
(DateTime)member.LastPasswordChangedDate,
(DateTime)member.LastLockoutDate
);
users.Add(user);
} // end foreach(vw_lion_Apps_Membership member in memberList)
The problem arises from the providerName parameter in the MembershipUser
constructor which is the same for each instance to be added to the
collection.
This causes the statement, users.Add(user);, to throw an exception because
apparently the providerName is a key in the MembershipUserCollection. How
can I deal with this? (I have tried using the UserName in this and I get
another exception for an invalid providerName.)
This is confusing.
Any input would be greatly appreciated.
Thanks,
Eagle