を使用して RavenDB からクエリを実行するのに問題があり[JsonProperty]
ます。
次のテストは機能しません。
(注:新しい名前空間を使用していることは承知していますRaven.Imports.Newtonsoft.Json
):
using System.Linq;
using NUnit.Framework;
using Raven.Client.Embedded;
using Raven.Imports.Newtonsoft.Json;
namespace RavenTest
{
[TestFixture]
public class RavenFixture
{
protected EmbeddableDocumentStore DocumentStore;
[SetUp]
public void BaseSetUp()
{
DocumentStore = new EmbeddableDocumentStore { RunInMemory = true };
DocumentStore.Initialize();
}
[Test]
public void Test()
{
using (var session = DocumentStore.OpenSession())
{
session.Store(new Parent {Inner = new Child {Num = 1}});
session.SaveChanges();
}
using (var session = DocumentStore.OpenSession())
{
var list = session.Query<Parent>().Customize(x => x.WaitForNonStaleResultsAsOfNow())
.Where(x => x.Inner.Num == 1)
.ToList();
Assert.That(list.Count, Is.EqualTo(1));
}
}
public class Parent
{
public string Id { get; set; }
//If you comment this out, it will work
[JsonProperty("N")]
public Child Inner { get; set; }
}
public class Child
{
[JsonProperty("M")]
public int Num { get; set; }
}
}
}
ただし、行をコメントアウトすると、[JsonProperty("N")]
期待どおりに機能します。
これはバグですか、それとも何か間違っていますか?
RavenDB 2.5.0.0 (最新) を使用しています