You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Pavel Tupitsyn (Jira)" <ji...@apache.org> on 2020/11/19 19:27:00 UTC

[jira] [Updated] (IGNITE-13336) .NET: Misleading LINQ exception when expression can't be translated

     [ https://issues.apache.org/jira/browse/IGNITE-13336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pavel Tupitsyn updated IGNITE-13336:
------------------------------------
    Release Note: .NET: Fix misleading exception when LINQ expression can't be translated to SQL

> .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: Sergey Stronchinskiy
>            Priority: Minor
>              Labels: .NET
>             Fix For: 2.10
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> 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>(Func<ICacheEntry<string, T>, bool> query)
>         {
>             var queryResult = GetCache<T>().AsCacheQueryable().Where(x => query(x));
>             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)