Errors written by the orchard module and Their Solutions

Source: Internet
Author: User

Some unexpected errors occurred while writing the custom module. When solving these problems, we deepened our understanding of orchard development.

1. When a part is edited, the part interface is not always displayed.

Check all the files and find that the service is not added to the constructor in the partdriver class,

Original statement:

   Public   Class Fixedassetpartdriver: contentpartdriver <fixedassetpart> {  Private   Readonly  Inotifier _ notifier;  Private   Const   String Templatename = "  Parts/fixedasset "  ;  Private   Readonly  Ifixedassetservice _ service;  Protected   Override   String  Prefix {  Get { Return   "  Fixedasset  "  ;}}  Public Localizer t { Get ; Set  ;}  Public  Fixedassetpartdriver (inotifier notifier)  //  Public fixedassetpartdriver (inotifier notifier, ifixedassetservice Service)  {_ Notifier = Notifier;  //  _ Service = service; T = Nulllocalizer. instance ;} 

Updated statement:

 PublicFixedassetpartdriver (inotifier notifier, ifixedassetservice Service) {_ notifier=Notifier; _ service=Service; t=Nulllocalizer. instance ;}
 
IfixedassetserviceThe data called by her is not instantiated, so it cannot appear, and no Part Page is displayed.

2. When updating data, the error of null ID is displayed, and no reason is found for a few days. I read the latest document and found that I did not pay attention to the details.
See the originalCode:
  Public   Class Fixedassetpart: contentpart <fixedassetpartrecord> {  Public   String Assetcode {  Get { Return  Record. assetcode ;}  Set {Record. assetcode = Value ;}}  Public   String  Assetname {  Get { Return  Record. assetname ;}  Set {Record. assetname =Value ;}}  Public   String  Brand {  Get { Return  Record. Brand ;}  Set {Record. Brand = Value ;}}  Public   Decimal  Assetvalue {  Get { Return Record. assetvalue ;}  Set {Record. assetvalue = Value ;}}  Public  Assetbuymethodrecord assetbuymethod {  Get { Return  Record. assetbuymethod ;}  Set {Record. assetbuymethod = Value ;}} 

Migration class:

Schemabuilder. createtable ( Typeof (Fixedassetpartrecord). Name, T => T. contentpartrecord (). Column < String > ( "  Assetcode  "  ). Column < String > ( "  Assetname  "  ). Column < String > ("  Brand  "  ). Column < Decimal > ( "  Assetvalue  "  ). Column < Int > ( "  Assetbuymethodrecord_id  "  )); 

The relationship between fixedassetpartrecord and assetbuymethodrecord is one-to-many. The columns in all fixedassetpartrecord tables should beAssetbuymethodrecord_id,

In fact, it should be the name of the fixedassetpart attribute plus _ id, that isAssetbuymethod_ Id

Therefore, the Migration. CS table creation should be:

Schemabuilder. createtable ( Typeof  (Fixedassetpartrecord). Name, T => T. contentpartrecord (). Column < String > ( "  Assetcode  "  ). Column <String > ( "  Assetname  "  ). Column < String > ( "  Brand  "  ). Column < Decimal > ( "  Assetvalue  "  ). Column < Int > ( "  Assetbuymethod_id  "  )); 

It took me three days to find the reason for such a small detail.

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.