当前位置: 首页>>代码示例>>C#>>正文


C# IQueryable.GroupBy方法代码示例

本文整理汇总了C#中IQueryable.GroupBy方法的典型用法代码示例。如果您正苦于以下问题:C# IQueryable.GroupBy方法的具体用法?C# IQueryable.GroupBy怎么用?C# IQueryable.GroupBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IQueryable的用法示例。


在下文中一共展示了IQueryable.GroupBy方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

        public static ValidatedPromo Create(PromoDetail promo, IQueryable<ProductMappingItem> mappings, List<KeyValuePair<string, string>> basketCriteriaChecks, IQueryable<ProductPromotionMapping> productPromoMappings)
        {
            // Reload the XML into the Integration object, so that we can make use of its validation routines.
            // We also use this for the available times.
            var integrationPromo = Qixol.Promo.Integration.Lib.Export.ExportPromotionDetailsItem.RetrieveFromXml(promo.PromoXml);
            // the Xml only has the TIME for the valid from / to, and then only if the promotion starts/expires on that day.
            // for completeness, reset these to the full datetime (or min/max if not present)
            integrationPromo.ValidFrom = promo.ValidFrom.HasValue ? promo.ValidFrom.Value : DateTime.MinValue;
            integrationPromo.ValidTo = promo.ValidTo.HasValue ? promo.ValidTo.Value : DateTime.MaxValue;
            if (integrationPromo.ValidTo.CompareTo(DateTime.MinValue) == 0)
                integrationPromo.ValidTo = DateTime.MaxValue;

            List<IGrouping<int, ProductPromotionMapping>> requiredQuantities = null;
            List<IGrouping<decimal, ProductPromotionMapping>> requiredSpend = null;
            List<IGrouping<bool, ProductPromotionMapping>> multipleProductRestrictions = null;
            List<IGrouping<string, ProductPromotionMapping>> matchingRestrictions = null;

            if(productPromoMappings != null)
            {
                requiredQuantities = productPromoMappings.GroupBy(gb => gb.RequiredQty).ToList();
                requiredSpend = productPromoMappings.GroupBy(gb => gb.RequiredSpend).ToList();
                multipleProductRestrictions = productPromoMappings.GroupBy(gb => gb.MultipleProductRestrictions).ToList();
                matchingRestrictions = productPromoMappings.GroupBy(gb => gb.MatchingRestrictions).ToList();            
            }

            var returnItem = new ValidatedPromo()
            {
                // Set basic details
                PromotionId = promo.PromoId,
                Title = promo.PromoName,
                PromoType = promo.PromoTypeName,
                Description = string.IsNullOrEmpty(promo.DisplayText) ? promo.PromoName : promo.DisplayText,
                ValidFrom = promo.ValidFrom,
                ValidTo = promo.ValidTo,
                MinimumSpend = promo.MinimumSpend,
                DiscountAmount = promo.DiscountAmount,
                DiscountPercent = promo.DiscountPercent,
                YourReference = promo.YourReference,

                HasMultipleRequiredQty = requiredQuantities != null && requiredQuantities.Count > 1,
                HasMultipleRequiredSpend = requiredSpend != null && requiredSpend.Count > 1,
                HasMultipleMatchingRestrictions = matchingRestrictions != null && matchingRestrictions.Count > 1,
                HasMultipleRequireAdditionalItems = multipleProductRestrictions != null && multipleProductRestrictions.Count > 1,

                RequiredItemQty = (requiredQuantities != null && requiredQuantities.Count == 1) ? requiredQuantities.FirstOrDefault().First().RequiredQty : default(int?),
                RequiredItemSpend = (requiredSpend != null && requiredSpend.Count == 1) ? requiredSpend.FirstOrDefault().First().RequiredSpend : default(decimal?),
                RequireAdditionalItems = (multipleProductRestrictions != null && multipleProductRestrictions.Count == 1) ? multipleProductRestrictions.FirstOrDefault().First().MultipleProductRestrictions : false,
                MatchingRestriction = (matchingRestrictions != null && matchingRestrictions.Count == 1) ? matchingRestrictions.FirstOrDefault().First().MatchingRestrictions : string.Empty,

                // Revalidate the Criteria and Time restrictions for this promo.
                ValidForCriteria = integrationPromo.ValidateUnmatchedCriteria(basketCriteriaChecks),
                ValidForTime = integrationPromo.ValidateForTime(DateTime.UtcNow),

                // Where timebands are specified, return them
                Availability = (integrationPromo.AvailableTimes != null && integrationPromo.AvailableTimes.Count > 0) ?
                                    integrationPromo.AvailableTimes.Select(a => new ValidatedPromoAvailability() { Start = a.StartTime, End = a.EndTime }).ToList()
                                    : null,

            };

            if (mappings != null && productPromoMappings != null)
            {
                // Check to see whether all variants for the product are valid for this promo.
                returnItem.ForAllVariants = mappings.Count() == 1 ? true
                                    : (mappings.Count() == productPromoMappings.Where(ppm => ppm.PromotionId == promo.PromoId).Count());

            }

            return returnItem;
        }
