How to view the generated SQL statement in nhib.pdf

Source: Internet
Author: User

Recently I want to use nhib.pdf to write a quick development framework.

When paging is implemented, you want to use the paging query method of nhib.pdf, but you do not know its paging principle.

Mainly database paging or false paging, which has a great impact on performance. Confirm.

However, after show_ SQL = true is configured, the generated SQL script cannot be seen.

It seems that log4net must be configured.

Later I found an article. Http://zhouweigang01.blog.163.com/blog/static/9340907201223093637530/

Introduced an excuse, very good, very reliable.

Therefore, we used this method to perform a tracking and found that it is indeed a database paging. Although rownum is used, the performance is generally enough.

Paste the Code:

Using system; using system. collections. generic; using system. LINQ; using system. text; using nhib.pdf. sqlcommand; namespace Dao {[serializable] public class emptyinterceptor: iinterceptor {// n lines of code earlier are omitted Public Virtual sqlstring onpreparestatement (sqlstring SQL) {return SQL ;} public void aftertransactionbegin (itransaction Tx) {// throw new notimplementedexception ();} public void after Transactioncompletion (itransaction Tx) {// throw new notimplementedexception ();} public void beforetransactioncompletion (itransaction Tx) {// throw new notimplementedexception ();} public int [] finddirty (Object entity, Object ID, object [] currentstate, object [] previusstate, string [] propertynames, nhib.pdf. type. itype [] types) {// throw new notimplementedexception (); return NULL;} public obje CT getentity (string entityname, Object ID) {// throw new notimplementedexception (); return NULL;} Public String getentityname (Object entity) {// throw new notimplementedexception (); return "";} public object instantiate (string entityname, entitymode, Object ID) {// throw new notimplementedexception (); return NULL;} public bool? Istransient (Object entity) {// throw new notimplementedexception (); Return true;} public void oncollectionrecreate (object collection, object key) {// throw new notimplementedexception ();} public void oncollectionremove (object collection, object key) {// throw new notimplementedexception ();} public void oncollectionupdate (object collection, object key) {// throw new notimplementedexception ();} public void ondelete (Object entity, Object ID, object [] State, string [] propertynames, nhib.pdf. type. itype [] types) {// throw new notimplementedexception ();} public bool onflushdirty (Object entity, Object ID, object [] currentstate, object [] previusstate, string [] propertynames, nhib.pdf. type. itype [] types) {// throw new notimplementedexception (); Return true;} public bool onload (Object entity, Object ID, object [] State, string [] propertynames, nhib.pdf. type. itype [] types) {// throw new notimplementedexception (); Return true;} public bool onsave (Object entity, Object ID, object [] State, string [] propertynames, nhib.pdf. type. itype [] types) {// throw new notimplementedexception (); Return true;} public void postflush (system. collections. icollection entities) {// throw new notimplementedexception ();} public void preflush (system. collections. icollection entities) {// throw new notimplementedexception ();} public void setsession (isession session) {// throw new notimplementedexception () ;}} public class myinterceptor: emptyinterceptor {public override nhib.pdf. sqlcommand. sqlstring onpreparestatement (nhib.pdf. sqlcommand. sqlstring SQL) {console. writeline (SQL. tostring (); Return base. onpreparestatement (SQL );}}}

Onpreparestatement can be rewritten in multiple ways. Here, console. writeline is the output console. In fact, I checked it through debug.

Of course, you can also write TXT text records.

Above

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.