using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using NHibernate.Linq; using Taloyhtio.GeneralSSO.Server.CodeFiles.Entities; using Taloyhtio.GeneralSSO.Server.CodeFiles.Infrastructure.DataAccess; namespace Taloyhtio.GeneralSSO.Server.CodeFiles.Repositories.Impl { public class SymmetricCryptoKeyRepository : AtomicRepositoryBase, ISymmetricCryptoKeyRepository { public SymmetricCryptoKeyRepository(ISessionSource sessionSource) : base(sessionSource) { } public SymmetricCryptoKey GetBy(string bucket, string handle) { // it is critical that this lookup be case-sensitive, which can only be configured at the database. return this.GetSession().Linq().FirstOrDefault(k => k.Bucket == bucket && k.Handle == handle); } public IEnumerable GetByOrderedByExpirationDesc(string bucket) { return this.GetSession().Linq().Where(k => k.Bucket == bucket).OrderByDescending(k => k.ExpirationDate).ToList(); } } }