How can I convert below foreach statement in corresponding linq with possible null handling:
foreach (var val in userData.ManagedUsers.Values)
        {
            if (val.UserId == userId)
            {
                foreach (var role in val.Roles)
                {
                    switch (role.ToLower())
                    {
                        case "underwriter1":
                            return "1";
                        case "underwriter2":
                            return "2";
                        case "underwriter3":
                            return "3";
                    }
                }
            }
        }
 
     
     
    