in

Wish: same syntax pre- and post-Load()

Last post 05-11-2008 6:36 PM by ranomore. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 04-09-2008 10:46 PM

    Wish: same syntax pre- and post-Load()

    Obviously, one goal of SubSonic is abstraction -- the ability to deal with domain entities like ProductCollection() instead of writing SQL. Seems to me a real useful and differentiating idea would be the ability to "re-query" or filter collections after they have loaded from the database.

    Yes, you can do this now with methods like FindAll using delegates. Workable, but heady stuff for some people. I would love to be able to use the same syntax that I used to query in the first place, to filter later.

    Let's say I am querying a clothing catalog. I want to get all the Jackets. I would do: 

    ProductCollection myJackets = new ProductCollection.Where("Type", "Jacket").Load()

    Now I have a collection of jackets. What if I just want leather jackets, without hitting the database again? I would have to do a Find() with a very different syntax, even though I am performing a very similar task. How about:

    ProductCollection myLeatherJackets = myJackets.Where("Material", "Leather").Filter() or some such?

    I would find this intuitive -- one syntax to express criteria. Non-trivial to implement, of course, but elegant to use.

    The reason this comes to mind is that I became accustomed to the Filter property of a recordset back in the classic ASP days. It allowed for really "inexpensive" code, ie, minimizing database hits.

    Thoughts?

  • 05-07-2008 9:25 AM In reply to

    • ejb
    • Top 75 Contributor
    • Joined on 01-02-2007
    • Posts 21

    Re: Wish: same syntax pre- and post-Load()

    The collections implement IEnumerable. Can't you use LINQ?

  • 05-11-2008 6:36 PM In reply to

    • ranomore
    • Top 10 Contributor
    • Joined on 11-05-2007
    • Salt Lake City
    • Posts 161
    • Moderator

    Re: Wish: same syntax pre- and post-Load()

    MattAtLandor:
    I would find this intuitive -- one syntax to express criteria. Non-trivial to implement, of course, but elegant to use.
     

    I agree, this would be very intuitive. But at the same time, why re-invent the wheel? Or convert the wheel into a square? 

Page 1 of 1 (3 items)