2 Patches Added

1 view
Skip to first unread message

Neal Blomfield

unread,
Mar 3, 2009, 2:16:37 PM3/3/09
to NhLambdaExtensionsUsers
When using the default build script I was getting errors from the exec
task that calls out to tt. Fully qualified the path to tt seems to
have fixed the issue. See issue 5 with attached patch.

Added support for the '.class' metaproperty allowing the following:

DetachedCriteria expected =
DetachedCriteria.For<Person>( "personAlias" )
.Add( Restrictions.Eq( "personAlias.class", typeof
(Person) ) );

to be expressed using lambda notion as:

Person personAlias = null;
DetachedCriteria actual =
DetachedCriteria<Person>.Create( () => personAlias )
.Add( LambdaRestriction.ClassEq( () => personAlias ) );

Not sure if its the best approach but it was the best I could come up
with at the time I needed it =)

Neal Blomfield

unread,
Mar 3, 2009, 8:44:22 PM3/3/09
to NhLambdaExtensionsUsers
Added another patch to allow restrictions against boolean members to
be expressed more succinctly e.g.

DetachedCriteria actual =
DetachedCriteria.For<Person>()
.Add<Person>( p => p.IsParent );

which is the same as:

DetachedCriteria actual =
DetachedCriteria.For<Person>()
.Add<Person>( p => p.IsParent == true );

Richard Brown (gmail)

unread,
Mar 5, 2009, 2:31:48 PM3/5/09
to nhlambdaext...@googlegroups.com
Hi Neal,

Sorry for the lateness of the reply, I've been busy the last couple of days.

I like the idea of supporting this; what's the thoughts on the syntax:

.Add<Person>(personAlias.GetType() == typeof(Person))

Cheers,
Richard

--------------------------------------------------
From: "Neal Blomfield" <Neal.Bl...@gmail.com>
Sent: Tuesday, March 03, 2009 7:16 PM
To: "NhLambdaExtensionsUsers" <nhlambdaext...@googlegroups.com>
Subject: 2 Patches Added

Richard Brown (gmail)

unread,
Mar 5, 2009, 2:32:43 PM3/5/09
to nhlambdaext...@googlegroups.com
Hi Neal,

I can't get the build script to fail on mine ... can you describe the steps
to reproduce?

(is it when using NAnt from the command line? what's the error? was the
CommandPrompt.bat used?)
(or from VS - which version?)

Cheers,
Richard

--------------------------------------------------
From: "Neal Blomfield" <Neal.Bl...@gmail.com>
Sent: Tuesday, March 03, 2009 7:16 PM
To: "NhLambdaExtensionsUsers" <nhlambdaext...@googlegroups.com>
Subject: 2 Patches Added

>

Richard Brown (gmail)

unread,
Mar 5, 2009, 3:50:41 PM3/5/09
to nhlambdaext...@googlegroups.com
I don't know if this is the problem, but there's a line in the build file:
<setenv name="PATH"
value="${nant::get-base-directory()}/../../t4;%PATH%"/>

This adds t4 to path based on where NAnt was run from, so I expect you're
using your own copy/installation of NAnt? (i.e., not the one in the SDKs
folder that's set by the CommandPrompt.bat? - just a guess).

--------------------------------------------------
From: "Richard Brown (gmail)" <fluk...@googlemail.com>
Sent: Thursday, March 05, 2009 7:32 PM
To: <nhlambdaext...@googlegroups.com>
Subject: Re: 2 Patches Added

Neal Blomfield

unread,
Mar 5, 2009, 4:18:49 PM3/5/09
to NhLambdaExtensionsUsers
Yes, I have nant set up in a tools directory so I don't have to add a
new path statement for every project that uses nant build files. That
would explain the problem.

As to syntax for accessing the class metaproperty, I'm happy however
it works. You can see my current implementation using
LambdaRestriction.ClassEq (which is really a shallow layer over get
type + string concatenation). This was built to satisfy the immediate
requirement and as a potential (although less than elegant) solution
to the problem (I'm still learning what I can do with expression tree
parsing).

Not 100% sure about the code changes to allow more succinct
representation of boolean expressions, but I followed that path
because I was getting annoyed with all the reshaper warnings (and it
does look rather neater).

Also been playing with concept of "typed" detached criteria to remove
the additional noise required by the Add<T> and increase the "type
safety" of the queries even further (i.e. not allowing something like
DetachedCriteria.For<Person>().Add<Cat>( c => ... ) ), but not sure if
that fits well with the concept of NHLambda (and it's not even close
to working).

