Yeah, I know that there are many questions of this subject open and answered in stackoverflow, but none solved my problem.
I'm trying to compare two strings in where clause of QueryOver, but I had the error “variable '' of type '' referenced from scope '', but it is not defined”. I don't know what I'm doing wrong and didn't find an example for my case. Can anyone help me?
That's my code:
var queryOverPaciente = _session.QueryOver(() => pacienteAlias).
Where(() => pacienteAlias.DataCadastro.Value.IsBetween(dataInicio).And(dataFinal));
// Other things....
// the error occurs here. "Identificacao" and "MatriculaInicio" are strings
// and I want to select all registers that "Identificacao" >= "MatriculaInicio".
queryOverPaciente = queryOverPaciente.Where(p =>
p.Identificacao.CompareTo(filtroRelatorio.MatriculaInicio) >= 0);
This statement (the issue above)
representing comparison defined in C# as
string.CompareTo(VALUE):so these are sort of equal:
and with SQL, we can express it directly:
Back to our NH/C# solution. We can define it like this
A curiosity - to handle even the NULL as stated in C# definition above, we can for example add
ISNULLstatement (more general and suitableCOALESCEin fact)