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

GetUser Methods 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 GetUser methods. I welcome any suggestions for improvement.
public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
{
    using (var context = new SSSEntities())
    {
        UserProfile u = context.UserProfiles
                    .SingleOrDefault(up => up.UserId == Convert.ToInt32(providerUserKey));
        MembershipUser membershipUser = GetMembershipUser(u);
        return membershipUser;
    }
}
public override MembershipUser GetUser(string username, bool userIsOnline)
{
    using (var context = new SSSEntities())
    {
        UserProfile u = context.UserProfiles
            .SingleOrDefault(up => up.UserName == username);
        MembershipUser membershipUser = GetMembershipUser(u);
        return membershipUser;
    }
}
// custom method to return a UserProfile
public UserProfile GetUser(string username)
{
    using (var context = new SSSEntities())
    {
        UserProfile u = context.UserProfiles
            .SingleOrDefault(up => up.UserName == username);
        return u;
    }
}
// custom method to return a UserProfile
public UserProfile GetUser(object providerUserKey)
{
    using (var context = new SSSEntities())
    {
        UserProfile u = context.UserProfiles
                    .SingleOrDefault(up => up.UserId == Convert.ToInt32(providerUserKey));
        return u;
    }
}


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)