What's the better way to implement a condition at NHibernate query?Hidden Features of C#?Best practices for querying with NHibernateHow can you use optional parameters in C#?Best way to repeat a character in C#Proper use of the IDisposable interfaceHow to build a query string for a URL in C#?Implementing INotifyPropertyChanged - does a better way exist?If my interface must return Task what is the best way to have a no-operation implementation?Calculate the execution time of a methodWhy not inherit from List<T>?
What should I do if actually I found a serious flaw in someone's PhD thesis and an article derived from that PhD thesis?
Icon is not displayed in lwc
How should you gracefully leave a company you helped start?
Number of matrices with bounded products of rows and columns
Do predators tend to have vertical slit pupils versus horizontal for prey animals?
Reducing contention in thread-safe LruCache
What are the advantages of this gold finger shape?
Output with the same length always
Alignement of different align environment
Build a mob of suspiciously happy lenny faces ( ͡° ͜ʖ ͡°)
μονάδαι as plural form of μονάς
How does the illumination of the sky from the sun compare to that of the moon?
What would cause a nuclear power plant to break down after 2000 years, but not sooner?
Meaning and structure of headline "Hair it is: A List of ..."
Unconventional examples of mathematical modelling
What was the intention with the Commodore 128?
programming a recursive formula into Mathematica and find the nth position in the sequence
My new Acer Aspire 7 doesn't have a Legacy Boot option, what can I do to get it?
Designing a prison for a telekinetic race
How to prevent criminal gangs from making/buying guns?
If it isn't [someone's name]!
Subgroup generated by a subgroup and a conjugate of it
What happened after the end of the Truman Show?
What does a comma signify in inorganic chemistry?
What's the better way to implement a condition at NHibernate query?
Hidden Features of C#?Best practices for querying with NHibernateHow can you use optional parameters in C#?Best way to repeat a character in C#Proper use of the IDisposable interfaceHow to build a query string for a URL in C#?Implementing INotifyPropertyChanged - does a better way exist?If my interface must return Task what is the best way to have a no-operation implementation?Calculate the execution time of a methodWhy not inherit from List<T>?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am using a generics implementation of Query from NHibernate.
My method:
public IEnumerable<TEntidade> ObterEntidadesPor(Func<TEntidade, bool> where)
return SessionNH.Query<TEntidade>().Where(where);
In this case, the NHibernate first do the "select * from TEntidade" bring all information to memory after all this, he implement the "where" conditional. This are taking to much time.
Is there a better way to do it?
c# nhibernate orm
add a comment |
I am using a generics implementation of Query from NHibernate.
My method:
public IEnumerable<TEntidade> ObterEntidadesPor(Func<TEntidade, bool> where)
return SessionNH.Query<TEntidade>().Where(where);
In this case, the NHibernate first do the "select * from TEntidade" bring all information to memory after all this, he implement the "where" conditional. This are taking to much time.
Is there a better way to do it?
c# nhibernate orm
1
why not use Entity Framework, (not sure aboutNHibernate
) but EF translateswhere
toWHERE
clause inSQL
and doesn't pull all records in memory to do filtering.
– Aarif
Mar 27 at 13:26
1
All applications here are using NHibernate. I can't change to EF without a big impact.
– Aness Ollem Azuos
Mar 27 at 13:34
2
Try withExpression<Func<TEntidade, bool>> where
instead
– Roman Artiukhin
Mar 27 at 16:06
1
That's it! TheExpression<Func<TEntidade, bool>> where
work it. Thanks!
– Aness Ollem Azuos
Mar 27 at 18:01
add a comment |
I am using a generics implementation of Query from NHibernate.
My method:
public IEnumerable<TEntidade> ObterEntidadesPor(Func<TEntidade, bool> where)
return SessionNH.Query<TEntidade>().Where(where);
In this case, the NHibernate first do the "select * from TEntidade" bring all information to memory after all this, he implement the "where" conditional. This are taking to much time.
Is there a better way to do it?
c# nhibernate orm
I am using a generics implementation of Query from NHibernate.
My method:
public IEnumerable<TEntidade> ObterEntidadesPor(Func<TEntidade, bool> where)
return SessionNH.Query<TEntidade>().Where(where);
In this case, the NHibernate first do the "select * from TEntidade" bring all information to memory after all this, he implement the "where" conditional. This are taking to much time.
Is there a better way to do it?
c# nhibernate orm
c# nhibernate orm
asked Mar 27 at 13:22
Aness Ollem AzuosAness Ollem Azuos
381 silver badge9 bronze badges
381 silver badge9 bronze badges
1
why not use Entity Framework, (not sure aboutNHibernate
) but EF translateswhere
toWHERE
clause inSQL
and doesn't pull all records in memory to do filtering.
– Aarif
Mar 27 at 13:26
1
All applications here are using NHibernate. I can't change to EF without a big impact.
– Aness Ollem Azuos
Mar 27 at 13:34
2
Try withExpression<Func<TEntidade, bool>> where
instead
– Roman Artiukhin
Mar 27 at 16:06
1
That's it! TheExpression<Func<TEntidade, bool>> where
work it. Thanks!
– Aness Ollem Azuos
Mar 27 at 18:01
add a comment |
1
why not use Entity Framework, (not sure aboutNHibernate
) but EF translateswhere
toWHERE
clause inSQL
and doesn't pull all records in memory to do filtering.
– Aarif
Mar 27 at 13:26
1
All applications here are using NHibernate. I can't change to EF without a big impact.
– Aness Ollem Azuos
Mar 27 at 13:34
2
Try withExpression<Func<TEntidade, bool>> where
instead
– Roman Artiukhin
Mar 27 at 16:06
1
That's it! TheExpression<Func<TEntidade, bool>> where
work it. Thanks!
– Aness Ollem Azuos
Mar 27 at 18:01
1
1
why not use Entity Framework, (not sure about
NHibernate
) but EF translates where
to WHERE
clause in SQL
and doesn't pull all records in memory to do filtering.– Aarif
Mar 27 at 13:26
why not use Entity Framework, (not sure about
NHibernate
) but EF translates where
to WHERE
clause in SQL
and doesn't pull all records in memory to do filtering.– Aarif
Mar 27 at 13:26
1
1
All applications here are using NHibernate. I can't change to EF without a big impact.
– Aness Ollem Azuos
Mar 27 at 13:34
All applications here are using NHibernate. I can't change to EF without a big impact.
– Aness Ollem Azuos
Mar 27 at 13:34
2
2
Try with
Expression<Func<TEntidade, bool>> where
instead– Roman Artiukhin
Mar 27 at 16:06
Try with
Expression<Func<TEntidade, bool>> where
instead– Roman Artiukhin
Mar 27 at 16:06
1
1
That's it! The
Expression<Func<TEntidade, bool>> where
work it. Thanks!– Aness Ollem Azuos
Mar 27 at 18:01
That's it! The
Expression<Func<TEntidade, bool>> where
work it. Thanks!– Aness Ollem Azuos
Mar 27 at 18:01
add a comment |
1 Answer
1
active
oldest
votes
The problem was solved with Expression<func>
.
public IEnumerable<TEntidade> ObterEntidadesPor(Expression<Func<TEntidade, bool>> where)
return SessionNH.Query<TEntidade>().Where(where);
While searching for answer, a colleague told me that the Func
executes the query before build an expression. To build an expression before executing the query, we have to use Expression
.
This is also mentioned by @RomanArtiukhin in comments on question.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55378281%2fwhats-the-better-way-to-implement-a-condition-at-nhibernate-query%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem was solved with Expression<func>
.
public IEnumerable<TEntidade> ObterEntidadesPor(Expression<Func<TEntidade, bool>> where)
return SessionNH.Query<TEntidade>().Where(where);
While searching for answer, a colleague told me that the Func
executes the query before build an expression. To build an expression before executing the query, we have to use Expression
.
This is also mentioned by @RomanArtiukhin in comments on question.
add a comment |
The problem was solved with Expression<func>
.
public IEnumerable<TEntidade> ObterEntidadesPor(Expression<Func<TEntidade, bool>> where)
return SessionNH.Query<TEntidade>().Where(where);
While searching for answer, a colleague told me that the Func
executes the query before build an expression. To build an expression before executing the query, we have to use Expression
.
This is also mentioned by @RomanArtiukhin in comments on question.
add a comment |
The problem was solved with Expression<func>
.
public IEnumerable<TEntidade> ObterEntidadesPor(Expression<Func<TEntidade, bool>> where)
return SessionNH.Query<TEntidade>().Where(where);
While searching for answer, a colleague told me that the Func
executes the query before build an expression. To build an expression before executing the query, we have to use Expression
.
This is also mentioned by @RomanArtiukhin in comments on question.
The problem was solved with Expression<func>
.
public IEnumerable<TEntidade> ObterEntidadesPor(Expression<Func<TEntidade, bool>> where)
return SessionNH.Query<TEntidade>().Where(where);
While searching for answer, a colleague told me that the Func
executes the query before build an expression. To build an expression before executing the query, we have to use Expression
.
This is also mentioned by @RomanArtiukhin in comments on question.
edited Mar 28 at 7:09
Amit Joshi
7,7837 gold badges33 silver badges72 bronze badges
7,7837 gold badges33 silver badges72 bronze badges
answered Mar 27 at 18:05
Aness Ollem AzuosAness Ollem Azuos
381 silver badge9 bronze badges
381 silver badge9 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55378281%2fwhats-the-better-way-to-implement-a-condition-at-nhibernate-query%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
why not use Entity Framework, (not sure about
NHibernate
) but EF translateswhere
toWHERE
clause inSQL
and doesn't pull all records in memory to do filtering.– Aarif
Mar 27 at 13:26
1
All applications here are using NHibernate. I can't change to EF without a big impact.
– Aness Ollem Azuos
Mar 27 at 13:34
2
Try with
Expression<Func<TEntidade, bool>> where
instead– Roman Artiukhin
Mar 27 at 16:06
1
That's it! The
Expression<Func<TEntidade, bool>> where
work it. Thanks!– Aness Ollem Azuos
Mar 27 at 18:01