Changeset 15966 for branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/JobDao.cs
- Timestamp:
- 06/19/18 15:51:41 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/JobDao.cs
r15908 r15966 32 32 return GetByIdQuery(DataContext, id); 33 33 } 34 34 35 35 public void DeleteByState(JobState state) { 36 36 DataContext.ExecuteCommand(DeleteByStateQueryString, Enum.GetName(typeof(JobState), state)); 37 } 38 39 public IEnumerable<Job> GetByProjectId(Guid id) { 40 return GetByProjectIdQuery(DataContext, id); 41 } 42 43 public IEnumerable<Job> GetByProjectIds(IEnumerable<Guid> projectIds) { 44 string paramProjectIds = string.Join(",", projectIds.ToList().Select(x => string.Format("'{0}'", x))); 45 if(!string.IsNullOrWhiteSpace(paramProjectIds)) { 46 string queryString = string.Format(GetByProjectIdsQueryString, paramProjectIds); 47 return DataContext.ExecuteQuery<Job>(queryString); 48 } 49 return Enumerable.Empty<Job>(); 37 50 } 38 51 … … 56 69 where job.JobId == jobId 57 70 select job).SingleOrDefault()); 71 private static readonly Func<DataContext, Guid, IEnumerable<Job>> GetByProjectIdQuery = 72 CompiledQuery.Compile((DataContext db, Guid projectId) => 73 (from job in db.GetTable<Job>() 74 where job.ProjectId == projectId 75 select job)); 58 76 private static readonly Func<DataContext, JobState, IEnumerable<Job>> GetByStateQuery = 59 77 CompiledQuery.Compile((DataContext db, JobState jobState) => … … 92 110 WHERE t.JobId = j.JobId) 93 111 "; 112 private const string GetByProjectIdsQueryString = @" 113 SELECT DISTINCT j.* 114 FROM [Job] j 115 WHERE j.ProjectId IN ({0}) 116 "; 94 117 #endregion 95 118 }
Note: See TracChangeset
for help on using the changeset viewer.