Few Small Examples in Linq with IronRuby

Hello,

I know that its too early to ask or it.

But can someone provide few examples, how Linq with IronRuby will look
alike.

Since i am reading few books on LINQ in C#, i want to gradually try to
understand it with IronRuby point of view.

I do not want examples to play around. I want examples to understand
LINQ with IronRuby.

I hope someone might help me here.

I think this should answer your question
http://rubyforge.org/pipermail/ironruby-core/2008-January/000706.html

Remove the comma from the URI.

Ivan Porto C. wrote:

I think this should answer your question
http://rubyforge.org/pipermail/ironruby-core/2008-January/000706.html


Ho Ivan,

Thanks for pointing me a link. But the link is obsolete now.


Translating this example:
Query Syntax and Method Syntax in LINQ (C#) | Microsoft Learn, it will look
something like this:

require ‘System.Core’
numbers = [5, 10, 8, 3, 6, 12]
numbers.where { |num| num % 2 == 0 }.order_by { |n| n }.each { |i|
write("#{i} ") }

  • John

I could see the example in Ruby, but the actual msdn2 link is now
obsolete and the code is removed.

So i am unable to make any comparison.

Sorry for my more questions on LINQ.

I just read in LinQ in Action…it goes like this…

In chapter 2, we’ll show you the details of how the programming
languages
have been extended to support LINQ. In chapter 3, you’ll learn how to
write LINQ
queries. This is where you’ll learn about query operators, query
expressions, and
expression trees. But you still have a few things to discover before
getting there.

what i understand is… C# and Vb.Net have been extended to meet the
LINQ requirement. So now we have C# 3.0 and Vb2008 right.

My question is … what about Ruby 1.8 or 1.9…? are they already
capable with their inbuilt features to support LINQ or IronRuby shall
incorporate those extra additions to meet the LINQ requirement…?

How far in IronRby from LINQ now…?

Thanks

Web R. wrote:

But can someone provide few examples, how Linq with IronRuby will look
alike.


I am the second interested.

LINQ 2 SQL is very important. I think few experts should start some
tutorials about this

Looking at the codes in C# and Vb.Net does not make any sense, as we are
never going that way.

IronRuby + LINQ is the way many like me would go.

John L. (DLR) wrote:

Remove the comma from the URI.


Thanks John.

I did not notice that little comma. I just clicked the link.

Here’s the C# Code.


class QueryVMethodSyntax
{
static void Main()
{
int[] numbers = { 5, 10, 8, 3, 6, 12};

    //Query syntax:
    IEnumerable<int> numQuery1 =
        from num in numbers
        where num % 2 == 0
        orderby num
        select num;

    //Method syntax:
    IEnumerable<int> numQuery2 = numbers.Where(num => num % 2 == 

0).OrderBy(n => n);

    foreach (int i in numQuery1)
    {
        Console.Write(i + " ");
    }
    Console.WriteLine(System.Environment.NewLine);
    foreach (int i in numQuery2)
    {
        Console.Write(i + " ");
    }

    // Keep the console open in debug mode.
    Console.WriteLine(System.Environment.NewLine);
    Console.WriteLine("Press any key to exit");
    Console.ReadKey();
}

}
/*
Output:
6 8 10 12
6 8 10 12
*/

With IronRuby, LINQ would be a fun.

Hope to see such more examples soon.

Thanks

Rahil K. wrote:

Web R. wrote:

LINQ 2 SQL is very important. I think few experts should start some
tutorials about this

I think, its time for some experts to come ahead a start blogging about
Linq to sql with Iron Ruby to start with.

  • 1 on the suggestion by Mr.Rahil

SoftMind