/// <summary> /// Retrieves a list of groups matching the criteria specified via method parameters. /// </summary> /// <param name="category">Category name.</param> /// <param name="categoryId">Category Id</param> /// <param name="pageNumber">Page number.</param> /// <param name="pageSize">Page size.</param> /// <param name="recordCount">Record count.</param> /// <returns>List of groups.</returns> public List<MonoSoftware.MonoX.Repositories.SnGroupDTO> GetPopularGroups(string category, Guid categoryId, int pageNumber, int pageSize, out int recordCount) { RelationPredicateBucket filter = new RelationPredicateBucket(); //introduced to filter out groups by languages and applications filter.Relations.Add(SnGroupEntity.Relations.SnGroupCategoryEntityUsingGroupCategoryId, JoinHint.Left); //Note: MonoX supports the multi application environment so general filter for all DB access calls should contain the application id filter filter.PredicateExpression.Add(SnGroupCategoryFields.ApplicationId == MonoSoftware.MonoX.Repositories.MembershipRepository.GetInstance().GetApplicationId()); //Note: MonoX in supports the multi language environment so general filter for all DB access calls should contain the language id filter filter.PredicateExpression.Add(SnGroupCategoryFields.LanguageId == LocalizationUtility.GetCurrentLanguageId()); //Filter groups by category if (categoryId != Guid.Empty) { filter.PredicateExpression.Add(SnGroupFields.GroupCategoryId == categoryId); } if (!String.IsNullOrEmpty(category)) { filter.PredicateExpression.Add(SnGroupCategoryFields.Slug == category); } IPrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.SnGroupEntity); prefetch.Add(SnGroupEntity.PrefetchPathSnGroupCategory); //Fetch a record from the members table only for the current user so his status could be read Guid uid = SecurityUtility.GetUserId(); if (!Guid.Empty.Equals(uid)) { PredicateExpression memberFilter = new PredicateExpression(SnGroupMemberFields.UserId == uid); prefetch.Add(SnGroupEntity.PrefetchPathSnGroupMembers, 1, memberFilter); } #region Popular groups sorter const string memberCountField = "MemberCountField"; const string memberCountTableName = "MemberCountTable"; EntityFields2 memberFields = new EntityFields2(2); memberFields.DefineField(SnGroupMemberFields.GroupId, 0); memberFields.DefineField(SnGroupMemberFields.Id, 1, memberCountField, AggregateFunction.Count); DerivedTableDefinition memberCountTable = new DerivedTableDefinition(memberFields, memberCountTableName, null, new GroupByCollection(memberFields[0])); IDynamicRelation memberCountRelation = new DynamicRelation(memberCountTable, JoinHint.Right, MonoSoftware.MonoX.DAL.EntityType.SnGroupEntity, String.Empty, SnGroupMemberFields.GroupId.SetObjectAlias(memberCountTable.Alias) == SnGroupFields.Id); filter.Relations.Add(memberCountRelation); ISortExpression sorter = new SortExpression(new SortClause(new EntityField2(memberCountField, null).SetObjectAlias(memberCountTableName), null, SortOperator.Descending)); #endregion EntityCollection<SnGroupEntity> groups = new EntityCollection<SnGroupEntity>(); //Fetch the group collection FetchEntityCollection(groups, filter, 0, sorter, prefetch, pageNumber, pageSize); //Fetch the group total count used by paging recordCount = GetDbCount(groups, filter); //Transfer group entities to the DTO List<MonoSoftware.MonoX.Repositories.SnGroupDTO> toReturn = groups.Select(group => new MonoSoftware.MonoX.Repositories.SnGroupDTO(group)).ToList<MonoSoftware.MonoX.Repositories.SnGroupDTO>(); return toReturn; }
/// <summary>Initializes a new instance of the <see cref="DynamicRelation"/> class.</summary> /// <param name="leftOperand">The left operand which is a field.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperand">The right operand which is a derived table.</param> /// <param name="aliasLeftOperand">The alias of the left operand. If you don't want to / need to alias the left operand (only alias if you have to), specify string.Empty.</param> /// <param name="onClause">The on clause for the join.</param> public DynamicRelation(IEntityFieldCore leftOperand, JoinHint joinType, DerivedTableDefinition rightOperand, string aliasLeftOperand, IPredicate onClause) { this.InitClass(joinType, aliasLeftOperand, string.Empty, onClause, leftOperand, rightOperand); }
/// <summary>Initializes a new instance of the <see cref="DynamicRelation"/> class.</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperand">The right operand which is an entity type.</param> /// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param> /// <param name="onClause">The on clause for the join.</param> public DynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, AdventureWorks.Dal.Adapter.v42.EntityType rightOperand, string aliasRightOperand, IPredicate onClause) { this.InitClass(joinType, string.Empty, aliasRightOperand, onClause, leftOperand, GeneralEntityFactory.Create(rightOperand)); }
/// <summary>Creates a new dynamic relation instance</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperand">The right operand.</param> /// <param name="onClause">The on clause for the join.</param> /// <returns>ready to use dynamic relation</returns> public override IDynamicRelation CreateDynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, DerivedTableDefinition rightOperand, IPredicate onClause) { return new DynamicRelation(leftOperand, joinType, rightOperand, onClause); }
/// <summary>Initializes a new instance of the <see cref="DynamicRelation"/> class.</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperand">The right operand which is an entity type.</param> /// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param> /// <param name="onClause">The on clause for the join.</param> public DynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, AdventureWorks.Dal.Adapter.v41.EntityType rightOperand, string aliasRightOperand, IPredicate onClause) { this.InitClass(joinType, string.Empty, aliasRightOperand, onClause, leftOperand, GeneralEntityFactory.Create(rightOperand)); }
/// <summary>Initializes a new instance of the <see cref="DynamicRelation"/> class.</summary> /// <param name="leftOperand">The left operand, which can only be a derived table definition. No join will take place. </param> /// <remarks>If a DynamicRelation is created with this CTor, it has to be the only one. It will be ignored if there are more /// relations in the relation collection.</remarks> public DynamicRelation(DerivedTableDefinition leftOperand) { this.InitClass(JoinHint.None, string.Empty, string.Empty, null, leftOperand, null); }
/// <summary>Initializes a new instance of the <see cref="DynamicRelation"/> class.</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperand">The right operand which is an entity type.</param> /// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param> /// <param name="onClause">The on clause for the join.</param> public DynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, ProductSearchEngine.EntityType rightOperand, string aliasRightOperand, IPredicate onClause) { this.InitClass(joinType, string.Empty, aliasRightOperand, onClause, leftOperand, GeneralEntityFactory.Create(rightOperand)); }
/// <summary>Initializes a new instance of the <see cref="DynamicRelation"/> class.</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperand">The right operand which is an entity type.</param> /// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param> /// <param name="onClause">The on clause for the join.</param> public DynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, silverspun.RGBDiff.Dal.EntityType rightOperand, string aliasRightOperand, IPredicate onClause) { base.InitClass(joinType, string.Empty, aliasRightOperand, onClause, leftOperand, GeneralEntityFactory.Create(rightOperand)); }
/// <summary>Initializes a new instance of the <see cref="DynamicRelation"/> class.</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperand">The right operand.</param> /// <param name="onClause">The on clause for the join.</param> public DynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, DerivedTableDefinition rightOperand, IPredicate onClause) { this.InitClass(joinType, string.Empty, string.Empty, onClause, leftOperand, rightOperand); }
/// <summary>Creates a new dynamic relation instance</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperand">The right operand.</param> /// <param name="aliasLeftOperand">The alias of the left operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param> /// <param name="onClause">The on clause for the join.</param> /// <returns>ready to use dynamic relation</returns> public override IDynamicRelation CreateDynamicRelation(IEntityFieldCore leftOperand, JoinHint joinType, DerivedTableDefinition rightOperand, string aliasLeftOperand, IPredicate onClause) { return(new DynamicRelation(leftOperand, joinType, rightOperand, aliasLeftOperand, onClause)); }
/// <summary>Creates a new dynamic relation instance</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperandEntityName">Name of the entity, which is used as the right operand.</param> /// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param> /// <param name="onClause">The on clause for the join.</param> /// <returns>ready to use dynamic relation</returns> public override IDynamicRelation CreateDynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, string rightOperandEntityName, string aliasRightOperand, IPredicate onClause) { return(new DynamicRelation(leftOperand, joinType, (Northwind.Data.EntityType)Enum.Parse(typeof(Northwind.Data.EntityType), rightOperandEntityName, false), aliasRightOperand, onClause)); }
/// <summary>Creates a new dynamic relation instance</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperand">The right operand.</param> /// <param name="onClause">The on clause for the join.</param> /// <returns>ready to use dynamic relation</returns> public override IDynamicRelation CreateDynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, DerivedTableDefinition rightOperand, IPredicate onClause) { return(new DynamicRelation(leftOperand, joinType, rightOperand, onClause)); }
/// <summary>Creates a new dynamic relation instance</summary> /// <param name="leftOperand">The left operand.</param> /// <returns>ready to use dynamic relation</returns> public override IDynamicRelation CreateDynamicRelation(DerivedTableDefinition leftOperand) { return(new DynamicRelation(leftOperand)); }
/// <inheritdoc/> public override IDynamicRelation CreateDynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, string rightOperandEntityName, string aliasRightOperand, IPredicate onClause) { return(new DynamicRelation(leftOperand, joinType, (SD.LLBLGen.Pro.Examples.Auditing.EntityType)Enum.Parse(typeof(SD.LLBLGen.Pro.Examples.Auditing.EntityType), rightOperandEntityName, false), aliasRightOperand, onClause)); }
/// <summary>Initializes a new instance of the <see cref="DynamicRelation"/> class.</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperand">The right operand which is an entity type.</param> /// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param> /// <param name="onClause">The on clause for the join.</param> public DynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, Kalibrasi.Data.EntityType rightOperand, string aliasRightOperand, IPredicate onClause) { base.InitClass(joinType, string.Empty, aliasRightOperand, onClause, leftOperand, GeneralEntityFactory.Create(rightOperand)); }
/// <summary>Initializes a new instance of the <see cref="DynamicRelation"/> class.</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperand">The right operand which is an entity type.</param> /// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param> /// <param name="onClause">The on clause for the join.</param> public DynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, TVJunkie.DatabaseAccessLayer.EntityType rightOperand, string aliasRightOperand, IPredicate onClause) { this.InitClass(joinType, string.Empty, aliasRightOperand, onClause, leftOperand, GeneralEntityFactory.Create(rightOperand)); }
/// <summary>Initializes a new instance of the <see cref="DynamicRelation"/> class.</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperand">The right operand which is an entity type.</param> /// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param> /// <param name="onClause">The on clause for the join.</param> public DynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, Northwind.Data.EntityType rightOperand, string aliasRightOperand, IPredicate onClause) { this.InitClass(joinType, string.Empty, aliasRightOperand, onClause, leftOperand, GeneralEntityFactory.Create(rightOperand)); }
/// <summary>Creates a new dynamic relation instance</summary> /// <param name="leftOperand">The left operand.</param> /// <returns>ready to use dynamic relation</returns> public override IDynamicRelation CreateDynamicRelation(DerivedTableDefinition leftOperand) { return new DynamicRelation(leftOperand); }
/// <summary>Initializes a new instance of the <see cref="DynamicRelation"/> class.</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperand">The right operand which is an entity type.</param> /// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param> /// <param name="onClause">The on clause for the join.</param> public DynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, MonoSoftware.MonoX.DAL.EntityType rightOperand, string aliasRightOperand, IPredicate onClause) { this.InitClass(joinType, string.Empty, aliasRightOperand, onClause, leftOperand, GeneralEntityFactory.Create(rightOperand)); }
/// <summary>Creates a new dynamic relation instance</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperandEntityName">Name of the entity, which is used as the right operand.</param> /// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param> /// <param name="onClause">The on clause for the join.</param> /// <returns>ready to use dynamic relation</returns> public override IDynamicRelation CreateDynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, string rightOperandEntityName, string aliasRightOperand, IPredicate onClause) { return new DynamicRelation(leftOperand, joinType, (Auction.Entities.EntityType)Enum.Parse(typeof(Auction.Entities.EntityType), rightOperandEntityName, false), aliasRightOperand, onClause); }
/// <summary>Initializes a new instance of the <see cref="DynamicRelation"/> class.</summary> /// <param name="leftOperand">The left operand.</param> /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param> /// <param name="rightOperand">The right operand which is an entity type.</param> /// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param> /// <param name="onClause">The on clause for the join.</param> public DynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, SD.LLBLGen.Pro.Examples.Auditing.EntityType rightOperand, string aliasRightOperand, IPredicate onClause) { this.InitClass(joinType, string.Empty, aliasRightOperand, onClause, leftOperand, GeneralEntityFactory.Create(rightOperand)); }