Nannette Thacker ShiningStar.net

ASP.net Web Application Development

Sponsors

News

See all Blog Posts by Nannette.

Nannette Thacker, consultant and owner of Shining Star Services LLC, specializes in development of custom dynamic database driven web applications utilizing ASP.net technologies. Nannette has been developing ASP sites since 1997. Nannette has written numerous articles on web development techniques and tutorials.

Nannette is the owner and developer of ChristianSinglesDating.com.

 Subscribe in a reader





View Nannette  Thacker's profile on LinkedIn

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


View Nannette  Thacker's profile on LinkedIn

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required)