本文整理汇总了C#中Common.List.OrderByDescending方法的典型用法代码示例。如果您正苦于以下问题:C# List.OrderByDescending方法的具体用法?C# List.OrderByDescending怎么用?C# List.OrderByDescending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common.List
的用法示例。
在下文中一共展示了List.OrderByDescending方法的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: Expression
private static void Expression(List<Student> list)
{
Console.WriteLine("\nInitial state:\n");
list.ForEach(x => Console.WriteLine(x));
Console.WriteLine("\nDescending order with expression\n");
List<Student> sort1 = list.OrderByDescending(x => x.FirstName)
.ThenByDescending(x => x.LastName)
.ToList();
sort1.ForEach(x => Console.WriteLine(x));
}
示例3: GetAlbumImageList
/// <summary>
/// 读取json,反序列化为相册图片列表
/// </summary>
public List<AlbumImageModel> GetAlbumImageList(string content, out AlbumImageModel cover)
{
List<AlbumImageModel> lst = new List<AlbumImageModel>();
cover = new AlbumImageModel();
try
{
string jsonnav = Utils.RemoveHtml(content).Replace("\n", "").Replace(" ", "");
if (jsonnav != "")
{
lst = Utils.ParseFromJson<List<AlbumImageModel>>(jsonnav);
cover = lst.OrderByDescending(m => m.IsCover).FirstOrDefault();
}
}
catch (Exception) { }
return lst;
}
示例4: GetAlbumPhotoList
private static List<AlbumPhotoModel> GetAlbumPhotoList(string content, out AlbumPhotoModel cover)
{
var lst = new List<AlbumPhotoModel>();
cover = new AlbumPhotoModel();
try
{
var jsonnav = content.ExRemoveHtml().Replace("\n", "").Replace(" ", "");
if (jsonnav != "")
{
lst = Utils.ParseFromJson<List<AlbumPhotoModel>>(jsonnav);
cover = lst.OrderByDescending(m => m.IsCover).FirstOrDefault();
}
}
catch { }
return lst;
}
示例5: GetDataByDateTime
public string GetDataByDateTime(string dateBegin, string dateEnd)
{
string result = "";
List<Dictionary<string, string>> listDic = new List<Dictionary<string, string>>();
listDic = GetOPInfoListForSpecimenByTimeRangeAndToDicList(dateBegin, dateEnd);
List<RuRo.Model.ZSSY.OPListForSpecimen> list = new List<RuRo.Model.ZSSY.OPListForSpecimen>();
if (listDic.Count > 0)
{
//result = ConvertDicListToJsonStr(listDic);
foreach (var item in listDic)
{
RuRo.Model.ZSSY.OPListForSpecimen model = new RuRo.Model.ZSSY.OPListForSpecimen();
RuRo.Common.ObjAndDic.DicToObject(item, model);
if (model.KeepSpecimenSign=="N")
{
model.KeepSpecimenSign = "";
}
list.Add(model);
}
list = list.OrderByDescending(a => a.KeepSpecimenSign).ToList();
result = Newtonsoft.Json.JsonConvert.SerializeObject(list);
}
return result;
}
示例6: ChooseTask
public ActiveEstimatedTask ChooseTask(EstimatedWorkflow workflow, List<IEnumerable<ActiveEstimatedTask>> tasks)
{
return tasks.OrderByDescending(t =>
GetTime(workflow, t.ElementAt(1)) - GetTime(workflow, t.ElementAt(0))).First().First();
}
示例7: TopTenProductsWithFaults
public PartialViewResult TopTenProductsWithFaults()
{
List<Product> products = new ProductServ.WCFProductClient().GetProducts().ToList();
List<ReportModel> pr = new List<ReportModel>();
foreach (Product p in products)
{
int faultNum = new BAFuncServ.WCFBAFuncClient().GetFaultNum(p.ID);
ReportModel rp = new ReportModel();
rp.Name = p.Name;
rp.Features = p.Features;
rp.Img = p.Image;
rp.Number_Faults = faultNum;
pr.Add(rp);
}
List<ReportModel> prSorted = pr.OrderByDescending(x => x.Number_Faults).ToList();
return PartialView("_TopTenProductsWithFaults",prSorted);
}
示例8: UpdateRechargeRecord
//.........这里部分代码省略.........
//系统账户
SystemAccountDetail_sad sysAccount = new SystemAccountDetail_sad();
sysAccount.sad_cRecordID = Guid.NewGuid();
sysAccount.sad_cConsumeID = rechargeInfo.rcr_cRecordID;
sysAccount.sad_cDesc = Common.DefineConstantValue.GetMoneyFlowDesc(rechargeInfo.rcr_cRechargeType);
sysAccount.sad_cFLowMoney = preRechargeItem.prr_fRechargeMoney;//金额与预充值额全额一致
sysAccount.sad_cFlowType = rechargeInfo.rcr_cRechargeType;
sysAccount.sad_cOpt = rechargeInfo.rcr_cLast;
sysAccount.sad_dOptTime = DateTime.Now;
listSysAccountInfos.Add(sysAccount);
}
}
#endregion
if (listUserAccountInfos.Count > 0)
{
//插入由充值记录产生的账户记录
listToInsertRecharge.AddRange(listRechargeInserts);
listToInsertAccountDetail.AddRange(listUserAccountInfos);
listToInsertSysDetail.AddRange(listSysAccountInfos);
}
//查找用户是否含有透支预存款记录
decimal fAdvance = decimal.Zero;
#region 获取用户的透支金额
List<RechargeRecord_rcr> listAdvance = db.RechargeRecord_rcr.Where(x =>
x.rcr_cUserID == listRechargeInserts[0].rcr_cUserID
&& x.rcr_cRechargeType == Common.DefineConstantValue.ConsumeMoneyFlowType.Recharge_AdvanceMoney.ToString()
).ToList();
if (listAdvance != null && listAdvance.Count > 0)
{
fAdvance = listAdvance.OrderByDescending(x => x.rcr_dRechargeTime).FirstOrDefault().rcr_fRechargeMoney;
}
#endregion
decimal fCurrentBalance = decimal.Zero;
fPreCostRecharge = Math.Abs(fPreCostRecharge);
decimal fSumPreCost = decimal.Zero;//记录欠款总额
//获取本次充值的最后余额
//decimal fCardBalance = listRechargeInserts.Max(x => x.rcr_fBalance);
decimal fCardBalance = listRechargeInserts.OrderByDescending(x => x.rcr_dRechargeTime).FirstOrDefault().rcr_fBalance;
if (fPreCostRecharge >= 0 && listRechargeInserts.Count > 0)//若存在需要支付预付款的金额,则进行平数处理
{
//若预付款还款值大于0,则更新被支付的未结算预付款记录
#region 结算预付款项
List<PreConsumeRecord_pcs> listPreCost = db.PreConsumeRecord_pcs.Where(x =>
x.pcs_lIsSettled == false //需为未支付金额
&& x.pcs_cAccountID == account.cua_cRecordID//需要账户对口
&& x.pcs_cUserID == listRechargeInserts[0].rcr_cUserID //需要对口人员ID
).ToList();
//筛选预付款的消费类型
listPreCost = filterRecord_CanComputePreCost(listPreCost);
fSumPreCost = listPreCost.Sum(x => x.pcs_fCost);
if (Math.Abs(fPreCostRecharge) < Math.Abs(fSumPreCost))
{
rvInfo.messageText = "支付额不足以支付待结算的预付款。";
return rvInfo;
}
List<CardUserAccountDetail_cuad> listPreUserCost = new List<CardUserAccountDetail_cuad>();
示例9: Expression
private static string Expression(List<string> someStrings)
{
var selected = someStrings.OrderByDescending(s => s.Length).FirstOrDefault();
return selected;
}
示例10: getRechargeInfo
/// <summary>
/// 转换充值信息
/// </summary>
/// <param name="listRechargeRecord"></param>
/// <returns></returns>
List<RechargeInfo> getRechargeInfo(List<RechargeRecord_rcr_Info> listRechargeRecord)
{
List<RechargeInfo> listRechargeInfo = null;
try
{
if (listRechargeRecord != null)
{
listRechargeInfo = new List<RechargeInfo>();
listRechargeRecord = listRechargeRecord.OrderByDescending(x => x.rcr_dRechargeTime).ToList();
for (int i = 0; i < listRechargeRecord.Count; i++)
{
try
{
RechargeInfo info = new RechargeInfo();
info.ID = i + 1;
info.RecordID = listRechargeRecord[i].rcr_cRecordID;
info.RechargeType = Common.DefineConstantValue.GetMoneyFlowDesc(listRechargeRecord[i].rcr_cRechargeType);
info.RechargeTime = listRechargeRecord[i].rcr_dRechargeTime;
info.RechargeMoney = listRechargeRecord[i].rcr_fRechargeMoney;
listRechargeInfo.Add(info);
}
catch (Exception exx)
{ base.MessageDialog("提示", exx.Message); }
}
}
}
catch (Exception ex)
{ base.MessageDialog("提示", ex.Message); }
return listRechargeInfo;
}
示例11: GetCustomerRealTimeCommissions
public static IEnumerable<RealTimeCommission> GetCustomerRealTimeCommissions(GetCustomerRealTimeCommissionsRequest request)
{
var results = new List<RealTimeCommission>();
// Get the commission record
var realtimeresponse = Exigo.WebService().GetRealTimeCommissions(new Common.Api.ExigoWebService.GetRealTimeCommissionsRequest
{
CustomerID = request.CustomerID
});
if (realtimeresponse.Commissions.Length == 0) return results;
// Get the unique periods for each of the commission results
var periods = new List<Period>();
var periodRequests = new List<GetPeriodsRequest>();
foreach (var commissionResponse in realtimeresponse.Commissions)
{
var periodID = commissionResponse.PeriodID;
var periodTypeID = commissionResponse.PeriodType;
var req = periodRequests.Where(c => c.PeriodTypeID == periodTypeID).FirstOrDefault();
if (req == null)
{
periodRequests.Add(new GetPeriodsRequest()
{
PeriodTypeID = periodTypeID,
PeriodIDs = new int[] { periodID }
});
}
else
{
var ids = req.PeriodIDs.ToList();
ids.Add(periodID);
req.PeriodIDs = ids.Distinct().ToArray();
}
}
foreach (var req in periodRequests)
{
var responses = GetPeriods(req);
foreach (var response in responses)
{
periods.Add(response);
}
}
// Get the volumes for each unique period
var volumeCollections = new List<VolumeCollection>();
foreach (var period in periods)
{
volumeCollections.Add(GetCustomerVolumes(new GetCustomerVolumesRequest
{
CustomerID = request.CustomerID,
PeriodID = period.PeriodID,
PeriodTypeID = period.PeriodTypeID,
VolumeIDs = request.VolumeIDs
}));
}
// Process each commission response
try
{
foreach (var commission in realtimeresponse.Commissions)
{
var typedCommission = (RealTimeCommission)commission;
typedCommission.Period = periods
.Where(c => c.PeriodTypeID == commission.PeriodType)
.Where(c => c.PeriodID == commission.PeriodID)
.FirstOrDefault();
typedCommission.Volumes = volumeCollections
.Where(c => c.Period.PeriodTypeID == typedCommission.Period.PeriodTypeID)
.Where(c => c.Period.PeriodID == typedCommission.Period.PeriodID)
.FirstOrDefault();
typedCommission.PaidRank = typedCommission.Volumes.PayableAsRank;
results.Add(typedCommission);
}
return results.OrderByDescending(c => c.Period.StartDate);
}
catch { return results; }
}
示例12: 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);
//.........这里部分代码省略.........
示例13: GetPersonListByGroupDepartment
/// <summary>
///
/// </summary>
/// <param name="dids"></param>
/// <param name="gids"></param>
/// <param name="pageSize"></param>
/// <param name="pageIndex"></param>
/// <param name="rowCount"></param>
/// <returns></returns>
protected List<P_PersonInfo> GetPersonListByGroupDepartment(string dids, string gids,out int rowCount, int pageSize=-1,int pageIndex=-1)
{
List<int> list_dids = new List<int>();
List<int> list_gids = new List<int>();
if (dids != "")
{
var list_dids_temp = (from g in dids.Split(',')
where g != ""
select g).ToList();
list_dids_temp.ForEach(g => list_dids.Add(int.Parse(g)));
}
if (gids != "")
{
var list_gids_temp = (from g in gids.Split(',')
where g != ""
select g).ToList();
list_gids_temp.ForEach(g => list_gids.Add(int.Parse(g)));
}
//2 根据department以及group的id查询其对应的Person对象集合
List<P_PersonInfo> list_person = new List<P_PersonInfo>();
var list_department = departmentBLL.GetListByIds(list_dids);
list_department.ForEach(d => list_person.AddRange(d.P_PersonInfo));
var list_group = groupBLL.GetListByIds(list_gids);
list_group.ForEach(g => list_person.AddRange(g.P_PersonInfo));
//3 将联系人集合去重
list_person = list_person.Distinct(new P_PersonEqualCompare()).ToList().Select(p => p.ToMiddleModel()).ToList();
list_person = list_person.OrderByDescending(a => a.isVIP).ToList();
rowCount = list_person.Count();
if (pageIndex != -1 && pageSize != -1)
{
//分页
list_person = list_person.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
}
return list_person;
}
示例14: GetUpperLimit
private static int GetUpperLimit(int size, int[,] matrix)
{
var topElements1 = new List<int>();
for (int i = 0; i < size; i++)
{
int maxx = 0;
for (int j = 0; j < size; j++)
{
if (matrix[j, i] > maxx)
maxx = matrix[j, i];
}
topElements1.Add(maxx);
}
var topElements2 = new List<int>();
for (int i = 0; i < size; i++)
{
int maxx = 0;
for (int j = 0; j < size; j++)
{
if (matrix[i, j] > maxx)
maxx = matrix[i, j];
}
topElements2.Add(maxx);
}
int sumTopElement1 = topElements1.OrderByDescending(x => x).Take(size - 1).Sum();
int sumTopElement2 = topElements2.OrderByDescending(x => x).Take(size - 1).Sum();
int sumTopElement = Math.Min(sumTopElement1, sumTopElement2);
return sumTopElement;
}
示例15: GetProfileMachineHaltRecord
/// <summary>
/// 獲取顯示用的停機記錄列表,並返回停機時長
/// </summary>
/// <param name="listMacHaltRecord">停機記錄列表</param>
/// <param name="tsTotal">停機時長</param>
/// <returns>顯示用的停機記錄列表</returns>
public override List<ProjectMachineHaltRecordShow> GetProfileMachineHaltRecord(List<ProjectMachineHaltRecord> listMacHaltRecord, out TimeSpan tsTotal)
{
tsTotal = new TimeSpan();
if (listMacHaltRecord == null)
{
return null;
}
listMacHaltRecord = listMacHaltRecord.OrderByDescending(x => x.psrd_dBeginTime).ToList();
List<ProjectMachineHaltRecordShow> listHaltShow = new List<ProjectMachineHaltRecordShow>();
int iRecIndex = 0;
foreach (ProjectMachineHaltRecord itemHalt in listMacHaltRecord)
{
if (itemHalt != null)
{
ProjectMachineHaltRecordShow itemHaltShow = new ProjectMachineHaltRecordShow(itemHalt);
if (itemHaltShow.MacHaltTimeSpan != null)
{
tsTotal += itemHaltShow.MacHaltTimeSpan.Value;
}
if (itemHaltShow.StopReasons != null && base.MachineHaltReasons != null)
{
int iReasonIndex = 0;
foreach (ProjectMachineHaltRecordReason itemReason in itemHaltShow.StopReasons)
{
ProjectBaseItemModel reasonBase = base.MachineHaltReasons.Where(x => x.Code.Trim() == itemReason.StopReasonID.ToString()).FirstOrDefault();
if (reasonBase != null)
{
itemHaltShow.MacHaltItemsDesc += (iReasonIndex + 1).ToString() + "." + reasonBase.Description + ";";
iReasonIndex++;
}
}
}
itemHaltShow.RecordIndex = iRecIndex + 1;
iRecIndex++;
listHaltShow.Add(itemHaltShow);
}
}
return listHaltShow;
}