Changeset 12691 for branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ResourcePermissionDao.cs
- Timestamp:
- 07/08/15 15:51:32 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ResourcePermissionDao.cs
r12468 r12691 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Data.Linq; 25 using System.Linq; 24 26 25 27 namespace HeuristicLab.Services.Hive.DataAccess.Daos { … … 30 32 throw new NotImplementedException(); 31 33 } 34 35 public IEnumerable<ResourcePermission> GetByResourceId(Guid id) { 36 return GetByResourceIdGetByIdQuery(DataContext, id); 37 } 38 39 public void DeleteByResourceAndGrantedUserId(Guid resourceId, IEnumerable<Guid> grantedUserId) { 40 string paramIds = string.Join(",", grantedUserId.Select(x => string.Format("'{0}'", x))); 41 if (!string.IsNullOrWhiteSpace(paramIds)) { 42 string query = string.Format(DeleteByGrantedUserQuery, resourceId, paramIds); 43 DataContext.ExecuteCommand(query); 44 } 45 } 46 47 #region Compiled queries 48 private static readonly Func<DataContext, Guid, IEnumerable<ResourcePermission>> GetByResourceIdGetByIdQuery = 49 CompiledQuery.Compile((DataContext db, Guid resourceId) => 50 from resourcePermission in db.GetTable<ResourcePermission>() 51 where resourcePermission.ResourceId == resourceId 52 select resourcePermission); 53 #endregion 54 55 #region String queries 56 private const string DeleteByGrantedUserQuery = 57 @"DELETE FROM [ResourcePermission] 58 WHERE ResourceId = '{0}' 59 AND GrantedUserId IN ({1});"; 60 #endregion 32 61 } 33 62 }
Note: See TracChangeset
for help on using the changeset viewer.