/// <summary> /// Gets the list of roles lookup values. /// </summary> /// <returns> /// List of roles lookup values. /// </returns> /// <exception cref="System.NotImplementedException"></exception> public IEnumerable <LookupKeyValue> GetUserRoles() { Role alias = null; LookupKeyValue lookupAlias = null; return(unitOfWork.Session .QueryOver(() => alias) .SelectList(select => select .Select(Projections.Cast(NHibernateUtil.String, Projections.Property <Role>(c => c.Id))).WithAlias(() => lookupAlias.Key) .Select(() => alias.Name).WithAlias(() => lookupAlias.Value)).Where(c => !c.IsDeleted) .OrderBy(o => o.Name).Asc() .TransformUsing(Transformers.AliasToBean <LookupKeyValue>()) .List <LookupKeyValue>()); }
/// <summary> /// Gets the list of category lookup values. /// </summary> /// <returns> /// List of category lookup values /// </returns> /// <exception cref="System.NotImplementedException"></exception> public IEnumerable <LookupKeyValue> GetCategories() { LookupKeyValue lookupAlias = null; Category alias = null; var query = unitOfWork .Session .QueryOver(() => alias) .Where(() => !alias.IsDeleted) .SelectList(select => select .Select(NHibernate.Criterion.Projections.Cast(NHibernateUtil.String, NHibernate.Criterion.Projections.Property <Category>(c => c.Id))).WithAlias(() => lookupAlias.Key) .Select(() => alias.Name).WithAlias(() => lookupAlias.Value)) .TransformUsing(Transformers.AliasToBean <LookupKeyValue>()); query.UnderlyingCriteria.AddOrder(new Order(NHibernate.Criterion.Projections.Property(() => alias.Name), true)); return(query.Future <LookupKeyValue>()); }
public IEnumerable <LookupKeyValue> GetSelectedCategories <TEntity, TEntityCategory>(Guid?entityId) where TEntity : Entity, ICategorized where TEntityCategory : Entity, IEntityCategory { CategoryTree categoryTreeAlias = null; Category categoryAliasa = null; TEntity entityAlias = null; TEntityCategory categoryAlias = default(TEntityCategory); LookupKeyValue valueAlias = null; return(repository.AsQueryOver(() => categoryAliasa) .JoinQueryOver(() => categoryAliasa.CategoryTree, () => categoryTreeAlias) .Where(() => !categoryTreeAlias.IsDeleted && !categoryAliasa.IsDeleted) .WithSubquery.WhereProperty(() => categoryAliasa.Id) .In(QueryOver.Of(() => entityAlias) .JoinQueryOver(() => entityAlias.Categories, () => categoryAlias) .Where(() => entityAlias.Id == entityId && !categoryAlias.IsDeleted) .SelectList(list => list.Select(() => categoryAlias.Category.Id))) .SelectList(l => l .Select(NHibernate.Criterion.Projections.Cast(NHibernateUtil.String, NHibernate.Criterion.Projections.Property(() => categoryAliasa.Id))).WithAlias(() => valueAlias.Key) .Select(() => categoryAliasa.Name).WithAlias(() => valueAlias.Value)) .TransformUsing(Transformers.AliasToBean <LookupKeyValue>()) .Future <LookupKeyValue>()); }