本文整理汇总了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));
}
示例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));
}
示例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());
}
}
示例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());
}
}
示例5: PerformJobs
private void PerformJobs(IGrouping<ISynchronizeInvoke, UpdateUIJob> jobGroup)
{
var firstJob = jobGroup.First();
jobGroup.Where(job => job != firstJob).ForEach(firstJob.MergeWith);
firstJob.Perform();
}
示例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;
}
示例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));
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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>();
}
示例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>();
}