当前位置: 首页>>代码示例>>C#>>正文


C# List.OrderByDescending方法代码示例

本文整理汇总了C#中Model.List.OrderByDescending方法的典型用法代码示例。如果您正苦于以下问题:C# List.OrderByDescending方法的具体用法?C# List.OrderByDescending怎么用?C# List.OrderByDescending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model.List的用法示例。


在下文中一共展示了List.OrderByDescending方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load_othernews

        // Load other news
        public List<News_details_entity> Load_othernews(string _sNews_Seo_Url)
        {
            try
            {
                List<News_details_entity> l = new List<News_details_entity>();
                if (_sNews_Seo_Url != "")
                {
                    var s = (from c in db.ESHOP_NEWS_CATs
                             join a in db.ESHOP_NEWs on c.NEWS_ID equals a.NEWS_ID
                             join b in db.ESHOP_CATEGORies on c.CAT_ID equals b.CAT_ID
                             where a.NEWS_SEO_URL == _sNews_Seo_Url
                             select new { b.CAT_ID}).ToList();
                    var _tinTucKhac = (from c in db.ESHOP_NEWS_CATs
                                       join a in db.ESHOP_NEWs on c.NEWS_ID equals a.NEWS_ID
                                       join b in db.ESHOP_CATEGORies on c.CAT_ID equals b.CAT_ID
                                       where a.NEWS_SEO_URL != _sNews_Seo_Url && b.CAT_ID == s[0].CAT_ID
                                       select new { a.NEWS_ID, a.NEWS_TITLE, a.NEWS_IMAGE3, a.NEWS_PRICE1, a.NEWS_DESC, a.NEWS_SEO_URL, a.NEWS_URL, a.NEWS_ORDER, a.NEWS_ORDER_PERIOD, a.NEWS_PUBLISHDATE, c.ESHOP_CATEGORy.CAT_SEO_URL }).OrderByDescending(n => n.NEWS_PUBLISHDATE).Take(99).Distinct();
                    if (_tinTucKhac.ToList().Count > 0)
                    {
                        foreach (var i in _tinTucKhac)
                        {
                            News_details_entity pro = new News_details_entity();
                            pro.NEWS_ID = i.NEWS_ID;
                            pro.NEWS_TITLE = i.NEWS_TITLE;
                            pro.NEWS_IMAGE3 = i.NEWS_IMAGE3;
                            pro.NEWS_DESC = i.NEWS_DESC;
                            pro.NEWS_SEO_URL = i.NEWS_SEO_URL;
                            pro.NEWS_URL = i.NEWS_URL;
                            pro.NEWS_ORDER = Utils.CIntDef(i.NEWS_ORDER);
                            pro.NEWS_ORDER_PERIOD = Utils.CIntDef(i.NEWS_ORDER_PERIOD);
                            pro.NEWS_PUBLISHDATE = Utils.CDateDef(i.NEWS_PUBLISHDATE, DateTime.Now);
                            pro.CAT_SEO_URL = i.CAT_SEO_URL;
                            l.Add(pro);
                        }
                    }
                  
                }
                return l.OrderByDescending(n => n.NEWS_PUBLISHDATE).ToList();
               
            }
            catch (Exception ex)
            {

                clsVproErrorHandler.HandlerError(ex);
                return null;
            }
        }
开发者ID:htphongqn,项目名称:nidushealth.com,代码行数:48,代码来源:News_details.cs

示例2: ListActivities


