My CMS Development Note-3

Source: Internet
Author: User

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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.