Solved

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

Posted on 2013-06-19
1
1,139 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
1 Comment
 
LVL 62

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Remove greater than sign 3 43
C# Json POSt to Rest API 4 37
Javascript and Jquery not firing 9 39
How to add <appSettings> to the webconfig file 2 20
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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now