IsLike extension method

59 views
Skip to first unread message

Raul Carlomagno

unread,
Oct 31, 2011, 10:21:50 AM10/31/11
to nhusers
in my application layer im querying my repositories with lambda
expressions, for example, customerRepo.FindAll(c => c.IsEnabled)
then inside the repository, im using QueryOver API
but now, i want to query something like this customerRepo.FindAll(c =>
c.Name.Contains("Charles"))
NH throws an exception
then, i read that i have to use IsLike extension because, Contains is
not implemented
but if i want to do customerRepo.FindAll(c =>
c.Name.IsLike("Charles"))
i have to reference my application layer to NHibernate.dll, this way
my layers and components gets highly coupled

is there another way to match string parts with lambda expressions?

i think i could implement this query inside my repository method and
just call
customerRepo.FindByName("Charles")

but i like the idea of querying freely from my application layer

mynkow

unread,
Oct 31, 2011, 10:27:44 AM10/31/11
to nhu...@googlegroups.com
Offtopic: What is the difference between nhibernate and repository?

Raul Carlomagno

unread,
Oct 31, 2011, 12:18:09 PM10/31/11
to nhusers
im abstracting my layers, today´s dal is composed of nh repositories,
and i need another dal, built with ef repositories
also, this way, i can unit test my application layer classes without
worry about nh, ef, or whatever mi repositories are built with,
included mock repositories

belva...@googlemail.com

unread,
Oct 31, 2011, 7:18:56 PM10/31/11
to nhu...@googlegroups.com
Maybe this can help:

http://fabiomaulo.blogspot.com/2010/07/nhibernate-linq-provider-extension.html

In this case you can separate the Extension from the NH stuff. But i don't know,
if there is such an integration point for the QueryOver API.

Am schrieb Raul Carlomagno <rcarl...@gmail.com>:
> --
>
> You received this message because you are subscribed to the Google Groups "nhusers" group.
>
> To post to this group, send email to nhu...@googlegroups.com.
>
> To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
>
> For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
>
>
>
>

Raul Carlomagno

unread,
Nov 4, 2011, 2:19:43 PM11/4/11
to nhusers
ive already tried it, it did not work
thanks anyway

On Oct 31, 8:18 pm, belvasis...@googlemail.com wrote:
> Maybe this can help:
>
> http://fabiomaulo.blogspot.com/2010/07/nhibernate-linq-provider-exten...
>
> In this case you can separate the Extension from the NH stuff. But i don't
> know,
> if there is such an integration point for the QueryOver API.
>
> Am schrieb Raul Carlomagno <rcarloma...@gmail.com>:

Richard Brown (gmail)

unread,
Nov 6, 2011, 11:15:46 AM11/6/11
to nhusers

You can register your own custom extensions for QueryOver:

https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Impl/ExpressionProcessor.cs#L152-154

I think perhaps, though, that the core problem is that you'll need your own
query-objects to wrap up dynamic querying behaviour without referencing NH.
You could take a look at this and see if it helps at all:

http://fabiomaulo.blogspot.com/2010/07/enhanced-query-object.html

Reply all
Reply to author
Forward
0 new messages