Pavel Tupitsyn created IGNITE-13336:
---------------------------------------

             Summary: .NET: Misleading LINQ exception when expression can't be 
translated
                 Key: IGNITE-13336
                 URL: https://issues.apache.org/jira/browse/IGNITE-13336
             Project: Ignite
          Issue Type: Bug
          Components: platforms
    Affects Versions: 2.8.1
            Reporter: Pavel Tupitsyn
            Assignee: Pavel Tupitsyn
             Fix For: 2.10


The following program results in a cryptic exception, when the problem is 
simply lack of Expression<> wrapper around the query filter:

{code}
    class Program
    {
        private static readonly IIgnite Ignite = Ignition.Start();

        static void Main(string[] args)
        {
            var cache = GetCache<Foo>();

            cache["1"] = new Foo();

            var res = Where2<Foo>(e => e.Value.X == 0);

            Console.WriteLine(res);
        }

        public static ICache<string, T> GetCache<T>()
        {
            var cacheName = typeof(T).Name;
            var cfg = new CacheConfiguration(cacheName, new 
QueryEntity(typeof(T)));

            return Ignite.GetOrCreateCache<string, T>(cfg);
        }

        public static List<T> Where2<T>(Expression<Func<ICacheEntry<string, T>, 
bool>> query)
        {
            var queryResult = GetCache<T>().AsCacheQueryable().Where(query);

            return queryResult.Select(x => x.Value).ToList();
        }
    }

    public class Foo
    {
        [QuerySqlField] public int X { get; set; }
    }
{code}

We should throw a better exception that says "LINQ expression can't be 
translated to SQL because of ..."



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to