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.

classic Classic list List threaded Threaded
7 messages Options
siva siva
Reply | Threaded
Open this post in threaded view
|

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.

This post was updated on .
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
exception

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.




var compiledQuery = CompiledQuery.Compile((int age) => queryable.Where(emp => emp.Value.Age > age));

var compileQuery = CompiledQuery.Compile((string name) => queryable.Where(emp => emp.Value.Name == name));




Can you tell where i am missing



Thanks
siva










--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Alexandr Shapkin Alexandr Shapkin
Reply | Threaded
Open this post in threaded view
|

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: [hidden email]
Sent: Friday, July 12, 2019 3:43 PM
To: [hidden email]
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/

 

Alex Shapkin
siva siva
Reply | Threaded
Open this post in threaded view
|

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.

This post was updated on .
Hi ,


Thanks for reply


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


https://github.com/cvakarna/ApacheIgnite/blob/master/Program.cs




Thanks
siva



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Alexandr Shapkin Alexandr Shapkin
Reply | Threaded
Open this post in threaded view
|

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!

 

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: [hidden email]
Sent: Friday, July 12, 2019 9:36 PM
To: [hidden email]
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/

 

Alex Shapkin
ptupitsyn ptupitsyn
Reply | Threaded
Open this post in threaded view
|

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

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);

On Mon, Jul 15, 2019 at 8:04 PM Alexandr Shapkin <[hidden email]> 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: [hidden email]
Sent: Friday, July 12, 2019 9:36 PM
To: [hidden email]
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/

 

siva siva
Reply | Threaded
Open this post in threaded view
|

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

This post was updated on .
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(tempDate)) == 0));


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

Thanks
siva



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Alexandr Shapkin Alexandr Shapkin
Reply | Threaded
Open this post in threaded view
|

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

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: [hidden email]
Sent: Tuesday, July 30, 2019 10:43 AM
To: [hidden email]
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/

 

Alex Shapkin