I think these changes make alot of sense.
One suggestion I'd like to make, I think it'd be rare you would ever TRULY use
.TransformResults<ProjectionType>("default")
.TransformResults<ProjectionType>("view")What I think would be far more useful would be supporting:TransformResult = (db, results) => ... ;
ORTransformResults = { { "ProjectionType", (db, results) => ... },{ "SomeOtherProjectionType", (db, results) => ... } }
This would allow the user to see easier configuration for when there's only ever 1 transform, which can just behind the scenes load the TransformResults without adding obtuse syntax to configure 1 item.
For your notions of default, I'd just pick the first one in the list if you don't have a typename match. (coincidentally also solves the untyped based usage). Theoretically typeof(ProjectionType) might be better, but i think the looser coupling the strings provide probably will pay out more in the long run. Users that are fine tight coupling to classes can just do typeof(ProjectionType).Name
When would you ever really do
.TransformResults<ProjectionType>("default").TransformResults<ProjectionType>("view")As opposed to
.TransformResults<ProjectionType>()
.TransformResults<SomeOtherProjectionType>()
If for some crazy reason, you really needed 2 transforms into the same type, you could still work entirely within the typed api
inlineOn Fri, May 18, 2012 at 3:39 PM, Chris Marisic <ch...@marisic.com> wrote:I think these changes make alot of sense.
One suggestion I'd like to make, I think it'd be rare you would ever TRULY use
.TransformResults<ProjectionType>("default")
.TransformResults<ProjectionType>("view")What I think would be far more useful would be supporting:TransformResult = (db, results) => ... ;
ORTransformResults = { { "ProjectionType", (db, results) => ... },{ "SomeOtherProjectionType", (db, results) => ... } }
This would allow the user to see easier configuration for when there's only ever 1 transform, which can just behind the scenes load the TransformResults without adding obtuse syntax to configure 1 item.If we will do that, it will only be by translating the first one to the second (creating a dictionary and adding it as "default"). See more below.For your notions of default, I'd just pick the first one in the list if you don't have a typename match. (coincidentally also solves the untyped based usage). Theoretically typeof(ProjectionType) might be better, but i think the looser coupling the strings provide probably will pay out more in the long run. Users that are fine tight coupling to classes can just do typeof(ProjectionType).Name
This would introduce friction. There should really be only one way of doing this, even if it breaks old habits from v1.0...
When would you ever really do
.TransformResults<ProjectionType>("default").TransformResults<ProjectionType>("view")As opposed to
.TransformResults<ProjectionType>()
.TransformResults<SomeOtherProjectionType>()
If for some crazy reason, you really needed 2 transforms into the same type, you could still work entirely within the typed apiI'm not sure where you got the idea of 2 chained transformations. The idea is to support one at a time, letting you choose which will be executed (if at all)As you said, I cannot see any use for chained transformations, and if you really need that just write a new TR function doing what you needAlso, it can be quite heavy on the server, chaining transformations
For your notions of default, I'd just pick the first one in the list if you don't have a typename match. (coincidentally also solves the untyped based usage). Theoretically typeof(ProjectionType) might be better, but i think the looser coupling the strings provide probably will pay out more in the long run. Users that are fine tight coupling to classes can just do typeof(ProjectionType).Name
This would introduce friction. There should really be only one way of doing this, even if it breaks old habits from v1.0...
I'm not sure what friction you're talking about. Supporting TransformResult that implicitly uses TransformResults is absolutely zero friction. 90% of your users will never have more 1 than transform (maybe even 98%+). Forcing every user to define TransformResults when in almost all scenarios ever will they only need 1 transform is friction.
When would you ever really do
.TransformResults<ProjectionType>("default").TransformResults<ProjectionType>("view")As opposed to
.TransformResults<ProjectionType>()
.TransformResults<SomeOtherProjectionType>()
If for some crazy reason, you really needed 2 transforms into the same type, you could still work entirely within the typed apiI'm not sure where you got the idea of 2 chained transformations. The idea is to support one at a time, letting you choose which will be executed (if at all)As you said, I cannot see any use for chained transformations, and if you really need that just write a new TR function doing what you needAlso, it can be quite heavy on the server, chaining transformations
I'm not talking about chained transform I'm talking about why in the world would you ever havesession.Query<Type, Index>().Where(...).TransformResults<ProjectionType>("default").ToList()That makes no sense to be mapping multiple shapes of transform into the same type.session.Query<Type, Index>().Where(...).TransformResults<ProjectionType>("view").ToList()
As you said yourself, it is going to be too confusing Select.ToList vs ToList.Select