0

我原来的问题可以在这里找到: RavenDB 索引查询问题

我现在使用以下索引得到了很好的效果:

public class JobsQueuedListCurrent : AbstractIndexCreationTask<AppointmentReminder, JobsQueuedListCurrent.IndexResult>
{
    public class IndexResult
    {
        public int Id { get; set; }
        public DateTime AppointmentDateTime { get; set; }
        public ReminderStatus ReminderStatus { get; set; }
        public DateTime JobDateTime { get; set; }
        public JobStatus JobStatus { get; set; }
    }

    public JobsQueuedListCurrent()
    {


        Map = appointmentreminders => from appointmentreminder in appointmentreminders
                                      from job in appointmentreminder.NotificationJobs
                                      where (appointmentreminder.ReminderStatus != ReminderStatus.Confirmed)

                                      select new 
                                      { 
                                          Id = appointmentreminder.Id, 
                                          AppointmentDateTime = appointmentreminder.AppointmentDateTime,
                                          ReminderStatus = appointmentreminder.ReminderStatus,
                                          JobDateTime = appointmentreminder.AppointmentDateTime.AddDays(job.DaysOffset),
                                          JobStatus = job.JobStatus
                                      };

        Store(x => x.AppointmentDateTime, FieldStorage.Yes);
        Store(x => x.ReminderStatus, FieldStorage.Yes);
        Store(x => x.JobDateTime, FieldStorage.Yes);
        Store(x => x.JobStatus, FieldStorage.Yes);

    }
}

我将代码从本地机器移到 AppHarbor 和 RavenHQ。我现在可以在 Appharbor 和 RavenHQ 中连接和查询普通数据。我的控制器看起来像:

public ActionResult GetJobsQueuedListCurrent()
    {
        var jobsqueuedlist = RavenSession.Query<JobsQueuedListCurrent.IndexResult, JobsQueuedListCurrent>()
            .OrderBy(x => x.AppointmentDateTime)
            .As<AppointmentReminder>()
            .Take(20)
            .ToList();

        return View("List", jobsqueuedlist);

    }

当我添加以下 where 子句时,效果很好:

.Where(x => (x.JobDateTime <= DateTime.Now))

使控制器看起来像:

public ActionResult GetJobsQueuedListCurrent()
    {
        var jobsqueuedlist = RavenSession.Query<JobsQueuedListCurrent.IndexResult, JobsQueuedListCurrent>()
            .Where(x => (x.JobDateTime <= DateTime.Now))
            .OrderBy(x => x.AppointmentDateTime)
            .As<AppointmentReminder>()
            .Take(20)
            .ToList();

        return View("List", jobsqueuedlist);

    }

现在这会导致错误 (500):内部服务器错误,输出的 pastebin 链接如下:

巴斯宾

我可以做些什么来允许查询在 Where 子句中使用日期时间?顺便说一句,我在我的客户端上使用最新的不稳定 (1.2.2139-Unstable) 与 RavenHQ 交谈。谢谢。

4

1 回答 1

0

您正在使用 1.2 客户端与 1.0 服务器通信。

于 2012-11-11T09:18:14.540 回答