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


C# IGrouping.Where方法代码示例

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


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

示例1: HeroStatistic

 public HeroStatistic(IGrouping<string, Match> group)
 {
     Hero = group.Key;
     Matches = group.Count();
     Wins = group.Where(m => m.Win).Count();
     Losses = group.Where(m => m.Win == false).Count();
     WinRatio = Convert.ToInt32((double)Wins / (double)Matches * 100);
     TimePlayed = group.Select(g => g.Duration).Aggregate(TimeSpan.Zero, (subtotal, t) => subtotal.Add(t));
 }
开发者ID:Gmoneydrums,项目名称:StormVault,代码行数:9,代码来源:HeroStatistic.cs

示例2: TweetGroup

 public TweetGroup(IGrouping<ITweet, ITweet> tg)
 {
     GroupStatusIDs = tg.Select(g => g.StatusID).ToList();
     CreatedOn = DateTime.Now;
     StatusID = tg.Key.StatusID;
     TweetText = tg.Key.TweetText;
     CreatedAt = tg.Key.CreatedAt;
     TweetTime = tg.Key.TweetTime;
     RetweetCount = tg.Key.RetweetCount + tg.Where(t => t.User.ScreenName != tg.Key.User.ScreenName).Sum(t => t.RetweetCount);
     LinkRetweetCount = tg.SelectMany(x => x.Links).Sum(x => x.UrlTweetCount);
     LinkFacebookShareCount = tg.SelectMany(x => x.Links).Sum(x => x.UrlFacebookShareCount);
     User = tg.Key.User;
     Links = tg.Where(t => t.User.ScreenName != tg.Key.User.ScreenName).SelectMany(x => x.Links).ToList();
     Links.AddRange(tg.Key.Links.Where(l => l.Image != null || l.Video != null));
 }
开发者ID:postworthy,项目名称:postworthy,代码行数:15,代码来源:TweetGroup.cs

示例3: CollectUpsertOperations

 private IEnumerable<Action<ISimpleDbService>> CollectUpsertOperations(IGrouping<ISimpleDbDomain, ISessionItem> domainSet)
 {
     var putBatches = domainSet.Where(i => i.State == SessionItemState.Create || i.State == SessionItemState.Update).GroupsOf(25);
     foreach (var putBatch in putBatches)
     {
         yield return service => service.BatchPutAttributes(domainSet.Key.Name, putBatch.Cast<object>().ToArray());
     }
 }
开发者ID:rsparkyc,项目名称:SimpleDb.Net,代码行数:8,代码来源:SimpleDbSession.cs

示例4: CollectDeleteOperations

 private IEnumerable<Action<ISimpleDbService>> CollectDeleteOperations(IGrouping<ISimpleDbDomain, ISessionItem> domainSet)
 {
     var deleteBatches = domainSet.Where(i => i.State == SessionItemState.Delete).GroupsOf(25);
     foreach (var deleteBatch in deleteBatches)
     {
         yield return service => service.BatchDeleteAttributes(domainSet.Key.Name, deleteBatch.Cast<object>().ToArray());
     }
 }
开发者ID:rsparkyc,项目名称:SimpleDb.Net,代码行数:8,代码来源:SimpleDbSession.cs

示例5: PerformJobs

        private void PerformJobs(IGrouping<ISynchronizeInvoke, UpdateUIJob> jobGroup)
        {
            var firstJob = jobGroup.First();

            jobGroup.Where(job => job != firstJob).ForEach(firstJob.MergeWith);

            firstJob.Perform();
        }
开发者ID:subTee,项目名称:Deviare2,代码行数:8,代码来源:UIUpdater.cs

示例6: BuildCustomer

        private Customer BuildCustomer(IGrouping<int, Bet> bets)
        {
            Customer customer = new Customer();

            customer.Id = bets.Key;
            customer.TotalNumberOfBets = bets.Count();
            customer.NumberOfSettledBets = bets.Count(bet => bet.BetStatus == BetStatus.Settled);
            customer.NumberOfUnsettledBets = bets.Count(bet => bet.BetStatus == BetStatus.Unsettled);
            customer.NumberOfWinningBets = bets.Count(bet => bet.BetStatus == BetStatus.Settled && bet.Win > 0);
            customer.TotalSettledStake = bets.Where(bet => bet.BetStatus == BetStatus.Settled).Sum(bet => bet.Stake);
            customer.TotalSettledWin = bets.Where(bet => bet.BetStatus == BetStatus.Settled).Sum(bet => bet.Win);
            customer.TotalUnsettledStake = bets.Where(bet => bet.BetStatus == BetStatus.Unsettled).Sum(bet => bet.Stake);
            customer.TotalUnsettledWin = bets.Where(bet => bet.BetStatus == BetStatus.Unsettled).Sum(bet => bet.Win);

            _customerRiskCalculator.DetermineCustomerRisk(customer);

            return customer;
        }
