[TestFixture]public class IndexTest : RavenTestBase{ [Test] public void CanWaitForIndex() { var documentStore = NewDocumentStore(true); documentStore.ExecuteIndex(new TestIndex()); documentStore.Initialize();
using (var session = documentStore.OpenSession()) { session.Store(new Entity { Id = "Entity/1", Test = "A", Properties = new List<PropertyClass> { new PropertyClass { Property = "Property1" } } }); session.SaveChanges(); }
using (var session = documentStore.OpenSession()) { var results = session.Query<TestIndex.Result, TestIndex>() .Customize(c => c.WaitForNonStaleResults()) .ProjectFromIndexFieldsInto<TestIndex.Result>() .ToList();
var errors = documentStore.DatabaseCommands.GetStatistics().Errors;
errors.Should().BeEmpty();
results.Should().HaveCount(1); } }}
public class Entity{ public string Id { get; set; } public string Test { get; set; } public List<PropertyClass> Properties { get; set; }}
public class PropertyClass{ public string Property { get; set; }}
public class TestIndex : AbstractIndexCreationTask<Entity, TestIndex.Result>{ public class Result { public string Test { get; set; } public List<PropertyClass> Properties { get; set; } }
public TestIndex() { Map = entities => from entity in entities let properties = entity.Test == "B" ? entity.Properties.Take(1) : new PropertyClass[0] select new { Test = entity.Test, Properites = from property in properties select new { Property = property.Property + "Test" } };
StoreAllFields(FieldStorage.Yes); }}
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hibernating Rhinos Ltd
Oren Eini l CEO l Mobile: + 972-52-548-6969
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811
Thanks for the workaround. Unfortunately, my posted example is highly simplified, the real production code is much more complex and not easy possible without a "let".
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
Map = entities => from entity in entities let properties = entity.Test == "B" ? entity.Properties.Take(1) : new PropertyClass[0] select new { Test = entity.Test,
Properites = from property in (IEnumerable<PropertyClass>)properties
select new { Property = property.Property + "Test" } };
Workaround can be to cast it explicitly to IEnumerable.
Hibernating Rhinos Ltd
Oren Eini l CEO l Mobile: + 972-52-548-6969
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811
On Thu, Jun 21, 2018 at 6:52 PM, Peter Balzli <elias....@gmail.com> wrote:
Thanks for the workaround. Unfortunately, my posted example is highly simplified, the real production code is much more complex and not easy possible without a "let".
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
Map = entities => from entity in entities let properties = entity.Test == "B" ? entity.Properties.Take(1) :
new PropertyClass[0].Concat(new PropertyClass[0])
select new { Test = entity.Test,
Properites = from property in properties
select new { Property = property.Property + "Test" } };
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.