I'm extending Fluent NHibernate for better use with F# (namely, quotation support), and want some feedback on de-fluenting the API. F# requires that return values be used, unless they are type unit. So this ends up terminating every line with "|> ignore":
type ProductMap() as m = inherit QClassMap<Product>() do
let x = Unchecked.defaultof<Product>
m.Id <@ x.Id @> |> ignore
m.Map <@ x.Name @> |> ignore
m.Map <@ x.Price @> |> ignore
(m.HasManyToMany <@ seq x.StoresStockedIn @>)
.Cascade.All()
.Inverse()
.WithTableName("StoreProduct") |> ignore
My first reaction was to add more methods to the base class so they return unit. For instance, "IdI" and "MapI":
...
m.IdI <@ x.Id @>
m.MapI <@ x.Name @>
m.MapI <@ x.Price @>
...
But that requires specific overloads here and there, and long chains are still going to need a |> Ignore. I also considered extending object with a Done property:
(m.Id <@ x.Id @>).Done
(m.Map <@ x.Name @>).Done
(m.Map <@ x.Price @>).Done
(m.HasManyToMany <@ seq x.StoresStockedIn @>)
.Cascade.All()
.Inverse()
.WithTableName("StoreProduct").Done
What do you think?