Skip to content

How to format members Roles expressions? #1205

Discussion options

You must be logged in to vote

Hi @rvgfox

This should give you what you need:

List<string> messages = new List<string>();

// Run through all roles
foreach (var role in Model.Roles)
{
    // Run through all tables to see if an RLS expression is set
    foreach (var table in role.RowLevelSecurity.Keys)
    {
        if (!string.IsNullOrEmpty(role.RowLevelSecurity[table]))
        {
            // Format the DAX expression
            role.RowLevelSecurity[table] = FormatDax(role.RowLevelSecurity[table]);
            messages.Add($"Role {role.Name} - Table {table}");
        }
    }
}

if (messages.Count > 0)
{
    Info("Formatted role expressions for:\r\n" + string.Join("\r\n", messages));
}
else
{
    Info("Didn't find…

Replies: 7 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@rvgfox
Comment options

Answer selected by mlonsk
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@DBojsen
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mlonsk
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content: script assistance Help on C# scripting
3 participants