From: Trans Date: 2008-10-07T15:01:22+09:00 Subject: Re: RINQ? On Oct 7, 12:36 am, Peņa, Botp wrote: > From: Trans [mailto:transf...@gmail.com] > #http://graffie.wordpress.com/2008/03/12/rinq-concept-of-a-ruby-integr... > # > #  http://rubyforge.org/frs/download.php/26198/BRUG-10-03-2007.pdf > # > > very nice. but still very sql-ish. > i like ruby keywords better. > > eg, from this > > customernames = customers. >               qwhere {|c| c.address.city == "London"}. >               qselect  {|c| {:firstname => c.firstname, >               :lastname  => c.lastname}}. >               qorderby {|c| c.lastname} > > i prefer this instead > > customernames = customers. >               select {|c| c.address.city == "London"}. >               collect{|c| [c.firstname,c.lastname]}. >               sort_by{|c| c.lastname} Interesting. I tried translating this idea to a more complex example. Given pseudo-LINQ like: r = query do from :c => :customer, :a => :account, :b => :bank select b.name where (( c.firstname == first1 ) | ( c.firstname == first2 ) ) & ( c.lastname =~ last ) & ( a.owner == c ) & ( a.bank == b ) end How would you work that? I played with it a bit and thought of: customers = from(:customers) a = from(:account) b = from(:bank) r = customers.select { |c| (c.firstname == first1 || c.firstname == first2) && c.lastname =~ last && a.owner == c && a.bank == b }.collect { |c| c.name } I generally like the idea, albeit the modus operandi of LINQ has been to reflect as much as possible the original domain language (sql, xml, etc.) in the target language. Nonetheless, I can see the advantage of expressing queries in native Ruby instead, and having that translated to the domain language. But is Ruby ultimately expressive enough? We may end up adding enough new syntax (eg. inner and outer joins), that it will largely overshadow the native syntax anyway. T.