Solved

ASP.Net MVC 4 C# -- Roles.GetRolesForUser() "LIKE" statement ?

Posted on 2013-06-19
1
1,184 Views
Last Modified: 2013-06-20
I have 20+ roles that start with "BUICK"
How can I get the below "LIKE" statement working ?

I am MVC4 simpleMembership with the below SYSTEM generated database tables.
  webpages_UsersInRoles
  UserProfile
  webpages_Membership
  webpages_Roles

                               if (User.IsInRole("BUICK_LeadMan")) --below works
                               -- trying to do this instead, but it fails --> if (Roles.GetRolesForUser().LIKE("BUICK"))
                                   {
                                       <li>@Html.ActionLink("About1", "About", "Home")</li>
                                   }
0
Comment
Question by:finance_teacher
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39260895
Hi finance_teacher;

You can try using the Linq method to achieve what you need.

if (Roles.GetRolesForUser().Any( u => u.StartsWith("BUICK")))
{ 
    <li>@Html.ActionLink("About1", "About", "Home")</li>
}

Open in new window

0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question