Skip to content

Coalesce Error: Not to be used directly - use inside QueryOver expression #2273

Closed
@fairking

Description

@fairking

Could someone please look if it's a bug?
NHibernate 5.2.6 (net.core)
Dialect: NHibernate.Dialect.MsSql2008Dialect
Driver: NHibernate.Driver.SqlClientDriver,NHibernate
Db: MSSQL 14.0.2027.2
The following query throws an exception:

queryOver
    .Select(new[]
    {
        Projections.Property(() => root.Id).WithAlias(() => vm.Id),
        Projections.Property(() => root.FullName).Coalesce(Projections.Property(() => root.UserName)).WithAlias(() => vm.Name),
    });

The exception is:

System.InvalidOperationException: Not to be used directly - use inside QueryOver expression
   at NHibernate.Criterion.ProjectionsExtensions.Coalesce[T](T objectProperty, T replaceValueIfIsNull)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions