0
votes

I am fairly new to this custom role provider(I think its good though), now I am trying to get the user to see or access certain parts of the web app based on their roles, this roles are in the database(admin,user and super_user). I have a class named UserRoleProvider and below is the part of it that seems not to work

public override string[] GetRolesForUser(string username)
    {
        using (CADDeContext caddeContext = new CADDeContext())
        {
            int? roleId = caddeContext.SMS_Staff.First().StaffSecurity;
            string site = caddeContext.SMS_Staff.First().BranchID;

            return new string[] { roleId.ToString() };
        }
    }

this method does not return any of the values in the database,what is returned its totally different from what I have in the database, where does it get all this values, I 100% I have the right connecting string in the web config, I have also double checked this connecttion with quickwatch. Below is the screenshot(without values) of all the fields I am expecting to get from the context

Expected database fields to be returned

1

1 Answers

0
votes

Oh no I cannot believe how big and stupid mistake I just did, there is no where clause on my query and also the inclusion of "first" on my query, threw everything off, I feel so stupid :(