//.........这里部分代码省略.........
                }
                // Determine Activity Types to filter
                if (FilterActivityExercise)
                    loActivityType |= MSHealthActivityType.FreePlay;
                if (FilterActivityRun)
                    loActivityType |= MSHealthActivityType.Run;
                if (FilterActivityBike)
                    loActivityType |= MSHealthActivityType.Bike;
                if (FilterActivityGolf)
                    loActivityType |= MSHealthActivityType.Golf;
                if (FilterActivitySleep)
                    loActivityType |= MSHealthActivityType.Sleep;
                if (FilterActivityGuided)
                    loActivityType |= MSHealthActivityType.GuidedWorkout;
                if (FilterActivityHike)
                    loActivityType |= MSHealthActivityType.Hike;
                // Determine Period to filter
                switch (Settings.MSHealthFilterPeriod)
                {
                    case Settings.PERIOD_DAY:
                        ldtEnd = DateTime.Today.AddDays(1).AddMilliseconds(-1);
                        ldtStart = DateTime.Today.AddDays(-1);
                        break;
                    case Settings.PERIOD_WEEK:
                        ldtEnd = DateTime.Today.AddDays(1).AddMilliseconds(-1);
                        ldtStart = DateTime.Today.AddDays(-7);
                        break;
                    case Settings.PERIOD_MONTH:
                        ldtEnd = DateTime.Today.AddDays(1).AddMilliseconds(-1);
                        ldtStart = DateTime.Today.AddMonths(-1);
                        break;
                    case Settings.PERIOD_YEAR:
                        ldtEnd = DateTime.Today.AddDays(1).AddMilliseconds(-1);
                        ldtStart = DateTime.Today.AddYears(-1);
                        break;
                }
                // Determine Distance Unit to retrieve
                switch (Settings.MSHealthFilterDistance)
                {
                    case DistanceUnit.DISTANCE_MILE:
                        loDistance = MSHealthSplitDistanceType.Mile;
                        break;
                    case DistanceUnit.DISTANCE_KILOMETER:
                        loDistance = MSHealthSplitDistanceType.Kilometer;
                        break;
                }
                // Find activities with selected criteria, and update MSHealth Token
                MSHealthActivities loActivities = await moMSHealthClient.ListActivities(startTime: ldtStart,
                                                                                        endTime: ldtEnd,
                                                                                        type: loActivityType,
                                                                                        splitDistanceType: loDistance);
                Settings.MSHealthToken = moMSHealthClient.Token;
                // Parse each separated activity list into one single activity list
                List<MSHealthActivity> loActivitiesList = new List<MSHealthActivity>();
                if (loActivities.BikeActivities != null &&
                    loActivities.BikeActivities.Any())
                    loActivitiesList.AddRange(loActivities.BikeActivities);
                if (loActivities.RunActivities != null &&
                    loActivities.RunActivities.Any())
                    loActivitiesList.AddRange(loActivities.RunActivities);
                if (loActivities.SleepActivities != null &&
                    loActivities.SleepActivities.Any())
                    loActivitiesList.AddRange(loActivities.SleepActivities);
                if (loActivities.FreePlayActivities != null &&
                    loActivities.FreePlayActivities.Any())
                    loActivitiesList.AddRange(loActivities.FreePlayActivities);
                if (loActivities.GolfActivities != null &&
                    loActivities.GolfActivities.Any())
                    loActivitiesList.AddRange(loActivities.GolfActivities);
                if (loActivities.GuidedWorkoutActivities != null &&
                    loActivities.GuidedWorkoutActivities.Any())
                    loActivitiesList.AddRange(loActivities.GuidedWorkoutActivities);
                if (loActivities.HikeActivities != null &&
                    loActivities.HikeActivities.Any())
                    loActivitiesList.AddRange(loActivities.HikeActivities);
                // Sort descending by Start Time and append to Bindable property
                loActivitiesList = loActivitiesList.OrderByDescending(loAct => loAct.StartTime).ToList();
                Activities = new ObservableCollection<MSHealthActivity>(loActivitiesList);
            }
            catch (Exception loException)
            {
                // Handle exceptions (just for debugging purposes). TODO: Delete this code
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    System.Diagnostics.Debug.WriteLine(loException.StackTrace);
                    System.Diagnostics.Debugger.Break();
                } // Handle exceptions (just for debugging purposes)
                  // Show error message
#if WINDOWS_UWP
                await moDialogService.ShowError(Resources.Strings.MessageContentErrorOperation,
                                                Resources.Strings.MessageTitleError,
                                                Resources.Strings.MessageButtonOK,
                                                null);
#endif
            }
            finally
            {
                IsRunningRequest = false;
            }
        }
开发者ID:yorchideas,项目名称:XportBand,代码行数:101,代码来源:MainViewModel.cs

