本文整理汇总了C#中IGrouping.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# IGrouping.SelectMany方法的具体用法?C# IGrouping.SelectMany怎么用?C# IGrouping.SelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGrouping
的用法示例。
在下文中一共展示了IGrouping.SelectMany方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: CreateOneNamespaceDeclaration
private static MemberDeclarationSyntax CreateOneNamespaceDeclaration(IGrouping<string, NamespaceDeclarationSyntax> ns)
{
var nameSyntax = SyntaxFactory.ParseName(ns.Key);
return SyntaxFactory
.NamespaceDeclaration(nameSyntax)
.AddMembers(ns.SelectMany(x => x.Members)
.ToArray());
}
示例3: ComputeOffsetBetweenEvents
private DataAroundEvent[] ComputeOffsetBetweenEvents(IGrouping<string, DataAroundEvent>[] orderEventGroups, IGrouping<string, DataAroundEvent> midGroup)
{
// compute offset between each event to center group
DataAroundEvent[] repivotEvents;
repivotEvents = orderEventGroups.SelectMany(@group =>
@group.Select(d =>
{
var eventPicked = @group.OrderByDescending(e => e.EventDate).FirstOrDefault(g => g.EventDate > DateTime.Today.AddDays(-numberOfPointsAroundEvent));
int busDayDiff = 0;
if (eventPicked != null)
{
busDayDiff = BusDayDiff(midGroup.OrderByDescending(e => e.EventDate).First(x => x.EventDate > DateTime.Today.AddDays(-numberOfPointsAroundEvent)).EventDate, eventPicked.EventDate);
}
var ar = new DataAroundEvent(d.EventDate, d.Instrument, d.RawData, d.NumPointsAroundEvent, d.EventCode, busDayDiff)
{
PivotIndex = pivotIndex,
};
return ar;
})).ToArray();
return repivotEvents;
}