Skip to content

NH-3892 - Add ability to coalesce using a property instead of a constant #767

Closed
@nhibernate-bot

Description

@nhibernate-bot

Sergey A. Tachenov created an issue — 31st July 2016, 5:15:45:

Right now, NHibernate doesn't support things like this:

.Where(() => anAlias.Property.Coalesce(anotherAlias.AnotherProperty) == "something")

Instead, I have to write something as ridiculous as

.Where(Restrictions.EqProperty(
    Projections.SqlFunction("COALESCE", NHibernateUtil.Object,
        Projections.Property(() => anAlias.Property),
        Projections.Property(() => anotherAlias.AnotherProperty)),
    Projections.Constant("something")))

which is, of course, not fun. See my StackOverflow question for details and a workaround.

I'm willing to submit a pull request along with a test, but there's a catch: as it is, I can't really just add another Coalesce() overload because it would have exactly the same signature. Of course, I could just give it another name, but what name would be good? IfNull(), like in the StackOverflow answer? IfNullThen()? OrElse()?

Or maybe there is another way to resolve the signature conflict? I thought about using an expression, like Coalesce(() => anotherAlias.AnotherProperty), but due to the lack of experience with C# I couldn't write expression processing code for that. And besides, it's too verbose.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions