Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not familiar with postGreSQL at all but hopefully this might be close to what you need.</p> <pre><code>var results = session.CreateCriteria&lt;Reword&gt;() .SetProjection(Projections.ProjectionList() .Add(Projections.Property("reword"), "reword") .Add(Projections.Property("faq"), "faq") ) .Add(Restrictions.Eq("reword","2")) .Add(Restrictions.Eq("faq","SOME_FAQ")) .SetResultTransformer(new AliasToBeanResultTransformer(typeof(ReWordDTO))) .List&lt;ReWordDTO&gt;(); </code></pre> <p>You can then concat the columns from the DTO in code for output if needed. You might need to add some OR conditions to make it work in Criteria.</p> <p>Should produce SQL like this:</p> <pre><code>select Reword, Reword_faq from me_review_entries where reword=2 and reword_faq='SOME_FAQ' </code></pre> <p>Which is similar to your original query and might be close to what you are looking for. I'm not sure you need to concat the columns in your where clause seeing as you have the values separately already.</p> <p>Your original:</p> <pre><code>SELECT ('reword#' || reword) || reword_faq as foo FROM me_review_entries re WHERE ('reword#' || reword) || reword_faq = 'reword#2#SOME_FAQ' </code></pre> <p>Could it be re-written as?:</p> <pre><code>SELECT (reword || reword_faq) as foo FROM me_review_entries re WHERE (reword || reword_faq) = '2#SOME_FAQ' </code></pre> <p>Which could then be re-written as?:</p> <pre><code>SELECT (reword || reword_faq) as foo FROM me_review_entries re WHERE reword=2 and reword_faq='#SOME_FAQ' </code></pre> <p>Although the data in the columns might mean it needs to be written the way you describe. You could add some OR conditions into the criteria query to make it work if that is the case.</p> <p>Another option would be to register a CustomSQLFunction.</p> <pre><code>RegisterFunction("concat", new SQLFunctionTemplate(NHibernateUtil.String, "(?1 || ?2)")); </code></pre> <p><a href="http://ayende.com/blog/1720/using-sql-functions-in-nhibernate" rel="nofollow">Registering Custom SQL Functions in NHibernate</a></p> <pre><code>var results = session.CreateQuery("select concat(reword,rewordfaq) from Reword where concat(reword,rewordfaq)='2#SOME_FAQ' ").List(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload