开发者

How to use Dynamic Instantiation with ICriteria in Nhibernate?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