0
你好誰能回答我爲什麼這個linq查詢不會按日期返回?Raven Db詢問日期
DocumentStore store = new DocumentStore { Url = "http://localhost:8080/" };
store.Initialize();
using (var session = store.OpenSession())
{
bool carExists = session.Query<Car>().Any(c => c.CarId == 1);
if (!carExists)
{
Car myNewCar = new Car
{
CarId = 1,
ManufactureDate = new DateTime(2010, 1, 1),
Name = "Porshe"
};
session.Store(myNewCar);
session.SaveChanges();
}
IQueryable<Car> cars = session.Query<Car>()
.Where(c => c.ManufactureDate == new DateTime(2010, 1, 1));
foreach (var car in cars)
{
Console.WriteLine(car.Name);
}
Console.ReadKey();
}
感謝您的回答,但它不會在第二次運行時陳舊,我得到相同的結果。但是,如果更改LINQ查詢通過ID查詢我得到一個結果。我正在尋找爲什麼日期不返回結果的答案? – Mantisimo
我的不好。應該是!=在carExists檢查。示例已更新。運行它 - 它的工作。 –