开发者

How to use Dynamic Instantiation with ICriteria in Nhibernate?

开发者 https://www.devze.com 2022-12-20 19:15 出处:网络
I know that you can do this easily with HQL using the following syntax: \"select new ItemRow开发者_Go百科(item.id, item.name) from ...\"

I know that you can do this easily with HQL using the following syntax:

"select new ItemRow开发者_Go百科(item.id, item.name) from ..."

In this example, the ItemRow need not be a persistent class that has its own mapping class.

But how can we accomplish the same using ICriteria?


Pretty sure that is equivalent to...

.SetProjection(Projections.ProjectionList()
    .Add(Projections.Property("item.id"), "id")
    .Add(Projections.Property("item.name"), "name"))
.SetResultTransformer(Transformers.AliasToBean<ItemRow>())
.List<ItemRow>();
0

精彩评论

暂无评论...
验证码 换一张
取 消