I couldn't find any information about any ezfind plugin for Rails.

Talking about LINQ,

Product.find(:all, :conditions => ['category.name = ?', "Books"])

is not really LINQ which means language integrated query.
What would be really LINQ-like is:

Product.all.select { |p| p.category.name == "Books"}
Article.all.reject { |a| a.comments.count == 0 }
Person.all.find { |p| p.roles.include? Role.find_by_name("manager") }
etc.

I've written an extension to ActiveRecord that adds the magic "all"
method to a model class that supports select, reject, find, each etc.
I haven't had time yet to implement joins though. I've also realized
that it is not possible to implement fully language integrated query
in Ruby as some operators/constructs are implemented at the language
level and cannot be overriden, such as the != operator, the if/unless
statement/expression and the not operator. The following LINQ-code, as
I've experienced, is not possible:
Product.all.select { |p| p.name != "Funky Trousers" }
or:
Article.all.each { |article| puts article.title if article.comments.count > 0 }.

It is possible to substitute !=, not and if with alphanumerically
named methods such as "not_eq", "not" and "if_true" (a la Smalltalk),
but it wouldn't be 100% "language integrated".

Erik

On 01/07/07, court3nay <[EMAIL PROTECTED]> wrote:
>
> Using ezfind plugin this would be fairly straight forward as it uses a
> block and some kind of magic
>
> --------
> courtenay
>
> On Jun 30, 2007, at 10:49 PM, Mike Sax <[EMAIL PROTECTED]> wrote:
>
> >
> > In Microsoft's LINQ after you define your model, you can say something
> > like this:
> >
> >   var products = from p in products where p.category.name == "Books"
> > select p;
> >
> > This gets translated in the following SQL statement (roughly)
> >
> >   SELECT * FROM products LEFT OUTER JOIN categories ON categories.id
> > = products.category_id where categories.name = "Books"
> >
> > Since we already have the model mostly defined through has_many/
> > has_one/belongs_to/etc. declarations, wouldn't it be nice if we could
> > say:
> >
> >   products = Product.find(:all, :conditions => ['category.name = ?',
> > "Books"])
> >
> > which would then generate the left outer join query.
> >
> >
> > >
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to