开发者ID:Qixol,项目名称:Qixol.Promo.Nop.Plugin,代码行数:70,代码来源:ValidatedPromotion.cs

示例2: GetRegistrationSummaryAll

 private static IQueryable<RegistrationSummaryReport> GetRegistrationSummaryAll(IQueryable<OrderItems> reportItems)
 {
     var newList = reportItems.GroupBy(x => new {x.ItemId, x.Price})
         .Select(y => new RegistrationSummaryReport()
         {
             ItemId = y.Key.ItemId,
             Price = y.Key.Price, 
             Count = y.Count()  ,
             TotalAmount = y.Sum(x => x.Price)
         }
         );
     return newList;
 }
开发者ID:cfcusaga,项目名称:portal,代码行数:13,代码来源:ReportsController.cs

示例3: PrepareAnalyseModel

 public void PrepareAnalyseModel(List<KeyValuePairViewModel> list, IQueryable<Record> models,
     Expression<Func<IGrouping<int, Record>, dynamic>> seletor)
 {
     var list4 = models.GroupBy(r => r.ChampionId)
            .OrderBy(s => s.Key)
            .Select(seletor);
     foreach (var m in list4)
         list.Add(new KeyValuePairViewModel { Key = m.Key, Value = m.Value });
 }
开发者ID:cjz9032,项目名称:ProjectWithNop,代码行数:9,代码来源:LolController.cs

示例4: GetPackageInfos

        private static IQueryable<PackageInfo> GetPackageInfos(IQueryable<IPackage> query, IPackageRepository repository, bool showPrerelease)
        {
            if (repository is DataServicePackageRepository)
            {
                if (showPrerelease)
                {
                    query = query.Where(p => p.IsAbsoluteLatestVersion);
                }
                else
                {
                    query = query.Where(p => p.IsLatestVersion);
                }

                return query.Cast<DataServicePackage>().Select(p => new PackageInfo
                                                        {
                                                            Id = p.Id,
                                                            Version = p.Version,
                                                            Authors = p.Authors,
                                                            DownloadCount = p.DownloadCount,
                                                            VersionDownloadCount = p.VersionDownloadCount,
                                                            PackageHash = p.PackageHash,
                                                            PackageSize = p.PackageSize,
                                                            Published = p.Published
                                                        });
            }
            else
            {
                query = query.GroupBy(p => p.Id, StringComparer.OrdinalIgnoreCase)
                             .Select(g => g.OrderByDescending(p => p.Version)
                             .First());

                return query.Cast<ZipPackage>().Select(p => new PackageInfo
                                                    {
                                                        Id = p.Id,
                                                        Version = p.Version.ToString(),
                                                        Authors = String.Join(", ", p.Authors),
                                                        DownloadCount = p.DownloadCount,
                                                        VersionDownloadCount = p.VersionDownloadCount,
                                                        PackageHash = p.PackageHash,
                                                        PackageSize = p.PackageSize,
                                                        DownloadUrl = new Uri(p.Source),
                                                        Published = p.Published,
                                                    });
            }
        }
开发者ID:304NotModified,项目名称:NuGetPackageExplorer-1,代码行数:45,代码来源:PackageChooserViewModel.cs

