本文整理汇总了C#中IGrouping.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# IGrouping.OrderBy方法的具体用法?C# IGrouping.OrderBy怎么用?C# IGrouping.OrderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGrouping
的用法示例。
在下文中一共展示了IGrouping.OrderBy方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFilterGroupModel
private FilterGroupModel CreateFilterGroupModel(IGrouping<int, FilterDTO> filterDTOGroup, string locationID, string database)
{
return new FilterGroupModel()
{
FilterGroupItems = filterDTOGroup.OrderBy(f => f.ViewOrder).Select(f => CreateBaseFilter(f, locationID, database)).ToList(),
Index = filterDTOGroup.Key
};
}
示例2: CreateFileFor
private static void CreateFileFor(IGrouping<string, Translation> group)
{
const string @namespace = "TODO.Your.Namespace";
var ietfLanguageTag = group.Key.ToLower();
var className = string.Concat(char.ToUpper(ietfLanguageTag[0]), ietfLanguageTag.Substring(1));
var translationBuilder = new StringBuilder();
foreach (var translation in group.OrderBy(t => t.XPath))
{
translationBuilder.AppendFormat(@" new Translation{{ResourceKey = ""{0}"", Text = @""{1}""}},{2}", translation.XPath, translation.Content, Environment.NewLine);
}
var content = string.Format(TemplateFile, @namespace, className, ietfLanguageTag, translationBuilder);
var filePath = string.Format(@"{0}\{1}.cs", OutputPath, className);
File.WriteAllText(filePath, content);
}
示例3: _CreateSingleMembershipWithCorrectStatus
private static MembershipDetails _CreateSingleMembershipWithCorrectStatus(IGrouping<int, MembershipDetails> groupedDetails)
{
var firstDetails = groupedDetails.First();
var statusToUse = groupedDetails
.OrderBy(d => d.MembershipStatus)
.First().MembershipStatus;
return new MembershipDetails
{
BecNumber = firstDetails.BecNumber,
FirstName = firstDetails.FirstName,
LastName = firstDetails.LastName,
MembershipStatus = statusToUse
};
}
示例4: DisplayGroupResults
static void DisplayGroupResults(IGrouping<int, RunResult> group)
{
Console.WriteLine("Benchmark {0}, Runner {1}, {2} iterations", group.First().BenchmarkType.Name,
group.First().RunnerType.Name, group.Key);
Console.WriteLine();
Console.WriteLine("{0,-30}{1,-14}{2,-12}{3,-10}{4}", "Implementation", "Duration", "Difference", "Each",
"Multiplier");
Console.WriteLine(new string('=', 78));
IOrderedEnumerable<RunResult> ordered = group.OrderBy(x => x.Duration);
RunResult best = ordered.First();
ordered.Select(x => new DisplayResult(x, best))
.Each(DisplayResult);
Console.WriteLine();
}
示例5: DisplayGroupResults
static void DisplayGroupResults(IGrouping<int, RunResult> group)
{
Console.WriteLine("Benchmark {0}, Runner {1}, {2} iterations", group.First().BenchmarkType.Name,
group.First().RunnerType.Name, group.Key);
Console.WriteLine();
Console.WriteLine("{0,-30}{1,-14}{2,-12}{3,-10}{4,-12}{5,-12}{6}", "Implementation", "Duration",
"Difference", "Each",
"Multiplier", "Memory(KB)", "Throughput");
Console.WriteLine(new string('=', 102));
IOrderedEnumerable<RunResult> ordered = group.OrderBy(x => x.Duration);
RunResult best = ordered.First();
IEnumerable<DisplayResult> results = ordered.Select(x => new DisplayResult(x, best));
foreach (DisplayResult x in results)
{
DisplayResult(group.Key, x);
}
Console.WriteLine();
}
示例6: AssignReleaseStatus
/// <summary>
/// Assigns the release status.
/// </summary>
/// <param name="processItem">The process item.</param>
private static void AssignReleaseStatus(IGrouping<byte?, ProcessComplianceListItem> processItem)
{
var currentDate = DateTimeHelper.RetrieveCurrentDate();
var currentDateTime = DateTimeHelper.RetrieveCurrentDateTime();
////For past releases.
var processComplianceListItem = processItem.OrderByDescending(u => u.StartDate).FirstOrDefault(u => u.StartDate <= currentDateTime);
int missedArtifactsCount;
////When Artifacts are missed.
if (processComplianceListItem != null)
{
missedArtifactsCount = (from listItem in processComplianceListItem.Items where listItem.DueDate < currentDate && listItem.Status != (byte)ArtifactStatus.Completed select listItem).Count();
if (missedArtifactsCount > 0)
{
processComplianceListItem.ReleaseArtifactsMissedCount = missedArtifactsCount;
}
}
////When release has not been completed on EndDate.
if (processComplianceListItem != null && processComplianceListItem.ReleaseStatus.HasValue && processComplianceListItem.EndDate.HasValue && processComplianceListItem.EndDate < currentDateTime && !processComplianceListItem.ReleaseStatus.Equals((byte)ReleaseStatus.Completed))
{
processComplianceListItem.IsReleaseNotCompleted = true;
}
////For future releases.
processComplianceListItem = processItem.OrderBy(u => u.StartDate).FirstOrDefault(u => u.StartDate >= currentDateTime);
////When Artifacts are missed.
if (processComplianceListItem != null)
{
missedArtifactsCount = (from listItem in processComplianceListItem.Items where listItem.DueDate < currentDate && listItem.Status != (byte)ArtifactStatus.Completed select listItem).Count();
if (missedArtifactsCount > 0)
{
processComplianceListItem.ReleaseArtifactsMissedCount = missedArtifactsCount;
}
}
////When risk at release level for future releases.
if (processComplianceListItem != null && processComplianceListItem.Items.Any(u => u.ReleaseAtRiskFlag.HasValue && u.ReleaseAtRiskFlag.Value))
{
processComplianceListItem.IsReleaseAtRisk = true;
}
}
示例7: ToJsonModel
private InsuranceGroupJsonModel ToJsonModel(IGrouping<PolicyType, Insurance> group)
{
if (group == null) return null;
return new InsuranceGroupJsonModel()
{
GroupId = group.Key.Id,
GroupName = group.Key.Name,
Insurances = group.OrderBy(x => x.Order).Select(ToJsonModel).ToList()
};
}
示例8: CreateRecordFromGrouping
private static VerizonRecord CreateRecordFromGrouping(IGrouping<string, VerizonRecord> g)
{
return new VerizonRecord
{
Date = g.OrderBy(r => r.Date).Last().Date,
Description = g.First().Description,
Minutes = g.Sum(r => r.Minutes),
Number = g.Key
};
}
示例9: compileSingleSentece
/// <summary>
/// Собирает предложение по частям
/// </summary>
/// <param name="parts"></param>
/// <returns></returns>
private static Sentence compileSingleSentece(IGrouping<int, RawSentencePart> parts)
{
var builder = parts.OrderBy(part => part.Position)
.Aggregate(new SentenceBuilder(), (sentenceBuilder, part) => sentenceBuilder.Add(part));
return builder.Sentence;
}
示例10: ActivityEditorVm
public ActivityEditorVm(
Model.Task task,
Dal.SoheilEdmContext uow,
IGrouping<Model.Activity, Model.StateStationActivity> ssaGroup)
: base(ssaGroup.Key)
{
Message = new Common.SoheilException.EmbeddedException();
if (!ssaGroup.Any())
{
Message.AddEmbeddedException("فعالیتی وجود ندارد");
return;
}
//make ProcessList self-aware of all changes
ProcessList.CollectionChanged += (s, e) =>
{
if (e.NewItems != null)
foreach (ProcessEditorVm processVm in e.NewItems)
{
ProcessList_Added(processVm);
}
};
//Add Choices
foreach (var choice in ssaGroup.OrderBy(ssa => ssa.ManHour))
{
Choices.Add(new ChoiceEditorVm(choice));
}
//Add existing processes
foreach (var process in task.Processes.Where(x => x.StateStationActivity.Activity.Id == ssaGroup.Key.Id))
{
ProcessList.Add(new ProcessEditorVm(process, Model, uow));
}
//Add process command
AddProcessCommand = new Commands.Command(o =>
{
DateTime dt;
if (GetTaskStart == null)
dt = ProcessList.Any() ?
ProcessList
.Where(x => x.ActivityModel.Id == ssaGroup.Key.Id)
.Max(x => x.Model.EndDateTime)
: task.StartDateTime;
else
dt = GetTaskStart();
var minMH = ssaGroup.Min(x => x.ManHour);
var processVm = new ProcessEditorVm(
new Model.Process
{
StartDateTime = dt,
EndDateTime = dt,
StateStationActivity = ssaGroup.First(x=>x.ManHour == minMH),
TargetCount = 0,
Task = task,
}, Model, uow);//activity Model is set here
ProcessList.Add(processVm);
processVm.IsSelected = true;
});
}
示例11: BuildForRepo
private string BuildForRepo(string repoName, IGrouping<string, RepoAndBranchInfo> repoAndBranchInfos)
{
var sb = new StringBuilder();
sb.Append(AddColumnHeaders());
var orderedByDateDesc = repoAndBranchInfos.OrderBy(b => b.BranchInfo.CommitterDate.Date);
foreach (var repoAndBranchInfo in orderedByDateDesc)
{
var branchInfo = repoAndBranchInfo.BranchInfo;
var branchName = branchInfo.Name.Length > Constants.EmailCommitBranchNameLength ? branchInfo.Name.Substring(0, Constants.EmailCommitBranchNameLength) : branchInfo.Name;
var commitMessage = branchInfo.Message.Length > Constants.EmailCommitMessageLength ? branchInfo.Message.Substring(0, Constants.EmailCommitMessageLength) : branchInfo.Message;
sb.Append(AddBranchInfo(branchInfo, branchName, commitMessage));
}
return h3(repoName) + table(sb.ToString());
}