Forum: IronRuby Linq syntax?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1e39a948a58f4569c53d971c2e120920?d=identicon&s=25 Ivan Porto carrero (casualjim)
on 2009-04-07 20:15
(Received via mailing list)
Hi
What would be the syntax to call Linq methods?

for example:
I have an IQueryable<Users> and I want to get the equivalent out of

from user in MyRepository.Users
where user.name == "somename"

That of course is only one example, I want to do a lot more :)

My best guess is that I would have to do something like this only it
doesn't
work

System::Linq::Queryable.where(MyRepository.Users, lambda { |user|
user.name== "somename" })

yields wrong number of arguments (2 for 2147483647)

So what is the correct way?
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
Cb51033949ffccd982ae32c9f890f25a?d=identicon&s=25 Tomas Matousek (Guest)
on 2009-04-07 21:02
(Received via mailing list)
Method of Queryable take expression trees. Ruby lambdas are not
convertible to expression trees.
You need to build the expression tree yourself.

Tomas

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Ivan Porto
Carrero
Sent: Tuesday, April 07, 2009 11:06 AM
To: ironruby-core
Subject: [Ironruby-core] Linq syntax?

Hi

What would be the syntax to call Linq methods?

for example:
I have an IQueryable<Users> and I want to get the equivalent out of

from user in MyRepository.Users
where user.name<http://user.name> == "somename"

That of course is only one example, I want to do a lot more :)

My best guess is that I would have to do something like this only it
doesn't work

System::Linq::Queryable.where(MyRepository.Users, lambda { |user|
user.name<http://user.name> == "somename" })

yields wrong number of arguments (2 for 2147483647)

So what is the correct way?
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
4f55d99fc4a14f491e3b19d0724081e5?d=identicon&s=25 Stefan Dobrev (Guest)
on 2009-04-07 22:03
(Received via mailing list)
I was just going to post about this. Currently it is not possible to
call
the extension methods in System::Linq::Enumerable and
System::Linq::Queryable.

>>> require 'System.Core, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'
=> true
>>> include System::Linq
=> Object
>>> Queryable
=> System::Linq::Queryable
>>> Queryable.where
:0:in `CallSite.Target': wrong number of arguments (1 for 2147483647)
(ArgumentError)
...

2009/4/7 Tomas Matousek <Tomas.Matousek@microsoft.com>
This topic is locked and can not be replied to.