示例3: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Session[Settings.Default.FlashSessionKey] != null)
            {
                this.FlashLiteralWrapper.Visible = true;
                this.FlashLiteral.Text = this.Session[Settings.Default.FlashSessionKey].ToString();
                this.Session[Settings.Default.FlashSessionKey] = null;
            }
            else
            {
                this.FlashLiteralWrapper.Visible = false;
            }

            this._petIdString = this.Request.QueryString["petid"];

            if (String.IsNullOrEmpty(this._petIdString))
            {
                this.StatsLiteral.Text = "Add a New Pet";
                this.SaveStatsButton.Text = "Save New Pet";
            }
            else
            {
                this.PhotoPanel.Visible = true;
            }

            this._userBucketName = String.Format(Settings.Default.BucketNameFormat, this.Context.User.Identity.Name, this._petIdString);
            this._itemName = this._petIdString ?? Guid.NewGuid().ToString();
            this._domainName = String.Format(Settings.Default.SimpleDbDomainNameFormat, this.Context.User.Identity.Name);

            if (!this.Page.IsPostBack)
            {
                List<int> years = new List<int>(100);
                for (int i = 0; i < 100; i++)
                {
                    years.Add(DateTime.Now.AddYears(i * -1).Year);
                }
                this.YearDropDownList.DataSource = years.OrderByDescending(y => y);
                this.YearDropDownList.DataBind();
                this.SelectMonth();
                this.SelectDay();

                Pet pet = default(Pet);
                List<string> files = new List<string>();
                if (!String.IsNullOrEmpty(this._petIdString))
                {
                    //
                    // Try to get the requested pet from the user's private domain
                    //
                    DomainHelper.CheckForDomain(this._domainName, _simpleDBClient);

                    GetAttributesRequest getAttributeRequest = new GetAttributesRequest()
                        .WithDomainName(this._domainName)
                        .WithItemName(this._itemName);
                    GetAttributesResponse getAttributeResponse = _simpleDBClient.GetAttributes(getAttributeRequest);
                    List<Attribute> attrs = null;
                    bool showPublic = false;

                    if (getAttributeResponse.IsSetGetAttributesResult())
                    {
                        attrs = getAttributeResponse.GetAttributesResult.Attribute;

                        showPublic = false;

                        //
                        // If we can't find it try the public domain
                        //
                        if (attrs.Count == 0)
                        {
                            showPublic = true;
                        }
                    }

                    if (showPublic)
                    {
                        Response.Redirect(String.Concat("PetProfile.aspx?petid", _petIdString));
                        return;
                    }

                    pet = new Pet
                    {
                        Name = attrs.First(a => a.Name == "Name").Value,
                        Birthdate = attrs.First(a => a.Name == "Birthdate").Value,
                        Sex = attrs.First(a => a.Name == "Sex").Value,
                        Type = attrs.First(a => a.Name == "Type").Value,
                        Breed = attrs.First(a => a.Name == "Breed").Value,
                        Likes = attrs.First(a => a.Name == "Likes").Value,
                        Dislikes = attrs.First(a => a.Name == "Dislikes").Value
                    };

                    this.Public.Checked = bool.Parse(attrs.First(a => a.Name == "Public").Value);

                    using (AmazonS3Client s3Client = new AmazonS3Client(Settings.Default.AWSAccessKey.Trim(), Settings.Default.AWSSecretAccessKey.Trim()))
                    {
                        BucketHelper.CheckForBucket(this._petIdString, s3Client);
                        ListObjectsRequest listObjectsRequest = new ListObjectsRequest()
                            .WithBucketName(this._userBucketName);
                        using (ListObjectsResponse listObjectsResponse = s3Client.ListObjects(listObjectsRequest))
                        {
                            files = listObjectsResponse.S3Objects.Select(o => String.Format(Settings.Default.S3BucketUrlFormat, this._userBucketName, o.Key)).ToList();
                            string firstPhoto = files.FirstOrDefault();
//.........这里部分代码省略.........
开发者ID:ksikes,项目名称:Amazon.Powershell,代码行数:101,代码来源:PetDetails.aspx.cs


注:本文中的Model.List.OrderByDescending方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。