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 ) );
}