Rock.Model.LocationService.GetAllAncestorIds C# (CSharp) Method

GetAllAncestorIds() public method

Gets all ancestor ids.
public GetAllAncestorIds ( int locationId ) : IEnumerable
locationId int The location identifier.
return IEnumerable
        public IEnumerable<int> GetAllAncestorIds( int locationId )
        {
            return this.Context.Database.SqlQuery<int>( string.Format(
                @"
                WITH CTE AS (
                    SELECT [Id], [ParentLocationId], [Name] FROM [Location] WHERE [Id]={0}
                    UNION ALL
                    SELECT [a].[Id], [a].[ParentLocationId], [a].[Name] FROM [Location] [a]
                    INNER JOIN CTE ON CTE.[ParentLocationId] = [a].[Id]
                )
                SELECT [Id]
                FROM CTE
                WHERE [Name] IS NOT NULL
                AND [Name] <> ''
                ", locationId ) );
        }