English 中文(简体)
• 如何与NHibernate建立扼制性格?
原标题:How to build string query with NHibernate?

我愿通过投影方式转播与NHibernate的询问。

SELECT ( reword#  || reword) || reword_faq as foo FROM me_review_entries re
WHERE ( reword#  || reword) || reword_faq =  reword#2#SOME_FAQ 

我这样做了。

Session.CreateCriteria<Reword>

但当时我不知道,我可以预测一下如何建立座标(<条码>(序号:p. > > > > > 序号:faq。

任何想法?

最佳回答

我根本不熟悉GreSQL员额,但希望这可能接近你们的需要。

var results = session.CreateCriteria<Reword>()
    .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<ReWordDTO>();

然后,如果需要,你可以将来自DTO的栏目编为产出。 也许需要增加一些替代条件,使之符合标准。

应生产这样的产品:

select Reword, Reword_faq
from me_review_entries
where reword=2
and reword_faq= SOME_FAQ 

这与你原来的询问相似,可能接近你所期待的。 我不敢确定,在你认为自己的价值观已经单独存在的条款中,你必须分门别类。

原文:

SELECT ( reword#  || reword) || reword_faq as foo FROM me_review_entries re
WHERE ( reword#  || reword) || reword_faq =  reword#2#SOME_FAQ 

是否可改写:

SELECT (reword || reword_faq) as foo 
FROM me_review_entries re
WHERE  (reword || reword_faq) =  2#SOME_FAQ 

什么时候可以改写?

SELECT (reword || reword_faq) as foo 
FROM me_review_entries re
WHERE  reword=2 and reword_faq= #SOME_FAQ 

虽然各栏中的数据可能意味着需要用文字说明。 如果情况是这样,你可以在标准中增加一些其他资源条件,使之发挥作用。

Another option would be to register a CustomSQLFunction.

RegisterFunction("concat", 
  new SQLFunctionTemplate(NHibernateUtil.String, "(?1 || ?2)"));

Registering Custom SQL Functions in NHibernate

var results = session.CreateQuery("select concat(reword,rewordfaq) 
  from Reword
  where concat(reword,rewordfaq)= 2#SOME_FAQ 
").List();
问题回答

暂无回答




相关问题
摘录数据

我如何将Excel板的数据输入我的Django应用? I m将PosgreSQL数据库作为数据库。

Postgres dump of only parts of tables for a dev snapshot

On production our database is a few hundred gigabytes in size. For development and testing, we need to create snapshots of this database that are functionally equivalent, but which are only 10 or 20 ...

How to join attributes in sql select statement?

I want to join few attributes in select statement as one for example select id, (name + + surname + + age) as info from users this doesn t work, how to do it? I m using postgreSQL.

What text encoding to use?

I need to setup my PostgreSQL DB s text encoding to handle non-American English characters that you d find showing up in languages such as German, Spanish, and French. What character encoding should ...

SQL LIKE condition to check for integer?

I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter "A": SELECT * ...

热门标签