Changeset 12691 for branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ResourceDao.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/ResourceDao.cs
r12468 r12691 29 29 30 30 public override Resource GetById(Guid id) { 31 return Table.SingleOrDefault(x => x.ResourceId == id); 31 return GetByIdQuery(DataContext, id); 32 } 33 34 public Resource GetByName(string name) { 35 return GetByNameQuery(DataContext, name); 32 36 } 33 37 … … 35 39 return Table.Where(x => x.OwnerUserId != null); 36 40 } 41 42 #region Compiled queries 43 private static readonly Func<DataContext, Guid, Resource> GetByIdQuery = 44 CompiledQuery.Compile((DataContext db, Guid resourceId) => 45 (from resource in db.GetTable<Resource>() 46 where resource.ResourceId == resourceId 47 select resource).SingleOrDefault()); 48 49 private static readonly Func<DataContext, string, Resource> GetByNameQuery = 50 CompiledQuery.Compile((DataContext db, string name) => 51 (from resource in db.GetTable<Resource>() 52 where resource.Name == name 53 select resource).FirstOrDefault()); 54 #endregion 37 55 } 38 56 }
Note: See TracChangeset
for help on using the changeset viewer.