As long as people make mistakes, as long as the software will have bugs, even if he is nhibernate
nhibernate1.2 supports Access databases. But I've been developing it with SQL Server. Now that I've got a little bit, I'm on the whim of switching the database to access to see how the execution works.
Touch, make a mistake. SQL statement syntax error. Damn, there was a mistake, change, try again? or an error. Depressed. Interrupt point to Start debugging, make sure my code is not wrong. I'm right, so who's wrong? NHibernate?? No way? But things have been done, and it is impossible to write again, had to bite the bullet, hehe. The nhibernate of the reference to remove, directly referencing the source code of the NHibernate to start debugging, did not think Ah did not think, incredibly actually was I to find the bug came.
When NHibernate handles access, it uses the Jetdriver dialect. Because of the particularity of access (which must be parentheses when the SQL statement is connected), the SQL statement is processed in the jetdriver. Code here: There are 96 lines in Jetdriver.cs.
Private SqlString Finalizejoins (SqlString sqlstring)
{
if (_querycache.contains (SqlString))
{
Return (SqlString) _querycache[sqlstring];
}
Fix WXY
int beginoffrom = sqlstring.indexofcaseinsensitive ("from");
int endoffrom = sqlstring.indexofcaseinsensitive ("where");
if (Beginoffrom < 0)
{
return sqlstring;
}
if (Endoffrom < 0)
{
Endoffrom = Sqlstring.length;
}
String FromClause = Sqlstring.substring (Beginoffrom, Endoffrom-beginoffrom). ToString ();
String transformedfrom = Transformfromclause (FromClause);
Put it all together again
Sqlstringbuilder final = new Sqlstringbuilder (Sqlstring.count + 1);
Final. ADD (sqlstring.substring (0, Beginoffrom));
Final. ADD (Transformedfrom);
Final. ADD (sqlstring.substring (Endoffrom));
SqlString ret = final. Tosqlstring ();
_querycache[sqlstring] = ret;
return ret;
}