Performance / unable to build query

Oct 2, 2015 at 10:57 PM
The performance of this relatively simple example seems to be terrible, it is related to the where clause n.MyData="hello1" is fine, but n.MyData==name ends up throwing lots of exceptions in the debug output and the performance dives. Looking into it deeper it seems to be a problem build the query Visit(b.Right) ends up calling StartsWithParameterReference which returns false
and ends up calling CannotConvertToSoda(). b is in fact a MemberAccess going to a Constant.

Converting in manually to SODA is much much faster
var q = x.Query<Data>();
q.Descend("MyData").Constrain(name).Equal();
var t = q.Execute<Data>();
Can anyone shed any light on how to resolve this? Is the LINQ provider known to be very slow?
using NDatabase;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace NDatabaseTest
{
    class Program
    {
        class Data
        {
            public string MyData;
        }
        static void Main(string[] args)
        {
            if (File.Exists("temp.db"))
                File.Delete("temp.db");
            Stopwatch sw = new Stopwatch();
            sw.Start();
            using (var x = OdbFactory.Open("temp.db"))
            {
                x.IndexManagerFor<Data>().AddIndexOn("Idx1", nameof(Data.MyData));
                for (int i = 0; i < 1000; ++i)
                {
                    string name = "Hello" + i.ToString();
                    var t = (from n in x.AsQueryable<Data>() where n.MyData == name select n).FirstOrDefault();
                    if (t == null)
                        x.Store(new Data() { MyData = name });
                }
            }
            sw.Stop();
            Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
                      

            File.Delete("temp.db");
            Console.ReadLine();

        }
    }
}