Click here to Skip to main content
15,909,747 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

i am writing to seek help, in how do i assign a single role to following query using 'string array []':

Updated query code:
C#
   public UserDetail trial(string username, string password)
{

    string[] Role = new string[] { "trial"};


    var query = (from s in db.Subs
                join u in db.UserDetails on s.sUID equals u.uID
                where s.sExpiryDate >= DateTime.Now &&
                u.uUsername == username &&
                u.uPassword == password
                select u).FirstOrDefault();

    if (query != null)
    {
        // Build a user and add the appropriate Trial role
        return new UserDetail() { username = query.uUsername, password = query.uPassword, Role = "Trial" };
    }
    else
    {
        // No user was found
        return null;
    }

}


I am currently having issue with defining the parameters such as username, password and role, and its outputting compiling error of 'does not contain definition for username' If anyone could advise on this issue, it would be very much appreciated.

Please note, i do not have role field setup in my database server.

Many thanks
Posted
Updated 19-Mar-14 7:11am
v3
Comments
Dinesh.V.Kumar 17-Mar-14 13:27pm    
Can you please elaborate on your query?
miss786 17-Mar-14 13:39pm    
hi, thank you for your response. I am not clear what would you like me to elaborate on, with the above query.
I would like to know, how can I assign a role to my query, so when i search for a username and password, it would display its assigned role. Hope this clarifies any misunderstanding.

Many thanks for your help.

1 solution

If you don't have a role field for each user, how are you going to determine which role(s) a user is a part of??
 
Share this answer
 
Comments
miss786 17-Mar-14 20:02pm    
Thank you for your response. thank you for clarifying this up. Is their a way to name or group this query? I have another two queries which call users and these queries represent different group of users, so i was wondering if their is a way to label the query above as particular user group, without the rolename fieldname from the database, so I can test query by:
if user details match query1(trial)
{
return page 1
}
else...

any help much appreciated. many thanks.
Dave Kreskowiak 17-Mar-14 20:05pm    
I have no idea because you haven't supplied anything that resembles a complete schema for users and their group/role memberships.
miss786 19-Mar-14 14:00pm    
Hi, I manage to update my code and if you get time, could you please advise on the issue I am currently experiencing(please the above updated code), if possible please. Many thanks for your time and help.
Dave Kreskowiak 19-Mar-14 17:05pm    
You STILL don't have any mapping column to do a join on. There is nothing that says "this user is a member of this role".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900