- Timestamp:
- 12/14/17 15:08:38 (6 years ago)
- Location:
- branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ProjectDao.cs
r15508 r15527 33 33 } 34 34 35 public IEnumerable<Project> Get ProjectsByChildId(Guid id) {36 return DataContext.ExecuteQuery<Project>(Get ProjectsByChildIdQuery, id);35 public IEnumerable<Project> GetChildProjectsById(Guid id) { 36 return DataContext.ExecuteQuery<Project>(GetChildProjectsByIdQuery, id); 37 37 } 38 38 39 public IEnumerable<Guid> GetProjectIdsByChildId(Guid id) { 40 return DataContext.ExecuteQuery<Guid>(GetProjectIdsByChildIdQuery, id); 39 public IEnumerable<Guid> GetChildProjectIdsById(Guid id) { 40 return DataContext.ExecuteQuery<Guid>(GetChildProjectIdsByIdQuery, id); 41 } 42 43 public IEnumerable<Project> GetParentProjectsById(Guid id) { 44 return DataContext.ExecuteQuery<Project>(GetParentProjectsByIdQuery, id); 45 } 46 47 public IEnumerable<Guid> GetParentProjectIdsById(Guid id) { 48 return DataContext.ExecuteQuery<Guid>(GetParentProjectIdsByIdQuery, id); 49 } 50 51 public IEnumerable<Project> GetCurrentAndParentProjectsById(Guid id) { 52 return DataContext.ExecuteQuery<Project>(GetCurrentAndParentProjectsByIdQuery, id); 53 } 54 55 public IEnumerable<Guid> GetCurrentAndParentProjectIdsById(Guid id) { 56 return DataContext.ExecuteQuery<Guid>(GetCurrentAndParentProjectIdsByIdQuery, id); 41 57 } 42 58 … … 50 66 51 67 #region String queries 52 private const string Get ProjectsByChildIdQuery = @"53 68 private const string GetChildProjectsByIdQuery = @" 69 WITH ptree AS 54 70 ( 55 71 SELECT ProjectId, ParentProjectId 56 72 FROM [Project] 57 73 UNION ALL 58 74 SELECT pt.ProjectId, p.ParentProjectId … … 62 78 SELECT DISTINCT pro.* 63 79 FROM ptree, [Project] pro 64 WHERE ptree.P rojectId = {0}65 AND ptree.ParentProjectId = pro.ProjectId80 WHERE ptree.ParentProjectId = {0} 81 AND ptree.ProjectId = pro.ProjectId 66 82 "; 67 private const string Get ProjectIdsByChildIdQuery = @"83 private const string GetChildProjectIdsByIdQuery = @" 68 84 WITH ptree AS 85 ( 86 SELECT ProjectId, ParentProjectId 87 FROM [Project] 88 UNION ALL 89 SELECT pt.ProjectId, r.ParentProjectId 90 FROM [Project] r 91 JOIN ptree pt ON pt.ParentProjectId = r.ProjectId AND r.ParentProjectId <> r.ProjectId AND pt.ParentProjectId <> pt.ProjectId 92 ) 93 SELECT DISTINCT ptree.ProjectId 94 FROM ptree 95 WHERE ptree.ParentProjectId = {0} 96 "; 97 private const string GetParentProjectsByIdQuery = @" 98 WITH pbranch AS 69 99 ( 70 100 SELECT ProjectId, ParentProjectId 71 101 FROM [Project] 72 102 UNION ALL 73 SELECT p t.ProjectId, p.ParentProjectId103 SELECT pb.ProjectId, p.ParentProjectId 74 104 FROM [Project] p 75 JOIN p tree pt ON pt.ParentProjectId = p.ProjectId AND p.ParentProjectId <> p.ProjectId AND pt.ParentProjectId <> pt.ProjectId105 JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId AND p.ParentProjectId <> p.ProjectId AND pb.ParentProjectId <> pb.ProjectId 76 106 ) 77 SELECT DISTINCT ptree.ParentProjectId 78 FROM ptree 79 WHERE ptree.ProjectId = {0} 107 SELECT DISTINCT pro.* 108 FROM pbranch, [Project] pro 109 WHERE pbranch.ProjectId = {0} 110 AND pbranch.ParentProjectId = pro.ProjectId 111 "; 112 private const string GetParentProjectIdsByIdQuery = @" 113 WITH pbranch AS 114 ( 115 SELECT ProjectId, ParentProjectId 116 FROM [Project] 117 UNION ALL 118 SELECT pb.ProjectId, p.ParentProjectId 119 FROM [Project] p 120 JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId AND p.ParentProjectId <> p.ProjectId AND pb.ParentProjectId <> pb.ProjectId 121 ) 122 SELECT DISTINCT pbranch.ParentProjectId 123 FROM pbranch 124 WHERE pbranch.ProjectId = {0} 125 "; 126 private const string GetCurrentAndParentProjectsByIdQuery = @" 127 WITH pbranch AS 128 ( 129 SELECT ProjectId, ParentProjectId 130 FROM Project 131 WHERE ProjectId = {0} 132 UNION ALL 133 SELECT p.ProjectId, p.ParentProjectId 134 FROM Project p 135 JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId 136 ) 137 SELECT DISTINCT pro.* 138 FROM pbranch, Project pro 139 WHERE pbranch.ProjectId = pro.ProjectId 140 "; 141 private const string GetCurrentAndParentProjectIdsByIdQuery = @" 142 WITH pbranch AS 143 ( 144 SELECT ProjectId, ParentProjectId 145 FROM Project 146 WHERE ProjectId = {0} 147 UNION ALL 148 SELECT p.ProjectId, p.ParentProjectId 149 FROM Project p 150 JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId 151 ) 152 SELECT DISTINCT pbranch.ProjectId 153 FROM pbranch 80 154 "; 81 155 #endregion -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ResourceDao.cs
r15503 r15527 41 41 } 42 42 43 public IEnumerable<Resource> Get ResourcesByParentId(Guid id) {44 return DataContext.ExecuteQuery<Resource>(Get ResourcesByParentIdQuery, id);43 public IEnumerable<Resource> GetChildResourcesById(Guid id) { 44 return DataContext.ExecuteQuery<Resource>(GetChildResourcesByIdQuery, id); 45 45 } 46 46 47 public IEnumerable<Guid> Get ResourceIdsByParentId(Guid id) {48 return DataContext.ExecuteQuery<Guid>(Get ResourceIdsByParentIdQuery, id);47 public IEnumerable<Guid> GetChildResourceIdsById(Guid id) { 48 return DataContext.ExecuteQuery<Guid>(GetChildResourceIdsByIdQuery, id); 49 49 } 50 50 51 public IEnumerable<Resource> Get ResourcesByChildId(Guid id) {52 return DataContext.ExecuteQuery<Resource>(Get ResourcesByChildIdQuery, id);51 public IEnumerable<Resource> GetParentResourcesById(Guid id) { 52 return DataContext.ExecuteQuery<Resource>(GetParentResourcesByIdQuery, id); 53 53 } 54 54 55 public IEnumerable<Guid> GetResourceIdsByChildId(Guid id) { 56 return DataContext.ExecuteQuery<Guid>(GetResourceIdsByChildIdQuery, id); 55 public IEnumerable<Guid> GetParentResourceIdsById(Guid id) { 56 return DataContext.ExecuteQuery<Guid>(GetParentResourceIdsByIdQuery, id); 57 } 58 59 public IEnumerable<Resource> GetCurrentAndParentResourcesById(Guid id) { 60 return DataContext.ExecuteQuery<Resource>(GetCurrentAndParentResourcesByIdQuery, id); 61 } 62 63 public IEnumerable<Guid> GetCurrentAndParentResourceIdsById(Guid id) { 64 return DataContext.ExecuteQuery<Guid>(GetCurrentAndParentResourceIdsByIdQuery, id); 57 65 } 58 66 … … 72 80 73 81 #region String queries 74 private const string Get ResourcesByParentIdQuery = @"82 private const string GetChildResourcesByIdQuery = @" 75 83 WITH rtree AS 76 84 ( … … 84 92 SELECT DISTINCT res.* 85 93 FROM rtree, [Resource] res 86 WHERE rtree.ParentResourceId = ({0})94 WHERE rtree.ParentResourceId = {0} 87 95 AND rtree.ResourceId = res.ResourceId 88 96 "; 89 private const string Get ResourceIdsByParentIdQuery = @"97 private const string GetChildResourceIdsByIdQuery = @" 90 98 WITH rtree AS 91 99 ( … … 99 107 SELECT DISTINCT rtree.ResourceId 100 108 FROM rtree 101 WHERE rtree.ParentResourceId = ({0})109 WHERE rtree.ParentResourceId = {0} 102 110 "; 103 private const string Get ResourcesByChildIdQuery = @"104 WITH r treeAS111 private const string GetParentResourcesByIdQuery = @" 112 WITH rbranch AS 105 113 ( 106 114 SELECT ResourceId, ParentResourceId 107 115 FROM [Resource] 108 116 UNION ALL 109 SELECT r t.ResourceId, r.ParentResourceId117 SELECT rb.ResourceId, r.ParentResourceId 110 118 FROM [Resource] r 111 JOIN r tree rt ON rt.ParentResourceId = r.ResourceId AND r.ParentResourceId <> r.ResourceId AND rt.ParentResourceId <> rt.ResourceId119 JOIN rbranch rb ON rb.ParentResourceId = r.ResourceId AND r.ParentResourceId <> r.ResourceId AND rb.ParentResourceId <> rb.ResourceId 112 120 ) 113 121 SELECT DISTINCT res.* 114 FROM r tree, [Resource] res115 WHERE r tree.ResourceId = ({0})116 AND r tree.ParentResourceId = res.ResourceId122 FROM rbranch, [Resource] res 123 WHERE rbranch.ResourceId = {0} 124 AND rbranch.ParentResourceId = res.ResourceId 117 125 "; 118 private const string Get ResourceIdsByChildIdQuery = @"119 WITH r treeAS126 private const string GetParentResourceIdsByIdQuery = @" 127 WITH rbranch AS 120 128 ( 121 129 SELECT ResourceId, ParentResourceId 122 130 FROM [Resource] 123 131 UNION ALL 124 SELECT r t.ResourceId, r.ParentResourceId132 SELECT rb.ResourceId, r.ParentResourceId 125 133 FROM [Resource] r 126 JOIN r tree rt ON rt.ParentResourceId = r.ResourceId AND r.ParentResourceId <> r.ResourceId AND rt.ParentResourceId <> rt.ResourceId134 JOIN rbranch rb ON rb.ParentResourceId = r.ResourceId AND r.ParentResourceId <> r.ResourceId AND rb.ParentResourceId <> rb.ResourceId 127 135 ) 128 SELECT DISTINCT rtree.ParentResourceId 129 FROM rtree 130 WHERE rtree.ResourceId = ({0}) 136 SELECT DISTINCT rbranch.ParentResourceId 137 FROM rbranch 138 WHERE rbranch.ResourceId = {0} 139 "; 140 private const string GetCurrentAndParentResourcesByIdQuery = @" 141 WITH rbranch AS 142 ( 143 SELECT ResourceId, ParentResourceId 144 FROM [Resource] 145 WHERE ResourceId = {0} 146 UNION ALL 147 SELECT r.ResourceId, r.ParentResourceId 148 FROM [Resource] r 149 JOIN rbranch rb ON rb.ParentResourceId = r.ResourceId 150 ) 151 SELECT DISTINCT res.* 152 FROM rbranch, [Resource] res 153 WHERE rbranch.ResourceId = res.ResourceId 154 "; 155 private const string GetCurrentAndParentResourceIdsByIdQuery = @" 156 WITH rbranch AS 157 ( 158 SELECT ResourceId, ParentResourceId 159 FROM [Resource] 160 WHERE ResourceId = {0} 161 UNION ALL 162 SELECT r.ResourceId, r.ParentResourceId 163 FROM [Resource] r 164 JOIN rbranch rb ON rb.ParentResourceId = r.ResourceId 165 ) 166 SELECT DISTINCT rbranch.ResourceId 167 FROM rbranch 131 168 "; 132 169 #endregion
Note: See TracChangeset
for help on using the changeset viewer.