In Asp.net MVC, how does one make the class automatically generated by the LINQ designer inherit from another class and call its base class constructor?

Source: Internet
Author: User

Inheritance is relatively simple. For example, there is a class named text100 in designer. CS, which can be directly written in text. CS:

 
Public class text // This is the base class {private int _ length = 0; public text (INT length) {_ length = length ;}}

 

 
Public partial class text100: Text // This is the LINQ class already declared in designer {.... // The constructor cannot be written here, because the designer. written in CS}

 

The base class constructor cannot be called here, but you can call partial void oncreate () (declared in deisigner. CS) to complete the work that the constructor wants to do. The final result is:

 
Public class text // This is the base class {private int _ length = 0; // public text (INT length) // It seems to be commented out, otherwise it is always called. I have never tried to keep it. // {// _ Length = length; //} public partial class text100: Text // This is the LINQ class {void oncreate () that has been declared in designer () // complete the work of calling the constructor here. {_ Length = 100 ;}}

This oncreate () has a partial version in the definition of text100, which is the only sentence in the text100 Constructor (which can be found in designer. CS). In other words, it is used to solve the problem of base class constructor.

 

This automatically generated class also has many on... functions, which can solve other basic class calling problems.

 

Click to download the free agile development textbook: Martian agile development manual

 

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.