vendredi 8 janvier 2016

Need List of Users into viewbag, whose Role is "xyz"

Roles

ApplicationId UNIQUEIDENTIFIER NOT NULL,
RoleId        UNIQUEIDENTIFIER NOT NULL,
RoleName      NVARCHAR (256) NOT NULL,
Description   NVARCHAR (256),
PRIMARY KEY (RoleId),

Users

ApplicationId    UNIQUEIDENTIFIER NOT NULL,
UserId           UNIQUEIDENTIFIER NOT NULL,
UserName         NVARCHAR (50) NOT NULL,
IsAnonymous      BIT NOT NULL,
LastActivityDate DATETIME NOT NULL,
PRIMARY KEY (UserId),

UsersInRoles

UserId UNIQUEIDENTIFIER NOT NULL,
RoleId UNIQUEIDENTIFIER NOT NULL,
PRIMARY KEY (UserId, RoleId),
CONSTRAINT UsersInRoleRole FOREIGN KEY (RoleId) REFERENCES dbo.Roles (RoleId),
CONSTRAINT UsersInRoleUser FOREIGN KEY (UserId) REFERENCES dbo.Users (UserId)

i need all the username from users table whose rolename is like xyz into a viewbag, so i can display the Usenames in dropdopwn

Aucun commentaire:

Enregistrer un commentaire