简体   繁体   English

SQL Compact Server 3.5 Orderby语句-Windows Phone

[英]SQL Compact Server 3.5 orderby statement - windows phone

I am trying to output all the information from the database. 我正在尝试从数据库中输出所有信息。 From my code, it works. 根据我的代码,它可以工作。 But it actually output everything. 但是它实际上输出了所有内容。 I would like to order it by dates. 我想按日期订购。 How can I do that. 我怎样才能做到这一点。 Below is my code: 下面是我的代码:

protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        if (!App.ViewModel.IsDataLoaded)
        {
            App.ViewModel.LoadData();
        }

        using (DatabaseContext c = new DatabaseContext(DatabaseContext.ConnectionString))
        {
            //c.CreateIfNotExists();
            if (!c.DatabaseExists())
            {
                c.CreateDatabase();
            }

            c.LogDebug = true;
            //output todolist data from database

            try
            {
                MLongListSelector.ItemsSource = c.ToDoList.ToList();
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Source + ":" + exc.Message);
            }



        }
    }
var result = c.ToDoList.OrderBy(datefilter => datefilter.Date).ToList(); 

To Order by today's current date and time, 要在今天的当前日期和时间订购,

DateTime today = DateTime.Today;
var result1 =  c.ToDoList().Where(test => test.Date.Date == today).OrderByDescending(t=>t.Date).ToList();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM