本文整理汇总了C#中Common.List.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# List.OrderBy方法的具体用法?C# List.OrderBy怎么用?C# List.OrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common.List
的用法示例。
在下文中一共展示了List.OrderBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FilterProducts
public PartialViewResult FilterProducts(ProductFilterModel model)
{
List<Product> p = new WCFProduct().GetProducts().ToList();
List<ProductModel> products = new List<ProductModel>();
foreach (Product pr in p)
{
ProductModel pm = new ProductModel();
pm.ID = pr.ID;
pm.Features = pr.Features;
pm.DateListed = pr.Date_Listed;
pm.Name = pr.Name;
pm.Image = pr.Image;
pm.Price = (double)pr.Price;
pm.StockAmount = pr.Stock_Amount;
pm.AverageRate = new WCFProductClient().GetProductAverageRating(pr.ID);
if (model.CategoryName != null)
{
if (pr.Category != null && pr.Category.Contains(model.CategoryName))
{
products.Add(pm);
}
}
else if (model.ProductName != null)
{
if (pm.Name.Contains(model.ProductName))
{
products.Add(pm);
}
}
else if (model.smallestPrice != 0 && model.greatestPrice != 0 && model.smallestPrice != null && model.greatestPrice != null)
{
if (pm.Price >= model.smallestPrice && pm.Price <= model.greatestPrice)
{
products.Add(pm);
}
}
else
{
products.Add(pm);
}
if (model.sortByPrice == true)
{
if (model.sortDescending == true)
{
products = products.OrderByDescending(temP => temP.Price).ToList();
}
else
{
products = products.OrderBy(temP => temP.Price).ToList();
}
}
}
return PartialView("_Filters", products);
}
示例2: GetEvents
List<JournalRecord> GetEvents(int oldJournalNo)
{
var journalRecords = new List<JournalRecord>();
var result = ReadEvents(SynchrinizeJournalNo, 100);
if (result == null || result.Result == null || result.HasError)
{
OnCriticalError();
return new List<JournalRecord>();
}
var document = SerializerHelper.Deserialize<Firesec.Models.Journals.document>(result.Result);
if (document != null && document.Journal.IsNotNullOrEmpty())
{
foreach (var innerJournalItem in document.Journal)
{
var eventId = int.Parse(innerJournalItem.IDEvents);
if (eventId > oldJournalNo)
{
if (eventId > LastJournalNo)
{
SynchrinizeJournalNo = eventId;
}
var journalRecord = JournalConverter.Convert(innerJournalItem);
journalRecords.Add(journalRecord);
}
}
}
if (journalRecords.Count > 0)
journalRecords = journalRecords.OrderBy(x => x.OldId).ToList();
return journalRecords;
}
示例3: MergeItems
private List<CalendarItem> MergeItems(List<CalendarItem> newItems, List<CalendarItem> fromRepo)
{
var result = new List<CalendarItem>();
var newModels = newItems.Except(fromRepo, new CalendarItemEqualityComparer()).ToList();
var updatet = fromRepo.Except(newModels,new CalendarItemEqualityComparer()).ToList();
updatet.ForEach(x =>
{
var model = newItems.FirstOrDefault(y => y.Id == x.Id);
if (model != null)
{
model.SyncStatus.CalenadCalendarItemStatus = IsModified(model, x)
? CalendarItemStatus.Updated
: CalendarItemStatus.Unmodified;
result.Add(model);
}
});
var deleted = fromRepo.Where(x => x.Start.Date >= DateTime.Now.Date).Except(newItems).Except(updatet);
newModels.ForEach(x => x.SyncStatus.CalenadCalendarItemStatus = CalendarItemStatus.New);
deleted.ForEach(x =>
{
x.SyncStatus.CalenadCalendarItemStatus = CalendarItemStatus.Deleted;
result.Add(x);
});
result.AddRange(newModels);
return result.OrderBy(x => x.Start).ToList();
}
示例4: GetAlbums
public List<AlbumModel> GetAlbums(int cid, int count = 0)
{
var varticles = cid == 0 ? GetVArticles(4, 0, count) : GetVArticles(4, GetCategoryIds(cid), count);
var albums = new List<AlbumModel>();
foreach (var varticle in varticles)
{
albums.Add(GetAlbum(varticle));
}
return albums.OrderBy(m => m.Category.OrderId).ThenBy(m => m.Varticle.istop).ToList();
}
示例5: Expression
private static void Expression(List<Student> students)
{
var selectedStudents = students.OrderBy(x => x.GroupNumber).GroupBy(x => x.GroupNumber);
foreach (var groupedStudents in selectedStudents)
{
Console.WriteLine(Environment.NewLine + "Group number " + groupedStudents.Key);
foreach (var student in groupedStudents)
{
Console.WriteLine("Name: {0}, Group number: {1}", student.FirstName + " " + student.LastName, student.Group.GroupNumber);
}
}
}
示例6: btnQuery_Click
private void btnQuery_Click(object sender, EventArgs e)
{
try
{
this.Cursor = Cursors.WaitCursor;
List<MealBooking_mbk_info> _objList = new List<MealBooking_mbk_info>();
MealBooking_mbk_info mbkInfo = new MealBooking_mbk_info();
mbkInfo.StartTime = this.rspSearch.RSP_TimeFrom;
mbkInfo.EndTime = this.rspSearch.RSP_TimeTo;
if (this.rspSearch.RSP_GradeID != Guid.Empty && this.rspSearch.RSP_ClassID == Guid.Empty)
{
mbkInfo.GradeID = this.rspSearch.RSP_GradeID;
}
else if (this.rspSearch.RSP_ClassID != Guid.Empty)
{
mbkInfo.ClassID = this.rspSearch.RSP_ClassID;
}
_objList = _imbBL.SearchRecords(mbkInfo);
if (_objList != null && _objList.Count > 0)
{
_objList = _objList.OrderBy(p => p.className).ToList();
ShowReport(_objList);
}
else
{
ShowWarningMessage("找不到符合条件的记录。");
}
}
catch
{
}
this.Cursor = Cursors.Default;
}
示例7: GetRequestPitchBoll
/// <summary>
/// 投手に要求する投球を取得
/// </summary>
/// <returns>要求する投球(コースと球種のみ設定)</returns>
public PitchingBallData GetRequestPitchBoll()
{
// 基本作戦の「常に厳しいコース」を追加
List<PitchingMission> missions = new List<PitchingMission>();
missions.Add(new PitchingMission(PitchingMissionKind.Random));
// 智力依存で投球の作戦を追加
AddMissions(missions);
// 検証用の投球作戦が指定されている場合は、他の投球作成をクリアしてそれを設定する
if (PitchingMissionsForDebug.Count > 0)
{
missions.Clear();
missions.AddRange(PitchingMissionsForDebug);
}
// 要求する投球データの初期値
// (球種はランダム、コースは厳しいコース)
PitchingBallData requestBall = new PitchingBallData()
{
IsFastBall = RandomCreater.GetBool(),
PitchingCourse = PitchingCourse.Severe
};
// 優先順位の低い順にソートした作戦を元にスイングデータを作成する
// (優先度の高い作戦により、後から上書きする)
var sortedMissions = missions.OrderBy(m => m.Priority);
foreach (PitchingMission mission in sortedMissions)
{
requestBall = mission.GetRequestBall(GameData, requestBall);
}
// ウエストの場合は球種は直球にしておく(アニメーションを直球にするため)
if (requestBall.PitchingCourse == PitchingCourse.PitchOut)
{
requestBall.IsFastBall = true;
}
return requestBall;
}
示例8: GetAllTags
public JsonResult GetAllTags(string searchTerm, int pageSize, int pageNumber)
{
var resultList = new List<TagViewModel>();
if (!string.IsNullOrEmpty(searchTerm))
{
resultList = this.tags.GetAll().To<TagViewModel>()
.Where(n => n.text.ToLower()
.Contains(searchTerm.ToLower()))
.ToList();
}
else
{
resultList = this.tags.GetAll().To<TagViewModel>().ToList();
}
var results = resultList.OrderBy(t => t.text).Skip((pageNumber - 1) * pageSize)
.Take(pageSize)
.ToList();
return this.Json(new { Results = results, Total = resultList.Count }, JsonRequestBehavior.AllowGet);
}
示例9: GetSourcesAsync
/// <summary>
/// Gets all <see cref="IVideoSource"/>s currently in database.
/// </summary>
/// <returns>All <see cref="IVideoSource"/>s currently in database.</returns>
public async Task<List<IVideoSource>> GetSourcesAsync()
{
if (!dbConnection.IsInitialized)
{
await dbConnection.InitializeAsync();
}
var sourcesList = new List<IVideoSource>();
var query = dbConnection.Table<VideoSource>();
sourcesList.AddRange(await query.ToListAsync());
return sourcesList.OrderBy(source => source.Name).ToList();
}
示例10: Apply
public Player Apply(TurnInfo info, IEnumerable<Player> queue)
{
var owner = queue.FirstOrDefault(p => p == info.Ball.Owner);
// We are not the owner.
if (owner == null) { return null; }
var ownerDistanceToGoal2 = (Field.EnemyGoal.Center - owner.Position).LengthSquared;
if(!info.Other.Players.Any(p => (p.Position - Field.EnemyGoal.Center).LengthSquared < ownerDistanceToGoal2))
{
if (ownerDistanceToGoal2 < 150 * 150)
{
owner.ActionShootGoal();
}
else
{
owner.ActionGo(Field.EnemyGoal.Center);
}
return owner;
}
var shotOnGoalTop = Field.EnemyGoal.Top - owner.Position;
var shotOnGoalCen = Field.EnemyGoal.Center - owner.Position;
var shotOnGoalBot = Field.EnemyGoal.Bottom - owner.Position;
var accuracy = Statistics.GetAccuracy(10, 0.75f);
var shotAngle = Theta.Create(shotOnGoalTop, shotOnGoalBot);
if (shotAngle > 2f * accuracy)
{
if (!info.Other.Players.Any(oppo => MightCatch(oppo.Position - owner.Position, shotOnGoalCen, 10, 0.75f)))
{
owner.ActionShootGoal();
return owner;
}
}
var passCandidates = info.Own.Players
.Where(p => p != owner && IsCandidate(owner, p, ownerDistanceToGoal2))
.OrderBy(p => (Field.EnemyGoal.Center - p.Position).LengthSquared)
.ToList();
if (!passCandidates.Any())
{
owner.ActionGo(Field.EnemyGoal.Center);
return owner;
}
var oppos = info.Other.Players.Where(p => p.Position.X > owner.Position.X).ToList();
foreach (var z in PassingZs)
{
foreach (var power in PassingPowers)
{
var safe = new List<Player>();
foreach (var candidate in passCandidates)
{
if (!info.Other.Players.Any(oppo => MightCatch(oppo.Position - owner.Position, candidate.Position - owner.Position, power, z)))
{
safe.Add(candidate);
}
}
if (safe.Any())
{
var target = safe.OrderBy(s => (s.Position - Field.EnemyGoal.Center).LengthSquared).FirstOrDefault();
owner.ActionShoot(target, PassingPower);
return owner;
}
}
}
// else run.
owner.ActionGo(Field.EnemyGoal.Center);
return owner;
}
示例11: ChooseTask
public ActiveEstimatedTask ChooseTask(EstimatedWorkflow workflow, List<IEnumerable<ActiveEstimatedTask>> tasks)
{
return tasks.OrderBy(t =>
{
var parent = workflow.Tasks.Single(wt => wt.Id == t.First().Id);
var depsWaitingTime = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max(d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time);
var nodesWaitingTime = t.First().Estimation.NodesTimings.Max(n => n.GetAvailabilityTime());
var waitingTime = Math.Max(depsWaitingTime, nodesWaitingTime);
return waitingTime + t.First().Estimation.Result.Time;
}).First().First();
}
示例12: FillReadySelect
/// <summary>
/// 填充數據到控件(已經準備項)
/// </summary>
/// <param name="source"></param>
private void FillReadySelect(List<MachinePrepareItem_mpit_Info> SelectSource)
{
lock (this.snyObj)
{
if (SelectSource == null)
return;
this.lvReadySelect.Clear();
this.lvReadySelect.BeginUpdate();
initReadySelect();
var source = SelectSource.OrderBy(o => o.ppmSeq);
foreach (MachinePrepareItem_mpit_Info t in source)
{
ListViewItem item = new ListViewItem();
Model.HBPMS.Management.RunningManagement.PrepareProjectMaster_ppm_Info PProject = t.PrepareProjectItem;
item.Tag = t;
item.SubItems[0].Text = t.mpit_PIPFID.ToString();
item.SubItems.Add(PProject.ppm_iSeq.ToString());
item.SubItems.Add(PProject.ppm_cItemCode.ToString());
item.SubItems.Add(PProject.ppm_cItemName.ToString());
item.SubItems.Add(PProject.ppm_iPredictedTime.ToString());
item.SubItems.Add(PProject.ppm_lIsParallelable == false ? "否" : "是");
item.SubItems.Add(PProject.ppm_cItemType.ToString());
item.SubItems.Add(PProject.ppm_cItemTypeName.ToString());
item.SubItems.Add(t.mpit_PIPFID.ToString());
this.lvReadySelect.Items.Add(item);
}
this.lvReadySelect.EndUpdate();
}
}
示例13: FillReadyAll
/// <summary>
/// 填充數據到控件(全部準備項)
/// </summary>
/// <param name="source"></param>
private void FillReadyAll(List<Model.HBPMS.Management.RunningManagement.PrepareProjectMaster_ppm_Info> All)
{
lock (this.snyObj)
{
if (All == null)
return;
this.lvReadyAll.Clear();
this.lvReadyAll.BeginUpdate();
initReadyAll();
initReadySelect();
var source = All.OrderBy(o => o.ppm_iSeq);
foreach (Model.HBPMS.Management.RunningManagement.PrepareProjectMaster_ppm_Info t in source)
{
ListViewItem item = new ListViewItem();
item.Tag = t;
item.SubItems[0].Text = t.ppm_RecordID.ToString();
item.SubItems.Add(t.ppm_iSeq.ToString());
item.SubItems.Add(t.ppm_cItemCode.ToString());
item.SubItems.Add(t.ppm_cItemName.ToString());
item.SubItems.Add(t.ppm_iPredictedTime.ToString());
item.SubItems.Add(t.ppm_lIsParallelable == false ? "否" : "是");
item.SubItems.Add(t.ppm_cItemTypeName.ToString());
//item.SubItems.Add(((PrepareItemProfile)t).MachineType.ToString());
//string machineTypeDesc = container.GetValueNameInfo(DictionaryType.MachineType, ((PrepareItemProfile)t).MachineType).Display;
item.SubItems.Add(t.ppm_cMachineTypeName);
item.SubItems.Add(t.ppm_RecordID.ToString());
this.lvReadyAll.Items.Add(item);
}
this.lvReadyAll.EndUpdate();
}
}
示例14: _compileMainPart
private IOrderedEnumerable<SentenceWord> _compileMainPart(Stage4ResultElement mainPart)
{
var result = new List<SentenceWord> { mainPart };
result.AddRange(mainPart.ServiceParts);
result.AddRange(mainPart.AddedWordsCase1);
result.AddRange(mainPart.AddedWordsCase2);
return result.OrderBy(word => word.Order);
}
示例15: SetMembers
/// <summary>
/// メンバの打順とポジションを設定
/// </summary>
/// <param name="allPlayers">全選手一覧(スタメン選定時に同じ能力なら並び順が先を優先)</param>
private void SetMembers(List<Player> allPlayers)
{
// 各ポジションごとに強い順に新しいスタメンを設定
List<GameMember> newGameMembers = new List<GameMember>();
List<GameMember> newOutsideMembers = new List<GameMember>();
List<DefensePosition> pendingPositions = new List<DefensePosition>();
foreach (DefensePosition position in DefensePositionHelper.GetEnums)
{
Player player;
// 守備適正のあるメンバのうち、総合力が最も高いメンバを選定する
if (position == DefensePosition.Pitcher)
{
// コンバートにより投手でも存在しないことがありえるためFirstOrDefaultメソッドで取得
player = allPlayers.Where(m => DefenseTypeHelper.FitDefensePosition(position, m.FielderAbility.DefenseType)).OrderByDescending(m => m.PitcherAbility.Total).FirstOrDefault();
}
else
{
player = allPlayers.Where(m => DefenseTypeHelper.FitDefensePosition(position, m.FielderAbility.DefenseType)).OrderByDescending(m => m.FielderAbility.Total).FirstOrDefault();
}
if (player != null)
{
// 新しいメンバをスタメンに追加
GameMember member = new GameMember(player, position);
newGameMembers.Add(member);
// 選手一覧から追加メンバを削除
allPlayers.Remove(player);
}
else
{
// 適切な守備適性のメンバが存在せずnullの場合は再検討
pendingPositions.Add(position);
}
}
// 適切な守備適性でスタメンが埋まらない場合は、適当に総合力の高い順に選定
if (pendingPositions.Count > 0)
{
foreach (DefensePosition position in pendingPositions)
{
// 概ね適正のある守備位置から選定
Player player = allPlayers.Where(m => DefenseTypeHelper.MostFitDefensePosition(position, m.FielderAbility.DefenseType))
.OrderByDescending(m => m.FielderAbility.Total).FirstOrDefault();
// 概ねの適性もなければ投手以外で適当に選定
if (player == null)
{
player = allPlayers.OrderBy(m => m.IsPitcher).ThenByDescending(m => m.FielderAbility.Total).First();
}
// 新しいメンバをスタメンに追加
GameMember member = new GameMember(player, position);
newGameMembers.Add(member);
// 選手一覧から追加メンバを削除
allPlayers.Remove(player);
}
}
// この時点で9人となるはず
Assertion.Assert(newGameMembers.Count == 9, "newGameMembers.Count == 9");
// 打順は、以下の順にメンバの能力値で決める
// 9:投手(投手でも打撃強い場合があるが交代も考慮して9番とする)
// 4:[ミート+パワー×2]トップ(初期設定で友沢亮が4番になりにくくするため長打力を重視)
// 1:[ミート+走力]トップ
// 3:打者能力トップ
// 2:[ミート+智力]トップ
// 5:打者能力トップ
// 6:打者能力トップ
// 7:打者能力トップ
// 8:打者能力トップ
GameMember member9 = newGameMembers.OrderByDescending(m => m.DefensePosition == DefensePosition.Pitcher).First();
newGameMembers.Remove(member9);
GameMember member4 = newGameMembers.OrderByDescending(m => m.Meet + m.Power * 2).First();
newGameMembers.Remove(member4);
GameMember member1 = newGameMembers.OrderByDescending(m => m.Meet + m.Run).First();
newGameMembers.Remove(member1);
GameMember member3 = newGameMembers.OrderByDescending(m => m.BatterAbility).First();
newGameMembers.Remove(member3);
GameMember member2 = newGameMembers.OrderByDescending(m => m.Meet + m.Wisdom).First();
newGameMembers.Remove(member2);
GameMember member5 = newGameMembers.OrderByDescending(m => m.BatterAbility).First();
newGameMembers.Remove(member5);
GameMember member6 = newGameMembers.OrderByDescending(m => m.BatterAbility).First();
newGameMembers.Remove(member6);
GameMember member7 = newGameMembers.OrderByDescending(m => m.BatterAbility).First();
newGameMembers.Remove(member7);
GameMember member8 = newGameMembers.OrderByDescending(m => m.BatterAbility).First();
newGameMembers.Remove(member8);
// 一番から打順の順番で追加し直す
newGameMembers.Add(member1);
newGameMembers.Add(member2);
newGameMembers.Add(member3);
//.........这里部分代码省略.........