#2 gets my vote too. You should bare in mind that the order-by attribute can
contain any arbitrary sql statement, as long as it is valid. While possible
to provide some fluency, it'll also be a good idea to allow the user to
specify a simple string too. I did this with the Where method.

On Tue, Jun 16, 2009 at 4:36 AM, Hudson Akridge <[email protected]>wrote:

> http://github.com/jagregory/fluent-nhibernate/tree/master
> <http://github.com/jagregory/fluent-nhibernate/tree/master>I'd say #2
> would be my pick, and the OrderBy() can return an interface that only gives
> you the choice of Ascending or Descending, and Asc/Desc would return the
> parent object (the OneToManyPart). Check out how the Cascade strategy works
> for an example.
>
>
> On Mon, Jun 15, 2009 at 6:44 PM, Dylan Beattie <[email protected]>wrote:
>
>>
>> Hi,
>>
>> I've been playing around with Fluent NH for a couple of days, and I
>> really, really like what you've done with it - awesome work, and
>> thankyou!
>>
>> I have some rough-but-running code for fluently specifying ordering of
>> child collections, and wanted some thoughts on syntax before I cover
>> the rest of the cases and hopefully submit a patch sometime this week.
>>
>> Three possibilities I can see:
>>
>> 1) HasMany<Child>(p => p.Children).OrderBy.Ascending(child =>
>> child.Name)
>>
>> This is my personal favourite so far, although I don't have a fully-
>> working implementation of this particular syntax yet. The syntax and
>> ideas are borrowed from CascadeExpression, and force you to specify
>> either .Ascending or .Descending, followed by either a string or
>> lambda property expression specifying the sort property.
>>
>> 2) HasMany<Child>(p => p.Children).OrderBy(child =>
>> child.Name).Ascending()
>>
>> A bit more LINQ-y, but means .Ascending() and .Descending() have to be
>> chained onto the return from .OrderBy() - which means it's
>> syntactically possible to add .Ascending() without specifying .OrderBy
>> (). Alternatively we could use the LINQ OrderBy() / OrderByDescending
>> () syntax here.
>>
>> 3) HasMany<Child>(p => p.Children).OrderBy(child => child.Name,
>> Order.Ascending)
>>
>> - i.e. just throw an enum Order { Ascending, Descending } in there as
>> a second parameter, defaulting to Ascending if it's omitted. I'd like
>> to steer clear of using 'bool ascending' which is used elsewhere in NH
>> - it works fine but isn't clear what the true/false means when you're
>> reading the resulting code.
>>
>> Unless anyone has a strong objection or a better idea, I'll go ahead
>> with approach #1 and see how I get on. Where's the best place to
>> submit a patch for this if I get something working?
>>
>> Thanks,
>>
>> Dylan
>>
>>
>
>
> --
> - Hudson
> http://www.bestguesstheory.com
> http://twitter.com/HudsonAkridge
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to