'System.Array' does not contain a definition for 'Select'

156 views
Skip to first unread message

Peter Balzli

unread,
Jun 21, 2018, 8:24:00 AM6/21/18
to RavenDB - 2nd generation document database
Hi

The following unit test fails cause of indexing errors: 'System.Array' does not contain a definition for 'Select'.

This looks like a bug for me. RavenDb Version: 3.5.7-patch-35266.


[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);
    }
}


Arkadiusz Palinski

unread,
Jun 21, 2018, 9:35:52 AM6/21/18
to rav...@googlegroups.com
Hi,

It seems `let` is causing an issue. You can workaround by getting rid of it from the index definition:

Map = entities => from entity in entities
                select new
                {
                    Test = entity.Test,
                    Properites = from property in entity.Test == "B" ?

                            entity.Properties.Take(1) :
                            new PropertyClass[0]
                        select new
                        {
                            Property = property.Property + "Test"
                        }
                };
--
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.

Peter Balzli

unread,
Jun 21, 2018, 11:52:52 AM6/21/18
to RavenDB - 2nd generation document database
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".

Oren Eini (Ayende Rahien)

unread,
Jun 21, 2018, 1:23:00 PM6/21/18
to ravendb
Workaround can be to cast it explicitly to IEnumerable.

Hibernating Rhinos Ltd  

Oren Eini l CEO 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+unsubscribe@googlegroups.com.

Peter Balzli

unread,
Jun 22, 2018, 2:59:34 AM6/22/18
to RavenDB - 2nd generation document database
Can you explain that more detailed?

Changing the index to the following does not solve the problem (still same error). Shouldn't this problem be solved by RavenDb rather than ugly workarounds?

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"
                                   }
                  };

Am Donnerstag, 21. Juni 2018 19:23:00 UTC+2 schrieb Oren Eini:
Workaround can be to cast it explicitly to IEnumerable.

Hibernating Rhinos Ltd  

Oren Eini l CEO 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.

Oren Eini (Ayende Rahien)

unread,
Jun 22, 2018, 3:31:24 AM6/22/18
to ravendb
Oh, we are going to be looking at this, see here: http://issues.hibernatingrhinos.com/issue/RavenDB-11401

I'm trying to suggest workaround for now.

Also, try use IEnumerable, not IEnumerable<T>.
If this doesn't work, please post the full error.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Peter Balzli

unread,
Jun 22, 2018, 3:56:55 AM6/22/18
to RavenDB - 2nd generation document database
OK thank you.

For now, the following is working:

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"
                                   }
                  };

Peter Balzli

unread,
Jun 28, 2018, 3:36:41 AM6/28/18
to RavenDB - 2nd generation document database
As I see in the issue tracker you fixed it in the 4.0 branch, did you also fix it in the 3.5 branch?

Oren Eini (Ayende Rahien)

unread,
Jun 28, 2018, 4:39:18 AM6/28/18
to ravendb
Given the workaround, we don't plan to do that there. 
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages