System. NullReferenceException generated when SubSonic3.0 plug-in uses SqlQuery or Select query

Source: Internet
Author: User

  

You have not set the object reference to the instance of the object.

Note:An unhandled exception occurred during the execution of the current Web request. Check the stack trace information for details about the error and the source of the error in the code.

Exception details:System. NullReferenceException: object reference is not set to the instance of the object.

Source error:

Row 168: foreach (Constraint constrain c) Row 169: {row 171: constrain. ColumnName = column. Name; row 172: constrain. ConstructionFragment = column. Name;

Source file:E: \ Asp.net \ ******* \ SubSonic. Core \ Query \ SqlQuery. csRow:170

Stack trace:

[NullReferenceException: object reference is not set to the instance of the object.] SubSonic. query. sqlQuery. where (Expression '1 expression) in E: \ Asp.net \ SubSonic. core \ Query \ SqlQuery. cs: 170 SubSonicTest. test. page_Load (Object sender, EventArgs e) in E: \ Asp.net \ SubSonicTest \ Test. aspx. cs: 19 System. web. util. calliEventHandlerDelegateProxy. callback (Object sender, EventArgs e) + 51 System. web. UI. control. onLoad (EventArgs e) + 92 System. web. UI. control. loadRecursive () + 54 System. web. UI. page. processRequestMain (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) + 772

  

After Tracing Through Debug, it is found that in the SqlQuery class condition adding function, after obtaining the generic class through reflection, find the condition column name and assign a value to the condition column, exception caused by this column not found

Modify the table object corresponding to the generic type to add a judgment. If it is null, modify the table object as follows:

  

  

SqlQuery Where <T> (Expression <Func <T,> expression) T: IList <Constraint> c = iTable = _ provider. findTable (iTable ===_ provider. findOrCreateTable <T> (Constraint constrain IColumn column ======View Code

 

  

After the above Code is added, you can use the SubSonic3.0 plug-in source code again.

 

Copyright:

This article was originally published by AllEmpty and published in the blog Park. You are welcome to repost it. You must retain this statement without your consent (otherwise, you will be entitled to pursue accountability) and provide the original article link clearly on the article page, if there is a problem, you can through 1654937@qq.comThank you very much for contacting me.

The content of this article, as long as the main and everyone to learn and make progress together, interested friends can add Q group: 327360708 or e-mail to me (1654937@qq.com), everyone to discuss.

For more information, visit the blog:

 

 

Related Article

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.