我最初的问题可以在这里找到:RavenDB Index Query Question
我现在使用下面的索引得到了很好的效果:
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子句中使用datetime?顺便说一句,我在我的客户端上使用最新的不稳定(1.2.2139-不稳定)来与RavenHQ交谈。谢谢。
发布于 2012-11-11 17:18:15
您正在使用1.2客户端与1.0服务器通信。
https://stackoverflow.com/questions/13328167
复制相似问题