Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public IEnumerable<PersistedTaxonomy> GetChildren(params int[] taxonomyId)
- {
- var query = @"with taxonomyCTE as
- (
- select * from Taxonomy t
- where t.TaxonomyId in (select ChildTaxonomyId from TaxonomyXTaxonomy where ParentTaxonomyId in @taxonomyId)
- union all
- select t.* from Taxonomy t
- join TaxonomyXTaxonomy txt on txt.ChildTaxonomyId = t.TaxonomyId
- join taxonomycte tcte on tcte.TaxonomyId = txt.ParentTaxonomyId
- )
- select distinct * from taxonomyCTE order by TaxonomyTypeId";
- using (var connection = new SqlConnection(ConnectionString))
- {
- connection.Open();
- return connection.Query<PersistedTaxonomy>(query, new { taxonomyId });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement