- Timestamp:
- 05/29/20 13:28:25 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/JobDao.cs
r17180 r17574 37 37 } 38 38 39 public int DeleteByState(JobState state, int batchSize) { 40 return DataContext.ExecuteCommand(DeleteTopNByStateQueryString, batchSize, Enum.GetName(typeof(JobState), state)); 41 } 42 39 43 public IEnumerable<Job> GetByProjectId(Guid id) { 40 44 return GetByProjectIdQuery(DataContext, id); … … 43 47 public IEnumerable<Job> GetByProjectIds(IEnumerable<Guid> projectIds) { 44 48 string paramProjectIds = string.Join(",", projectIds.ToList().Select(x => string.Format("'{0}'", x))); 45 if (!string.IsNullOrWhiteSpace(paramProjectIds)) {49 if (!string.IsNullOrWhiteSpace(paramProjectIds)) { 46 50 string queryString = string.Format(GetByProjectIdsQueryString, paramProjectIds); 47 51 return DataContext.ExecuteQuery<Job>(queryString); … … 51 55 52 56 public IEnumerable<Job> GetByState(JobState state) { 53 return GetByStateQuery(DataContext, state );57 return GetByStateQuery(DataContext, state.ToString()); 54 58 } 55 59 56 60 public IEnumerable<Guid> GetJobIdsByState(JobState state) { 57 return GetJobIdsByStateQuery(DataContext, state );61 return GetJobIdsByStateQuery(DataContext, state.ToString()); 58 62 } 59 63 … … 74 78 where job.ProjectId == projectId 75 79 select job)); 76 private static readonly Func<DataContext, JobState, IEnumerable<Job>> GetByStateQuery =77 CompiledQuery.Compile((DataContext db, JobStatejobState) =>80 private static readonly Func<DataContext, string, IEnumerable<Job>> GetByStateQuery = 81 CompiledQuery.Compile((DataContext db, string jobState) => 78 82 (from job in db.GetTable<Job>() 79 where job.State == jobState83 where job.State.ToString() == jobState 80 84 select job)); 81 private static readonly Func<DataContext, JobState, IEnumerable<Guid>> GetJobIdsByStateQuery =82 CompiledQuery.Compile((DataContext db, JobStatejobState) =>85 private static readonly Func<DataContext, string, IEnumerable<Guid>> GetJobIdsByStateQuery = 86 CompiledQuery.Compile((DataContext db, string jobState) => 83 87 (from job in db.GetTable<Job>() 84 where job.State == jobState88 where job.State.ToString() == jobState 85 89 select job.JobId)); 86 90 private static readonly Func<DataContext, IEnumerable<Job>> GetJobsReadyForDeletionQuery = … … 101 105 WHERE JobState = {0} 102 106 "; 107 private const string DeleteTopNByStateQueryString = @" 108 DELETE TOP ({0}) 109 FROM [Job] 110 WHERE JobState = {1} 111 "; 103 112 private const string GetStatisticsPendingJobs = @" 104 113 SELECT DISTINCT j.*
Note: See TracChangeset
for help on using the changeset viewer.