开发者ID:patrickkferguson,项目名称:bet-risk,代码行数:18,代码来源:RiskService.cs

示例7: Reduce

        private static IEnumerable<SecurityAttributeDescriptor> Reduce(IGrouping<string, SecurityAttributeDescriptor> g)
        {
            var overrides = g.Where(d => d.Override != SecurityAttributeOverride.None).ToList();
            switch (overrides.Count)
            {
                case 0:
                    yield return g.OrderByDescending(d => d.AttributeType).First();
                    break;

                case 1:
                    var @override = overrides[0];
                    if (@override.Override == SecurityAttributeOverride.Add)
                        yield return new SecurityAttributeDescriptor(@override.AttributeType, @override.Target, @override.Signature);
                    break;

                default:
                    throw new ArgumentException(string.Format("Conflicting overrides: {0}", overrides));
            }
        }
开发者ID:tigerhu67,项目名称:monobuildtools,代码行数:19,代码来源:SecurityAttributeDescriptorOperations.cs

示例8: Run

        private async Task Run(IGrouping<string, Series> group, CancellationToken cancellationToken)
        {
            var tvdbId = group.Key;

            var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, tvdbId);

            var episodeFiles = Directory.EnumerateFiles(seriesDataPath, "*.xml", SearchOption.TopDirectoryOnly)
                .Select(Path.GetFileNameWithoutExtension)
                .Where(i => i.StartsWith("episode-", StringComparison.OrdinalIgnoreCase))
                .ToList();

            var episodeLookup = episodeFiles
                .Select(i =>
                {
                    var parts = i.Split('-');

                    if (parts.Length == 3)
                    {
                        int seasonNumber;

                        if (int.TryParse(parts[1], NumberStyles.Integer, UsCulture, out seasonNumber))
                        {
                            int episodeNumber;

                            if (int.TryParse(parts[2], NumberStyles.Integer, UsCulture, out episodeNumber))
                            {
                                return new Tuple<int, int>(seasonNumber, episodeNumber);
                            }
                        }
                    }

                    return new Tuple<int, int>(-1, -1);
                })
                .Where(i => i.Item1 != -1 && i.Item2 != -1)
                .ToList();

            var hasBadData = HasInvalidContent(group);

            var anySeasonsRemoved = await RemoveObsoleteOrMissingSeasons(group, episodeLookup, hasBadData)
                .ConfigureAwait(false);

            var anyEpisodesRemoved = await RemoveObsoleteOrMissingEpisodes(group, episodeLookup, hasBadData)
                .ConfigureAwait(false);

            var hasNewEpisodes = false;
            var hasNewSeasons = false;

            foreach (var series in group.Where(s => s.ContainsEpisodesWithoutSeasonFolders))
            {
                hasNewSeasons = await AddDummySeasonFolders(series, cancellationToken).ConfigureAwait(false);
            }

            if (!hasBadData && _config.Configuration.EnableInternetProviders)
            {
                var seriesConfig = _config.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, typeof(Series).Name, StringComparison.OrdinalIgnoreCase));

                if (seriesConfig == null || !seriesConfig.DisabledMetadataFetchers.Contains(TvdbSeriesProvider.Current.Name, StringComparer.OrdinalIgnoreCase))
                {
                    hasNewEpisodes = await AddMissingEpisodes(group.ToList(), seriesDataPath, episodeLookup, cancellationToken)
                        .ConfigureAwait(false);
                }
            }

            if (hasNewSeasons || hasNewEpisodes || anySeasonsRemoved || anyEpisodesRemoved)
            {
                foreach (var series in group)
                {
                    await series.RefreshMetadata(new MetadataRefreshOptions
                    {
                    }, cancellationToken).ConfigureAwait(false);

                    await series.ValidateChildren(new Progress<double>(), cancellationToken, new MetadataRefreshOptions(), true)
                        .ConfigureAwait(false);
                }
            }
        }
开发者ID:Sile626,项目名称:MediaBrowser,代码行数:76,代码来源:MissingEpisodeProvider.cs

示例9: GetFirstCar

 private static Car GetFirstCar(Tournament tournament, IGrouping<string, CarResult> classGroup)
 {
     var maxPoints = classGroup.Max(r => r.Points);
     var carsWithMaxPoints = classGroup.Where(r => r.Points == maxPoints).ToArray();
     if (carsWithMaxPoints.Count() == 1)
     {
         return carsWithMaxPoints.First().Car;
     }
     var tiebreakWinner = TiebreakWinner(tournament, classGroup);
     if (tiebreakWinner == null)
     {
         return null;
     }
     return tiebreakWinner;
 }
