Nhibernate 中的 SelectList 和 Projection 有什么区别?

What is the difference of SelectList and Projection in Nhibernate?

正如标题所说。

(对我来说,SelectList 是一种无需使用 Projections 方法即可创建投影的方法。)

我想说文档中有完整的解释:

QueryOver allows arbitrary IProjection to be added (allowing private properties to be projected). The Projections factory class also has overloads to allow Lambda Expressions to be used:

IList selection =
    session.QueryOver<Cat>()
        .Select(Projections.ProjectionList()
            .Add(Projections.Property<Cat>(c => c.Name))
            .Add(Projections.Avg<Cat>(c => c.Age)))
        .List<object[]>();

In addition there is an inline syntax for creating projection lists that does not require the explicit class qualification:

IList selection =
    session.QueryOver<Cat>()
        .SelectList(list => list
            .Select(c => c.Name)
            .SelectAvg(c => c.Age))
        .List<object[]>();

Check 16.6. Projections