Apologies for the flurry of changes - I'm migrating a bunch of
criteria queries over - some that have "interesting" characteristics
so I have to extend the capabilities of NHLambda, which exposes me to
it's potential which drives me to mess around with it even more.

Great work btw, Nice to work on something thats easy to follow and
extend.

On Mar 6, 9:50 am, "Richard Brown \(gmail\)" <fluke...@googlemail.com>
wrote:
> I don't know if this is the problem, but there's a line in the build file:
>     <setenv name="PATH"
> value="${nant::get-base-directory()}/../../t4;%PATH%"/>
>
> This adds t4 to path based on where NAnt was run from, so I expect you're
> using your own copy/installation of NAnt?  (i.e., not the one in the SDKs
> folder that's set by the CommandPrompt.bat? - just a guess).
>
> --------------------------------------------------
> From: "Richard Brown (gmail)" <fluke...@googlemail.com>
> Sent: Thursday, March 05, 2009 7:32 PM
> To: <nhlambdaext...@googlegroups.com>
> Subject: Re: 2 Patches Added
>
> > Hi Neal,
>
> > I can't get the build script to fail on mine ... can you describe the
> > steps to reproduce?
>
> > (is it when using NAnt from the command line?  what's the error? was the
> > CommandPrompt.bat used?)
> > (or from VS - which version?)
>
> > Cheers,
> >    Richard
>
> > --------------------------------------------------
> > From: "Neal Blomfield" <Neal.Blomfi...@gmail.com>

Richard Brown (gmail)

unread,
Mar 8, 2009, 4:29:25 PM3/8/09
to nhlambdaext...@googlegroups.com
> Yes, I have nant set up in a tools directory so I don't have to add a
> new path statement for every project that uses nant build files. That
> would explain the problem.

Cool, I'll close off that issue. (It's actually quite nice that it 'forces'
it to be built using the supplied version of NAnt).

> As to syntax for accessing the class metaproperty, I'm happy however
> it works. You can see my current implementation using

OK, I think I'll try implementing the GetType() version unless there's any
objections.

> Not 100% sure about the code changes to allow more succinct
> representation of boolean expressions, ...

Thanks for the patch, I'll get it added when I get the chance.

> Also been playing with concept of "typed" detached criteria to remove
> the additional noise required by the Add<T> and increase ...

Yeah, I tried this myself but gave up (too easily). I'll no doubt revisit
it soon and try to get it working. It was the first thing Ayende (the king
of fluent syntax) noticed too:

http://groups.google.com/group/nhibernate-development/browse_thread/thread/614bb5963621fb1a

IIRC the bit that was awkward was making the creation of sub-criteria
typesafe.


--------------------------------------------------
From: "Neal Blomfield" <Neal.Bl...@gmail.com>
Sent: Thursday, March 05, 2009 9:18 PM
To: "NhLambdaExtensionsUsers" <nhlambdaext...@googlegroups.com>
Subject: Re: 2 Patches Added

Richard Brown (gmail)

unread,
Mar 9, 2009, 6:16:34 PM3/9/09
to nhlambdaext...@googlegroups.com
V1.0.5.0 released.

Supports direct Boolean expressions (without a comparison to true/false);
Supports GetType() in place of .class meta-property.

Thanks Neal.

--------------------------------------------------
From: "Richard Brown (gmail)" <fluk...@googlemail.com>
Sent: Sunday, March 08, 2009 8:29 PM
Reply all
Reply to author
Forward
0 new messages