Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. public IEnumerable<PersistedTaxonomy> GetChildren(params int[] taxonomyId)
  2. {
  3. var query = @"with taxonomyCTE as
  4. (
  5. select * from Taxonomy t
  6. where t.TaxonomyId in (select ChildTaxonomyId from TaxonomyXTaxonomy where ParentTaxonomyId in @taxonomyId)
  7. union all
  8. select t.* from Taxonomy t
  9. join TaxonomyXTaxonomy txt on txt.ChildTaxonomyId = t.TaxonomyId
  10. join taxonomycte tcte on tcte.TaxonomyId = txt.ParentTaxonomyId
  11. )
  12. select distinct * from taxonomyCTE order by TaxonomyTypeId";
  13. using (var connection = new SqlConnection(ConnectionString))
  14. {
  15. connection.Open();
  16. return connection.Query<PersistedTaxonomy>(query, new { taxonomyId });
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement