You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Sergey Stronchinskiy (Jira)" <ji...@apache.org> on 2020/10/02 15:00:00 UTC
[jira] [Assigned] (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 ]
Sergey Stronchinskiy reassigned IGNITE-13336:
---------------------------------------------
Assignee: Sergey Stronchinskiy (was: Pavel Tupitsyn)
> .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
>
>
> 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)