开发者ID:matt-bartling,项目名称:pinewood-derby-manager,代码行数:15,代码来源:TournamentExtensions.cs

示例10: SumOfOT

 private decimal SumOfOT(IGrouping<int, AttendanceResult> group, string id)
 {
     List<AttendanceResult> items = group.Where(sar => !string.IsNullOrEmpty(id) && id == sar.Category).ToList();
     if (items != null && items.Count > 0)
     {
         return items.Sum(it => AttendanceRules.Current.GetDuarationFrom(it.Present, true).Value);
     }
     return 0;
 }
开发者ID:chendeben,项目名称:508-Attendance,代码行数:9,代码来源:FrmShiftResultStatistics.cs

示例11: ExportMonth

        private void ExportMonth(IGrouping<int, DAL.EF.AccountListing> month, ExcelWorksheet ws)
        {
            decimal totalMonth = 0;
            var collWeeks = this.GetMonthWeeks(this.Year, month.Key);
            foreach (var week in collWeeks)
            {
                var weekAccounts = month.Where(l => l.ACT_Date >= week.WeekStart && l.ACT_Date <= week.WeekEnd).ToList().GroupBy(l => l.ACT_Date);
                totalMonth += this.ExportWeek(week, weekAccounts);
            }

            // agrego las tablas a excel
            this.InsertWeeks(ref ws, collWeeks);

            // indico que la hoja tiene datos y seteo el total mes
            ws.Cells["H3"].Value = totalMonth;
            ws.Cells["H3"].Style.Numberformat.Format = (this.IsPesosMoney) ? _format_pesos : _format_dollars;
            ws.TabColor = System.Drawing.Color.FromArgb(30894);
        }
开发者ID:BoccaDamian,项目名称:bubis,代码行数:18,代码来源:ucAccountsListings.ascx.cs

示例12: CreateJoinComponent

        private Join CreateJoinComponent(IGrouping<Property, KeyValuePair<SourceColumn, SourceColumn>> referenceGroup, Dictionary<SourceColumn, Join> all_joins)
        {
            // Get SrcTbl & check for uniqueness.
            var srcTbl = referenceGroup.Select(r => r.Value.References.SourceTable).Distinct().Single();
            var directRefs = referenceGroup.Where(r => r.Value.References.References == null);

            var result = new Join()
            {
                Type = JoinType.Left,
                JoinTableName = _dst.GetTableName(srcTbl.DestinationObjectClass.Module.SchemaName, srcTbl.DestinationObjectClass.TableName),
                JoinColumnName = directRefs.Select(reference => new ColumnRef(reference.Value.References.DestinationProperty.Single().Name, ColumnRef.Local, reference.Value.References.DestinationProperty.Single().GetDbType())).ToArray(),
                FKColumnName = directRefs.Select(reference => new ColumnRef(reference.Value.Name, ColumnRef.PrimaryTable, (System.Data.DbType)reference.Value.DbType)).ToArray(),
                CompareNullsAsEqual = directRefs.Select(reference => reference.Key.CompareNulls).ToArray()
            };
            directRefs.ForEach(dr => all_joins[dr.Key] = result);
            return result;
        }
开发者ID:daszat,项目名称:zetbox,代码行数:17,代码来源:MigrationTasksBase.cs

示例13: GetItemsMarkedForDeletion

 private IEnumerable<object> GetItemsMarkedForDeletion(IGrouping<ISimpleDbDomain, ISessionItem> domainSet)
 {
     return domainSet
         .Where(i => i.State == SessionItemState.Delete)
         .Select(i => new {
             Name = i.Name
         }).Cast<object>();
 }
开发者ID:rexm,项目名称:SimpleDb.Net,代码行数:8,代码来源:SimpleDbSession.cs

示例14: GetAttributesMarkedForDeletion

 private IEnumerable<object> GetAttributesMarkedForDeletion(IGrouping<ISimpleDbDomain, ISessionItem> domainSet)
 {
     return domainSet
         .Where(i => i.State == SessionItemState.Update)
         .Select(i => new {
             Name = i.Name,
             Attributes = i.Attributes.Where(att => ((ISessionAttribute)att).IsDeleted)
         })
         .Where(a => a.Attributes.Any())
         .Cast<object>();
 }
开发者ID:rexm,项目名称:SimpleDb.Net,代码行数:11,代码来源:SimpleDbSession.cs


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