Questions tagged [icriteria]

NHibernate Criteria Interface : Criteria is a simplified API for retrieving entities by composing NHibernate.Expression objects

151 questions
27
votes
3 answers

NHibernate - CreateCriteria vs CreateAlias

Assuming the following scenario: class Project{ public Job Job; } class Job{ public Name; } Assuming I want to use the Criteria API to search for all projects whose Job has the name "sumthing". I could use the CreateAlias to create an alias…
Megacan
  • 2,510
  • 3
  • 20
  • 31
18
votes
1 answer

Lazy loading not working for many-to-one relationship when mapping to a non-key field using property-ref

I have a legacy database that I am mapping using NHibernate. The objects of concern are an Account and a list of Notification objects. The objects look like: public class Notification { public virtual int Id { get; set; } public virtual…
SteveBering
  • 947
  • 1
  • 12
  • 30
16
votes
1 answer

How do I take the "top n" using NHibernate Criteria API?

How do I take the "top n" using NHibernate Criteria API? Ideally I'd like to use detached criteria.
Ben Aston
  • 53,718
  • 65
  • 205
  • 331
15
votes
4 answers

NHibernate HQL vs CriteriaAPI vs QueryOver vs Linq. Performance

What are the performance differences between the hql and criteriaApi and QueryOver? Are there any situations where one is faster or slower than the other? Edit: I extended the question with QueryOver and…
mynkow
  • 4,408
  • 4
  • 38
  • 65
10
votes
6 answers

NHibernate How do I query against an IList property?

I am trying to query against an IList property on one of my domain classes using NHibernate. Here is a simple example to demonstrate: public class Demo { public Demo() { this.Tags = new List(); } public…
JohnRudolfLewis
  • 1,692
  • 1
  • 18
  • 33
9
votes
1 answer

What's the difference between DetachedCriteria and ICriteria

These classes have some similar methods but seem to work slightly different. What's the difference between them and when should I use each of them?
x__dos
  • 1,813
  • 3
  • 27
  • 47
9
votes
2 answers

NHibernate Query across multiple tables

I am using NHibernate, and am trying to figure out how to write a query, that searchs all the names of my entities, and lists the results. As a simple example, I have the following objects; public class Cat { public string name {get; set;} } public…
Dai Bok
  • 3,451
  • 2
  • 53
  • 70
9
votes
3 answers

Nhibernate Criteria: 'select max(id)...'

Can I use a Criteria to execute a t-sql command to select the max value for a column in a table? 'select @cus_id = max(id) + 1 from customers' Ta Ollie
AwkwardCoder
  • 24,893
  • 27
  • 82
  • 152
8
votes
7 answers

NHIbernate: Shortcut for projecting all properties?

I'm trying to generate SQL along the lines of: SELECT t.*, SELECT (...) FROM Title t [trimmed] using QueryOver Title title = null; var q = session .QueryOver(() => title) .Select( Projections.Alias(Projections.Property(t…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/nhibernate" class="post-tag grid--cell" title="show questions tagged 'nhibernate'" rel="tag">nhibernate</a> <a href="../../questions/tagged/icriteria" class="post-tag grid--cell" title="show questions tagged 'icriteria'" rel="tag">icriteria</a> <a href="../../questions/tagged/queryover" class="post-tag grid--cell" title="show questions tagged 'queryover'" rel="tag">queryover</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Apr 23 '11 at 07:34">asked Apr 23 '11 at 07:34</time> <a href="../../users/184131/csano" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/184131.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="csano" /> </a> <div class="s-user-card--info"> <a href="../../users/184131/csano" class="s-user-card--link">csano</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">13,266</li> <li class="s-award-bling s-award-bling__gold" title="2 gold badges">2</li> <li class="s-award-bling s-award-bling__silver" title="28 silver badges">28</li> <li class="s-award-bling s-award-bling__bronze" title="45 bronze badges">45</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-434138"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>8</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/434138/how-to-set-more-than-2-expression-in-expression-or" class="question-hyperlink">How to set more than 2 Expression in Expression.Or</a></h3> <div class="excerpt">I want to create a query which has more than 3-4 Expression.Or ? But Expression.Or just let me to add two Expressions inside it. if (!string.IsNullOrEmpty(keyword)) query .Add(Expression.Or( …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/nhibernate" class="post-tag grid--cell" title="show questions tagged 'nhibernate'" rel="tag">nhibernate</a> <a href="../../questions/tagged/criteria" class="post-tag grid--cell" title="show questions tagged 'criteria'" rel="tag">criteria</a> <a href="../../questions/tagged/expression" class="post-tag grid--cell" title="show questions tagged 'expression'" rel="tag">expression</a> <a href="../../questions/tagged/icriteria" class="post-tag grid--cell" title="show questions tagged 'icriteria'" rel="tag">icriteria</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jan 12 '09 at 00:51">asked Jan 12 '09 at 00:51</time> <a href="../../users/51734/barbaros-alp" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/51734.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Barbaros Alp" /> </a> <div class="s-user-card--info"> <a href="../../users/51734/barbaros-alp" class="s-user-card--link">Barbaros Alp</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">6,405</li> <li class="s-award-bling s-award-bling__gold" title="8 gold badges">8</li> <li class="s-award-bling s-award-bling__silver" title="47 silver badges">47</li> <li class="s-award-bling s-award-bling__bronze" title="61 bronze badges">61</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-1168686"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>8</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/1168686/nhibernate-implement-not-in-query-using-icriteria" class="question-hyperlink">NHibernate - Implement "NOT IN" query using ICriteria</a></h3> <div class="excerpt">I've started getting to grips with NHibernate. I'm trying to perform a query that selects all records from a table but with an exclusion filter list of IDs, eg. get me all Products except these ones with these ID values. Normally in direct T-SQL I'd…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/nhibernate" class="post-tag grid--cell" title="show questions tagged 'nhibernate'" rel="tag">nhibernate</a> <a href="../../questions/tagged/icriteria" class="post-tag grid--cell" title="show questions tagged 'icriteria'" rel="tag">icriteria</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jul 22 '09 at 22:37">asked Jul 22 '09 at 22:37</time> <a href="../../users/143253/sunday-ironfoot" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/143253.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Sunday Ironfoot" /> </a> <div class="s-user-card--info"> <a href="../../users/143253/sunday-ironfoot" class="s-user-card--link">Sunday Ironfoot</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">12,840</li> <li class="s-award-bling s-award-bling__gold" title="15 gold badges">15</li> <li class="s-award-bling s-award-bling__silver" title="75 silver badges">75</li> <li class="s-award-bling s-award-bling__bronze" title="91 bronze badges">91</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-1752978"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>7</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/1752978/nhibernate-criteria-query-select-distinct" class="question-hyperlink">NHibernate Criteria Query - Select Distinct</a></h3> <div class="excerpt">I have a Person entity belongs to a person has a Country, I want to select all the distinct countries that have people in them. Easy in HQL select distinct p.Country from Person p How can I do this using a Criteria Query? </div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/nhibernate" class="post-tag grid--cell" title="show questions tagged 'nhibernate'" rel="tag">nhibernate</a> <a href="../../questions/tagged/criteria" class="post-tag grid--cell" title="show questions tagged 'criteria'" rel="tag">criteria</a> <a href="../../questions/tagged/icriteria" class="post-tag grid--cell" title="show questions tagged 'icriteria'" rel="tag">icriteria</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Nov 18 '09 at 01:10">asked Nov 18 '09 at 01:10</time> <a href="../../users/166303/reach4thelasers" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/166303.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="reach4thelasers" /> </a> <div class="s-user-card--info"> <a href="../../users/166303/reach4thelasers" class="s-user-card--link">reach4thelasers</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">26,181</li> <li class="s-award-bling s-award-bling__gold" title="22 gold badges">22</li> <li class="s-award-bling s-award-bling__silver" title="92 silver badges">92</li> <li class="s-award-bling s-award-bling__bronze" title="123 bronze badges">123</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-1222735"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>7</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status "> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/1222735/projections-conditional-how-to-use-it" class="question-hyperlink">Projections.Conditional - How to use it?</a></h3> <div class="excerpt">Anyone knows how to use Projections.Conditional to produce something like "case ... when..." The following code gives a wrong query: IProjection isError = Projections.Conditional( Expression.Eq( "event.LogLevel", eLogLevel.Fatal.ToString( ) ),…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/nhibernate" class="post-tag grid--cell" title="show questions tagged 'nhibernate'" rel="tag">nhibernate</a> <a href="../../questions/tagged/icriteria" class="post-tag grid--cell" title="show questions tagged 'icriteria'" rel="tag">icriteria</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Aug 03 '09 at 14:43">asked Aug 03 '09 at 14:43</time> <a href="../../users/148144/caro" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/148144.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Caro" /> </a> <div class="s-user-card--info"> <a href="../../users/148144/caro" class="s-user-card--link">Caro</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">91</li> <li class="s-award-bling s-award-bling__silver" title="1 silver badges">1</li> <li class="s-award-bling s-award-bling__bronze" title="4 bronze badges">4</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-729687"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>6</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/729687/how-do-i-select-a-random-row-using-nhibernate-s-icriteria-api" class="question-hyperlink">How do I select a Random Row using NHibernate's ICriteria API?</a></h3> <div class="excerpt">Can I select a random row using NHibernate's ICriteria API? </div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/nhibernate" class="post-tag grid--cell" title="show questions tagged 'nhibernate'" rel="tag">nhibernate</a> <a href="../../questions/tagged/random" class="post-tag grid--cell" title="show questions tagged 'random'" rel="tag">random</a> <a href="../../questions/tagged/icriteria" class="post-tag grid--cell" title="show questions tagged 'icriteria'" rel="tag">icriteria</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Apr 08 '09 at 12:15">asked Apr 08 '09 at 12:15</time> <a href="../../users/62664/andrey-selitsky" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/62664.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Andrey Selitsky" /> </a> <div class="s-user-card--info"> <a href="../../users/62664/andrey-selitsky" class="s-user-card--link">Andrey Selitsky</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">2,584</li> <li class="s-award-bling s-award-bling__gold" title="3 gold badges">3</li> <li class="s-award-bling s-award-bling__silver" title="28 silver badges">28</li> <li class="s-award-bling s-award-bling__bronze" title="42 bronze badges">42</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-636925"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>5</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/636925/nhibernate-projections-and-having-clause" class="question-hyperlink">NHibernate Projections and "Having" clause</a></h3> <div class="excerpt">I'm using NHibernate to query my database with the criteria API. My criteria is below: ICriteria c = Session.CreateCriteria(typeof(Transaction)); ProjectionList projections = Projections.ProjectionList(); projections.Add(Projections.Sum("Units"),…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/c#" class="post-tag grid--cell" title="show questions tagged 'c#'" rel="tag">c#</a> <a href="../../questions/tagged/nhibernate" class="post-tag grid--cell" title="show questions tagged 'nhibernate'" rel="tag">nhibernate</a> <a href="../../questions/tagged/icriteria" class="post-tag grid--cell" title="show questions tagged 'icriteria'" rel="tag">icriteria</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Mar 12 '09 at 00:25">asked Mar 12 '09 at 00:25</time> <a href="../../users/493/lomaxx" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/493.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="lomaxx" /> </a> <div class="s-user-card--info"> <a href="../../users/493/lomaxx" class="s-user-card--link">lomaxx</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">113,627</li> <li class="s-award-bling s-award-bling__gold" title="57 gold badges">57</li> <li class="s-award-bling s-award-bling__silver" title="144 silver badges">144</li> <li class="s-award-bling s-award-bling__bronze" title="179 bronze badges">179</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <div class="s-pagination--item is-selected">1</div> <a class="s-pagination--item" href="../../questions/tagged/icriteria_page=2" rel="" title="Go to page 2">2</a> <a class="s-pagination--item" href="../../questions/tagged/icriteria_page=3" rel="" title="Go to page 3">3</a> <div class="s-pagination--item s-pagination--item__clear">…</div> <a class="s-pagination--item" href="../../questions/tagged/icriteria_page=10" rel="" title="Go to page 10">10</a> <a class="s-pagination--item" href="../../questions/tagged/icriteria_page=11" rel="" title="Go to page 11">11</a> <a class="s-pagination--item" href="../../questions/tagged/icriteria_page=2" rel="next" title="Go to page 2"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>