示例5: MapPerson

        /// <summary>
        /// Maps the person.
        /// </summary>
        /// <param name="tableData">The table data.</param>
        /// <param name="selectedColumns">The selected columns.</param>
        public void MapPerson( IQueryable<Row> tableData )
        {
            var lookupContext = new RockContext();
            var groupTypeRoleService = new GroupTypeRoleService( lookupContext );

            // Marital statuses: Married, Single, Separated, etc
            var maritalStatusTypes = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS ), lookupContext ).DefinedValues;

            // Connection statuses: Member, Visitor, Attendee, etc
            var connectionStatusTypes = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS ), lookupContext ).DefinedValues;
            int memberStatusId = connectionStatusTypes.FirstOrDefault( dv => dv.Guid == new Guid( Rock.SystemGuid.DefinedValue.PERSON_CONNECTION_STATUS_MEMBER ) ).Id;
            int visitorStatusId = connectionStatusTypes.FirstOrDefault( dv => dv.Guid == new Guid( Rock.SystemGuid.DefinedValue.PERSON_CONNECTION_STATUS_VISITOR ) ).Id;
            int attendeeStatusId = connectionStatusTypes.FirstOrDefault( dv => dv.Guid == new Guid( Rock.SystemGuid.DefinedValue.PERSON_CONNECTION_STATUS_ATTENDEE ) ).Id;

            // Record statuses/reasons: Active, Inactive, Pending, Deceased, etc
            var recordStatuses = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_RECORD_STATUS ) ).DefinedValues;
            var recordStatusReasons = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_RECORD_STATUS_REASON ), lookupContext ).DefinedValues;

            int recordStatusActiveId = recordStatuses.FirstOrDefault( r => r.Guid == new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE ) ).Id;
            int recordStatusInactiveId = recordStatuses.FirstOrDefault( r => r.Guid == new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE ) ).Id;
            int recordStatusPendingId = recordStatuses.FirstOrDefault( r => r.Guid == new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_PENDING ) ).Id;
            int statusReasonDeceasedId = recordStatusReasons.FirstOrDefault( dv => dv.Guid == new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_REASON_DECEASED ) ).Id;
            int statusReasonNoActivityId = recordStatusReasons.Where( dv => dv.Value == "No Activity" ).Select( dv => dv.Id ).FirstOrDefault();

            // Record type: Person
            int? personRecordTypeId = DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_PERSON ), lookupContext ).Id;

            // Suffix type: Dr., Jr., II, etc
            var suffixTypes = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_SUFFIX ) ).DefinedValues;

            // Title type: Mr., Mrs. Dr., etc
            var titleTypes = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_TITLE ), lookupContext ).DefinedValues;

            // Group roles: Owner, Adult, Child, others
            GroupTypeRole ownerRole = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_OWNER ) );
            int adultRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ).Id;
            int childRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD ) ).Id;
            int inviteeRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_INVITED ) ).Id;
            int invitedByRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_INVITED_BY ) ).Id;
            int canCheckInRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_CAN_CHECK_IN ) ).Id;
            int allowCheckInByRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_ALLOW_CHECK_IN_BY ) ).Id;

            // Group type: Family
            int familyGroupTypeId = new GroupTypeService( lookupContext ).Get( new Guid( Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY ) ).Id;

            // Look up additional Person attributes (existing)
            var personAttributes = new AttributeService( lookupContext ).GetByEntityTypeId( PersonEntityTypeId ).AsNoTracking().ToList();

            // F1 attributes: IndividualId, HouseholdId
            // Core attributes: PreviousChurch, Position, Employer, School
            var previousChurchAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key.Equals( "PreviousChurch", StringComparison.InvariantCultureIgnoreCase ) ) );
            var membershipDateAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key.Equals( "MembershipDate", StringComparison.InvariantCultureIgnoreCase ) ) );
            var firstVisitAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key.Equals( "FirstVisit", StringComparison.InvariantCultureIgnoreCase ) ) );
            var legalNoteAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key.Equals( "LegalNotes", StringComparison.InvariantCultureIgnoreCase ) ) );
            var employerAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key.Equals( "Employer", StringComparison.InvariantCultureIgnoreCase ) ) );
            var positionAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key.Equals( "Position", StringComparison.InvariantCultureIgnoreCase ) ) );
            var schoolAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key.Equals( "School", StringComparison.InvariantCultureIgnoreCase ) ) );

            var familyList = new List<Group>();
            var visitorList = new List<Group>();
            var previousNamesList = new Dictionary<Guid, string>();
            var householdCampusList = new List<string>();

            int completed = 0;
            int totalRows = tableData.Count();
            int percentage = ( totalRows - 1 ) / 100 + 1;
            ReportProgress( 0, string.Format( "Verifying person import ({0:N0} found, {1:N0} already exist).", totalRows, ImportedPeople.Count ) );

            foreach ( var groupedRows in tableData.GroupBy<Row, int?>( r => r["Household_ID"] as int? ) )
            {
                var familyGroup = new Group();
                householdCampusList.Clear();

                foreach ( var row in groupedRows.Where( r => r != null ) )
                {
                    var familyRoleId = FamilyRole.Adult;
                    string currentCampus = string.Empty;
                    int? individualId = row["Individual_ID"] as int?;
                    int? householdId = row["Household_ID"] as int?;
                    var personKeys = GetPersonKeys( individualId, householdId );
                    if ( personKeys == null )
                    {
                        var person = new Person();
                        person.FirstName = row["First_Name"] as string;
                        person.MiddleName = row["Middle_Name"] as string;
                        person.NickName = row["Goes_By"] as string ?? person.FirstName;
                        person.LastName = row["Last_Name"] as string;
                        person.IsDeceased = false;

                        var DOB = row["Date_Of_Birth"] as DateTime?;
                        if ( DOB != null )
                        {
                            var birthDate = (DateTime)DOB;
                            person.BirthDay = birthDate.Day;
                            person.BirthMonth = birthDate.Month;
//.........这里部分代码省略.........
开发者ID:NewSpring,项目名称:Excavator,代码行数:101,代码来源:People.cs

示例6: DataMainPreparatons

        /// <summary>
        /// Сортировка достижений, вывод основной информации по пользователю и переход на вывод рейтинга
        /// </summary>
        /// <param name="ach"></param>
        void DataMainPreparatons(IQueryable<AchieveInfo> ach) 
        {
            TBlInfo.Text = "";
            FillingNP();
            FillingPoints(ach);

            //Сортировка по темам дотижений
            var sortAch = ach.GroupBy(p => p.Theme.Name).
                Select(
                gnew => new 
                {
                    Name=gnew.FirstOrDefault().Theme.Name, 
                    Points=gnew.Sum(c=>c.Points) 
                });
            sortAch = sortAch.OrderByDescending(p => p.Points);
            FillingTextBlock(sortAch);
        }
开发者ID:VladislavBI,项目名称:AchiveNoter,代码行数:21,代码来源:ThemeRatio.xaml.cs

示例7: LastTitlesByFeed

 /// <summary>
 /// Take last n titles from each feed.
 /// </summary>
 /// <param name="query"></param>
 /// <param name="n"></param>
 /// <returns></returns>
 private IEnumerable<String> LastTitlesByFeed(IQueryable<NewsFile> query, int n)
 {
     var list = query.GroupBy(x => x.FeedId).Select(x => x.OrderByDescending(y => y.PubDate).Take(n).Select(b => b.Title)).SelectMany(x => x);
     return list;
 }
开发者ID:snuderl,项目名称:MobilniPortalNovic,代码行数:11,代码来源:ParsingService.cs

示例8: MapPerson

        /// <summary>
        /// Maps the person.
        /// </summary>
        /// <param name="tableData">The table data.</param>
        /// <param name="selectedColumns">The selected columns.</param>
        private void MapPerson( IQueryable<Row> tableData, List<string> selectedColumns = null )
        {
            var groupTypeRoleService = new GroupTypeRoleService();
            var attributeService = new AttributeService();
            var dvService = new DefinedValueService();
            var familyList = new List<Group>();

            // Marital statuses: Married, Single, Separated, etc
            List<DefinedValue> maritalStatusTypes = dvService.Queryable()
                .Where( dv => dv.DefinedType.Guid == new Guid( Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS ) ).ToList();

            // Connection statuses: Member, Visitor, Attendee, etc
            List<DefinedValue> connectionStatusTypes = dvService.Queryable()
                .Where( dv => dv.DefinedType.Guid == new Guid( Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS ) ).ToList();

            // Record status reasons: No Activity, Moved, Deceased, etc
            List<DefinedValue> recordStatusReasons = dvService.Queryable()
                .Where( dv => dv.DefinedType.Guid == new Guid( Rock.SystemGuid.DefinedType.PERSON_RECORD_STATUS_REASON ) ).ToList();

            // Record statuses: Active, Inactive, Pending
            int? statusActiveId = dvService.Get( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE ) ).Id;
            int? statusInactiveId = dvService.Get( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE ) ).Id;
            int? statusPendingId = dvService.Get( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_PENDING ) ).Id;

            // Record type: Person
            int? personRecordTypeId = dvService.Get( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_PERSON ) ).Id;

            // Suffix type: Dr., Jr., II, etc
            List<DefinedValue> suffixTypes = dvService.Queryable()
                .Where( dv => dv.DefinedType.Guid == new Guid( Rock.SystemGuid.DefinedType.PERSON_SUFFIX ) ).ToList();

            // Title type: Mr., Mrs. Dr., etc
            List<DefinedValue> titleTypes = dvService.Queryable()
                .Where( dv => dv.DefinedType.Guid == new Guid( Rock.SystemGuid.DefinedType.PERSON_TITLE ) ).ToList();

            // Note type: Comment
            int noteCommentTypeId = new NoteTypeService().Get( new Guid( "7E53487C-D650-4D85-97E2-350EB8332763" ) ).Id;

            // Group roles: Adult, Child, others
            int adultRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ).Id;
            int childRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD ) ).Id;

            // Group type: Family
            int familyGroupTypeId = GroupTypeCache.GetFamilyGroupType().Id;

            // Look up additional Person attributes (existing)
            var personAttributes = attributeService.GetByEntityTypeId( PersonEntityTypeId ).ToList();

            // Cached F1 attributes: IndividualId, HouseholdId, PreviousChurch, Position, Employer, School
            var individualIdAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "F1IndividualId" ) );
            var householdIdAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "F1HouseholdId" ) );
            var previousChurchAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "PreviousChurch" ) );
            var employerAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "Employer" ) );
            var positionAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "Position" ) );
            var firstVisitAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "FirstVisit" ) );
            var schoolAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "School" ) );
            var membershipDateAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "MembershipDate" ) );

            int completed = 0;
            int totalRows = tableData.Count();
            int percentage = ( totalRows - 1 ) / 100 + 1;
            ReportProgress( 0, string.Format( "Checking person import ({0:N0} found, {1:N0} already exist).", totalRows, ImportedPeople.Count() ) );

            foreach ( var groupedRows in tableData.GroupBy<Row, int?>( r => r["Household_ID"] as int? ) )
            {
                var familyGroup = new Group();
                var householdCampusList = new List<string>();

                foreach ( var row in groupedRows )
                {
                    int? individualId = row["Individual_ID"] as int?;
                    int? householdId = row["Household_ID"] as int?;
                    if ( GetPersonId( individualId, householdId ) == null )
                    {
                        var person = new Person();
                        person.FirstName = row["First_Name"] as string;
                        person.MiddleName = row["Middle_Name"] as string;
                        person.NickName = row["Goes_By"] as string ?? person.FirstName;
                        person.LastName = row["Last_Name"] as string;
                        person.BirthDate = row["Date_Of_Birth"] as DateTime?;
                        person.CreatedByPersonAliasId = ImportPersonAlias.Id;
                        person.RecordTypeValueId = personRecordTypeId;
                        int groupRoleId = adultRoleId;

                        var gender = row["Gender"] as string;
                        if ( gender != null )
                        {
                            person.Gender = (Gender)Enum.Parse( typeof( Gender ), gender );
                        }

                        string prefix = row["Prefix"] as string;
                        if ( prefix != null )
                        {
                            prefix = prefix.RemoveSpecialCharacters().Trim();
                            person.TitleValueId = titleTypes.Where( s => prefix == s.Name.RemoveSpecialCharacters() )
//.........这里部分代码省略.........
开发者ID:secc,项目名称:Excavator,代码行数:101,代码来源:People.cs

示例9: InitializeTypesFilter

        private void InitializeTypesFilter(IQueryable<Product> entities)
        {
            if (ViewModel.GroupsFilter == null)
            {
                return;
            }

            IEnumerable<Group> allGroups = GroupRepository.All();

            List<GenericFilterModel<string>> groups =
                entities.GroupBy(item => item.GroupName)
                        .ToList()
                        .Select(
                            g =>
                            new GenericFilterModel<string>
                                {
                                    Value = g.Key,
                                    Name = allGroups.Single(obj => obj.Name == g.Key).DisplayName,
                                    ProductsCount = g.Count()
                                })
                        .ToList();
            foreach (var item in groups)
            {
                item.IsSelected = ViewModel.GroupsFilter.GroupList.Contains(item.Value.ToLower());
            }

            ViewModel.Groups = groups;
        }
开发者ID:vslotylo,项目名称:3e,代码行数:28,代码来源:ListControllerBase.cs

示例10: InitializeProducerFilter

        private void InitializeProducerFilter(IQueryable<Product> entities)
        {
            if (ViewModel.ProducersFilter == null)
            {
                return;
            }

            List<GenericFilterModel<string>> producers =
                entities.GroupBy(p => p.Producer)
                        .Select(
                            g =>
                            new GenericFilterModel<string>
                                {
                                    Value = g.Key.Name,
                                    Name = g.Key.DisplayName,
                                    ProductsCount = g.Count()
                                })
                        .ToList();
            ViewModel.ProducersFilter.ProducersList =
                producers.Select(obj => obj.Value.ToLower())
                         .Where(p => ViewModel.ProducersFilter.ParsedProducers.Contains(p.ToLower()))
                         .ToList();
            foreach (var item in producers)
            {
                item.IsSelected = ViewModel.ProducersFilter.ProducersList.Contains(item.Value.ToLower());
            }

            ViewModel.Producers = producers;
        }
开发者ID:vslotylo,项目名称:3e,代码行数:29,代码来源:ListControllerBase.cs

示例11: MapPerson

        /// <summary>
        /// Maps the person.
        /// </summary>
        /// <param name="tableData">The table data.</param>
        /// <param name="selectedColumns">The selected columns.</param>
        private void MapPerson( IQueryable<Row> tableData, List<string> selectedColumns = null )
        {
            var lookupContext = new RockContext();
            var groupTypeRoleService = new GroupTypeRoleService( lookupContext );
            var dvService = new DefinedValueService( lookupContext );

            var schoolList = new List<DefinedValue>();
            var newSchool = new DefinedValue();
            var existingSchoolLookUp = dvService.Queryable()
                .Where( dv => dv.DefinedTypeId == 34 ).ToList();

            // Marital statuses: Married, Single, Separated, etc
            var maritalStatusTypes = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS ), lookupContext ).DefinedValues;

            // Connection statuses: Member, Visitor, Attendee, etc
            var connectionStatusTypes = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS ), lookupContext ).DefinedValues;

            // Record status reasons: No Activity, Moved, Deceased, etc
            var recordStatusReasons = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_RECORD_STATUS_REASON ), lookupContext ).DefinedValues;

            // Record statuses: Active, Inactive, Pending
            int? recordStatusActiveId = DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE ), lookupContext ).Id;
            int? recordStatusInactiveId = DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE ), lookupContext ).Id;
            int? recordStatusPendingId = DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_PENDING ), lookupContext ).Id;

            // Record type: Person
            int? personRecordTypeId = DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_PERSON ), lookupContext ).Id;

            // Suffix type: Dr., Jr., II, etc
            var suffixTypes = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_SUFFIX ) ).DefinedValues;

            // Title type: Mr., Mrs. Dr., etc
            var titleTypes = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_TITLE ), lookupContext ).DefinedValues;

            // Note type: Comment
            int noteCommentTypeId = new NoteTypeService( lookupContext ).Get( new Guid( "7E53487C-D650-4D85-97E2-350EB8332763" ) ).Id;

            // Group roles: Owner, Adult, Child, others
            GroupTypeRole ownerRole = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_OWNER ) );
            int adultRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ).Id;
            int childRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD ) ).Id;
            int inviteeRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_INVITED ) ).Id;
            int invitedByRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_INVITED_BY ) ).Id;
            int canCheckInRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_CAN_CHECK_IN ) ).Id;
            int allowCheckInByRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_ALLOW_CHECK_IN_BY ) ).Id;

            // Group type: Family
            int familyGroupTypeId = new GroupTypeService( lookupContext ).Get( new Guid( Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY ) ).Id;

            // Look up additional Person attributes (existing)
            var personAttributes = new AttributeService( lookupContext ).GetByEntityTypeId( PersonEntityTypeId ).ToList();

            // Cached F1 attributes: IndividualId, HouseholdId
            // Core attributes: PreviousChurch, Position, Employer, School
            var individualIdAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "F1IndividualId" ) );
            var householdIdAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "F1HouseholdId" ) );
            var previousChurchAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "PreviousChurch" ) );
            var employerAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "Employer" ) );
            var positionAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "Position" ) );
            var firstVisitAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "FirstVisit" ) );
            var schoolAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "School" ) );
            var membershipDateAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "MembershipDate" ) );

            var familyList = new List<Group>();
            var visitorList = new List<Group>();

            int completed = 0;
            int totalRows = tableData.Count();
            int percentage = ( totalRows - 1 ) / 100 + 1;
            ReportProgress( 0, string.Format( "Verifying person import ({0:N0} found, {1:N0} already exist).", totalRows, ImportedPeople.Count() ) );

            foreach ( var groupedRows in tableData.GroupBy<Row, int?>( r => r["Household_ID"] as int? ) )
            {
                var familyGroup = new Group();
                var householdCampusList = new List<string>();

                foreach ( var row in groupedRows )
                {
                    bool isFamilyRelationship = true;
                    string currentCampus = string.Empty;
                    int? individualId = row["Individual_ID"] as int?;
                    int? householdId = row["Household_ID"] as int?;
                    if ( GetPersonAliasId( individualId, householdId ) == null )
                    {
                        var person = new Person();
                        person.FirstName = row["First_Name"] as string;
                        person.MiddleName = row["Middle_Name"] as string;
                        person.NickName = row["Goes_By"] as string ?? person.FirstName;
                        person.LastName = row["Last_Name"] as string;
                        person.BirthDate = row["Date_Of_Birth"] as DateTime?;
                        person.CreatedByPersonAliasId = ImportPersonAlias.Id;
                        person.RecordTypeValueId = personRecordTypeId;
                        person.ForeignId = individualId.ToString();
                        int groupRoleId = adultRoleId;

//.........这里部分代码省略.........
开发者ID:CrossroadsChristian,项目名称:Excavator,代码行数:101,代码来源:People.cs

示例12: GetShopCategoryStatistic

 public IQueryable<ShopCategoryWithShopStatistic> GetShopCategoryStatistic(IQueryable<V_ShopForList> shopEntity)
 {
     return shopEntity.GroupBy(r => new { r.CategoryId, r.Category })
     .Select(r => new ShopCategoryWithShopStatistic() { CategoryId = r.Key.CategoryId, CategoryValue = r.Key.Category, CoverShopsCount = r.Count() })
     .OrderBy(r => r.CategoryId);
 }
开发者ID:jingwang109,项目名称:zsfproject,代码行数:6,代码来源:ShopModel.cs

示例13: ApplyExpressions

        public IQueryable ApplyExpressions(IQueryable queryable)
        {
            if (queryable.ElementType != OfType.Type)
                queryable = queryable.OfType(OfType.Type);

            queryable = queryable.Where(FilterExpression);

            if (GroupByExpression == null)
            {
                // OrderBy is applied BEFORE select if GroupBy has not been specified.
                queryable = ApplyOrderByExpression(queryable);
            }
            else
                queryable = queryable.GroupBy(GroupByExpression);

            if (SelectExpression != null)
            {
                queryable = queryable.Select(SelectExpression);

                // OrderBy is applied AFTER select if GroupBy has been specified.
                if (GroupByExpression != null)
                    queryable = ApplyOrderByExpression(queryable);
            }
            else if (GroupByExpression != null)
            {
                throw new PomonaExpressionSyntaxException(
                    "Query error: $groupby has to be combined with a $select query parameter.");
            }

            return queryable;
        }
开发者ID:Pomona,项目名称:Pomona,代码行数:31,代码来源:PomonaQuery.cs


注:本文中的IQueryable.GroupBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。