First, let's take a look at my own architecture diagram.
Here we are, just for this ibll bll dal idal.
First we need to join the Idal class library, define the Ibasedal interface
This interface has only one function, the definition of common methods, such as additions and deletions and so on, remember that this is to be written in generics, because his sons are to inherit it OH
Here for the time being only write these few, adding or deleting change to submit OK complete.
And then what needs to be done is the corresponding basedal in the DAL layer.
This only need to inherit this ibasedal, implement the inside of the four or five interface method can, here is the generic type Oh, pay attention to their word base know this is Father class
Then some people will ask these methods are less ah, not enough to do, good at this time need special interface for special methods
Case, we have a form table, the role of the form is to take the table name of other tables
Establishing the Iformdal interface
Then you think about how to write, of course, this is the following, think about this method in addition to the traditional additions and deletions to do what needs to do, here is very good to write
namespacewhblog.idal{//data Interface for form write-take Public InterfaceIformdal:ibasedal<form> { //get the table name based on Formid stringGettablename (intFormID); //Build Index This gets the name string This[intIndex] {Get;Set; } //gets the displayed Formid array based on the permission ID int[] Getformids (intRoleflag); }}
Here inherit the IBase interface, then the following three are self-directed to their own form
Finally, it's formdal.
Here class implements this interface Iformdal, and inherits this Basedal this class (here is very important, because: if this does not inherit this basedal, the consequence is, you each special word class needs to implement each to increase the pruning to investigate the basic method, is not the trouble to die, We give the implementation of the basic method interface to the Basedal class to implement Ibasedal, the basic interface, and then our special class only need to inherit this basedal class can get it all)
Then implement the following two methods to
Public classFormdal:basedal<form>, Iformdal { Public string This[intIndex] { Get { Throw Newnotimplementedexception (); } Set { Throw Newnotimplementedexception (); } } Public int[] Getformids (intRoleflag) { Throw Newnotimplementedexception (); } Public stringGettablename (intFormID) { Throw Newnotimplementedexception (); } }
Basically done, the BLL ibll himself to write, I will not say
Daily keywords -170304-.net,c# layered architecture common sense