You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Alexandr Shapkin <le...@gmail.com> on 2019/07/12 16:07:14 UTC

RE: Error compiling query: entire LINQ expression should be specifiedwithin lambda passed to Compile method. Part of the query can't be outsidethe Compile method call.

Hi, Siva!

Can you share a simple example of that?


From: siva
Sent: Friday, July 12, 2019 3:43 PM
To: user@ignite.apache.org
Subject: Error compiling query: entire LINQ expression should be specifiedwithin lambda passed to Compile method. Part of the query can't be outsidethe Compile method call.

Hi,

I am trying to use Linq compiled queries on top of caches.

Getting  excepted  result  when i  pass int values to the complie query
arguments.

when when i pass string and  and using in where cluse getting following
exceotion 
*
Error compiling query: entire LINQ expression should be specified within
lambda passed to Compile method. Part of the query can't be outside the
Compile method call.*





Can you tell where i am missing



Thanks
siva










--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Error compiling query: entire LINQ expression should bespecifiedwithin lambda passed to Compile method. Part of the query can't beoutsidethe Compile method call.

Posted by siva <si...@bizruntime.com>.
Hi, 

when i tried with DateTime type using where clause, then also getting the
following 
exception 

Method not supported: System.DateTime.(Int32 CompareTo(System.DateTime))

var compileQuery = CompiledQuery.Compile((DateTime tempDate) =>
cache1.Where(data => (data.Value.CreatedDateTime.CompareTo(prodDate)) ==
0));

Please suggest if any other way to query with DateTime type.

Thanks 
siva 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

RE: Error compiling query: entire LINQ expression shouldbespecifiedwithin lambda passed to Compile method. Part of the query can'tbeoutsidethe Compile method call.

Posted by Alexandr Shapkin <le...@gmail.com>.
Hello Siva,

DateTime is a struct and thus should work the expected way.

Please, make sure, that you re-created your cache after some development modifications.

I checked this with the following example from your sources:

public class Employee
    {
        …
        [QuerySqlField]
        public DateTime? DateTime { get; set; }
    }


Func<DateTime, IQueryCursor<ICacheEntry<string, Employee>>> issueqry =
                    CompiledQuery.Compile((DateTime dt) => queryable.Where(emp => emp.Value.DateTime < dt));

   foreach (var entry in issueqry(DateTime.UtcNow))
                    Console.WriteLine(">>>    " + entry.Value.Name);



From: siva
Sent: Tuesday, July 30, 2019 10:43 AM
To: user@ignite.apache.org
Subject: Re: Error compiling query: entire LINQ expression shouldbespecifiedwithin lambda passed to Compile method. Part of the query can'tbeoutsidethe Compile method call.


Hi, 

when i tried with DateTime type using where clause, then also getting the
following 
exception 

*Method not supported: System.DateTime.(Int32 CompareTo(System.DateTime))
*


Please suggest if any other way to query with DateTime type.

Thanks 
siva 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Error compiling query: entire LINQ expression should bespecifiedwithin lambda passed to Compile method. Part of the query can't beoutsidethe Compile method call.

Posted by siva <si...@bizruntime.com>.
Hi, 

when i tried with DateTime type using where clause, then also getting the
following 
exception 

*Method not supported: System.DateTime.(Int32 CompareTo(System.DateTime))
*


Please suggest if any other way to query with DateTime type.

Thanks 
siva 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Error compiling query: entire LINQ expression should bespecifiedwithin lambda passed to Compile method. Part of the query can't beoutsidethe Compile method call.

Posted by Pavel Tupitsyn <pt...@apache.org>.
I've got to the bottom of this, it is indeed a bug [1]

The workaround is to use a different overload [2], this works:

CompiledQueryFunc<ICacheEntry<string, Employee>> issueqry =
    CompiledQuery.Compile(queryable.Where(emp => emp.Value.Name ==
"unused_value"));

foreach (var entry in issueqry("abc"))
    Console.WriteLine(">>>    " + entry.Value.Name);


[1] https://issues.apache.org/jira/browse/IGNITE-11985
[2]
https://ignite.apache.org/releases/latest/dotnetdoc/api/Apache.Ignite.Linq.CompiledQuery.html#Apache_Ignite_Linq_CompiledQuery_Compile__1_System_Linq_IQueryable___0__

On Mon, Jul 15, 2019 at 8:04 PM Alexandr Shapkin <le...@gmail.com> wrote:

> Hi!
>
>
>
> As I understand correctly, right now CompiledQuery won’t work if there is
> a non-primitive value inside the WHERE clause.
>
>
>
> This seems like a bug for me, because it’s pretty common to treat String
> class as a primitive one.
>
> Right now you can rewrite your query to “x.Contains(y)” or
> “x.StartsWith(y)”, but it’s not the same as Equals.
>
>
>
> *From: *siva <si...@bizruntime.com>
> *Sent: *Friday, July 12, 2019 9:36 PM
> *To: *user@ignite.apache.org
> *Subject: *RE: Error compiling query: entire LINQ expression should
> bespecifiedwithin lambda passed to Compile method. Part of the query can't
> beoutsidethe Compile method call.
>
>
>
> Hi ,
>
>
>
>
>
> Thanks for reply
>
>
>
>
>
> i have attached sample code  git hub link.please verify it .
>
>
>
>
>
>
>
>
>
>
>
>
>
> Thanks
>
> siva https://github.com/cvakarna/ApacheIgnite/blob/master/Program.cs
>
> <https://github.com/cvakarna/ApacheIgnite/blob/master/Program.cs>
>
>
>
>
>
>
>
> --
>
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
>
>

RE: Error compiling query: entire LINQ expression should bespecifiedwithin lambda passed to Compile method. Part of the query can't beoutsidethe Compile method call.

Posted by Alexandr Shapkin <le...@gmail.com>.
Hi!

As I understand correctly, right now CompiledQuery won’t work if there is a non-primitive value inside the WHERE clause.

This seems like a bug for me, because it’s pretty common to treat String class as a primitive one.
Right now you can rewrite your query to “x.Contains(y)” or “x.StartsWith(y)”, but it’s not the same as Equals.
 

From: siva
Sent: Friday, July 12, 2019 9:36 PM
To: user@ignite.apache.org
Subject: RE: Error compiling query: entire LINQ expression should bespecifiedwithin lambda passed to Compile method. Part of the query can't beoutsidethe Compile method call.

Hi ,


Thanks for reply 


i have attached sample code  git hub link.please verify it .






Thanks 
siva https://github.com/cvakarna/ApacheIgnite/blob/master/Program.cs
<https://github.com/cvakarna/ApacheIgnite/blob/master/Program.cs>  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


RE: Error compiling query: entire LINQ expression should be specifiedwithin lambda passed to Compile method. Part of the query can't be outsidethe Compile method call.

Posted by siva <si...@bizruntime.com>.
Hi ,


Thanks for reply 


i have attached sample code  git hub link.please verify it .






Thanks 
siva https://github.com/cvakarna/ApacheIgnite/blob/master/Program.cs
<https://github.com/cvakarna/ApacheIgnite/blob/master/Program.cs>  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/