DeleteUser Method for Entity Framework MVC3 Razor Custom Member Provider C# Using LINQ
From my
C# MVC3 Razor Custom Membership Provider article and source code, here is the code for the DeleteUser method. I welcome any suggestions for improvement.
public override bool DeleteUser(string username, bool deleteAllRelatedData)
{
// deleteAllRelatedData not implemented
try
{
using (var context = new SSSEntities())
{
UserProfile u = context.UserProfiles
.SingleOrDefault(up => up.UserName == username);
context.UserProfiles.DeleteObject(u);
context.SaveChanges();
return true;
}
}
catch
{
return false;
}
May your dreams be in ASP.NET!
Nannette Thacker