# Linq syntax?

**URL:** <https://www.ruby-forum.com/t/linq-syntax/164957>\
**Category:** IronRuby\
**Created:** [April 7, 2009, 8:15pm UTC](https://www.ruby-forum.com/t/linq-syntax/164957 "2009-04-07T20:15:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![barby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@barby](https://www.ruby-forum.com/u/barby)\
**Post date:** [April 7, 2009, 8:15pm UTC](https://www.ruby-forum.com/t/linq-syntax/164957/1 "2009-04-07T20:15:03Z")

</div>

Hi  
What would be the syntax to call Linq methods?

for example:  
I have an IQueryable 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 C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))

---

<div class="post-metadata">

**Author:** ![barby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@barby](https://www.ruby-forum.com/u/barby)\
**Post date:** [April 7, 2009, 9:02pm UTC](https://www.ruby-forum.com/t/linq-syntax/164957/2 "2009-04-07T21:02:38Z")

</div>

Method of Queryable take expression trees. Ruby lambdas are not  
convertible to expression trees.  
You need to build the expression tree yourself.

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] 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 and I want to get the equivalent out of

from user in MyRepository.Users  
where user.name[http://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](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 C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))

---

<div class="post-metadata">

**Author:** ![barby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@barby](https://www.ruby-forum.com/u/barby)\
**Post date:** [April 7, 2009, 10:03pm UTC](https://www.ruby-forum.com/t/linq-syntax/164957/3 "2009-04-07T22:03:04Z")

</div>

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 M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
