Time back to the 2010, then still familiar with the code generation + basic framework of this model, the basic development idea is to generate the entity through the code generator, and then generate the interface and implementation class, and finally drag the control, write interface data binding code. Basically is the dynamic code generator gives the pattern, or Microsoft's Repository Factory mode of practice, infatuated with Microsoft's Enterprise Libray, this framework is from the application Block evolved. Well, I'm kind of. NET technology promotion, the first batch of study. NET technology developers.
have been looking for an interface and logic separation technology, there is no idea, the result of the above code generation is that the logic code distributed in various parts of the system, changing a field or adding fields need to be regenerated once, to the stability of the system is troubled. A model summarized in the enterprise Application architecture model is the transactional script (Transaction scripts), but this model is well understood and does not have a complex technology stack, and by mastering this pattern, the. NET learner becomes a skilled. NET code worker.
The first time I saw Llbl Gen Pro, it grew this way:
LLBL Gen Pro 2.5/2.6 is a classic version of its development history, the query interface is stable and mature, encountered problems to go to tinyform on a post, after a while there will be professional staff response to reply. After more than half a year of learning, familiar with the use of this ORM framework, the beginning of a higher level of custom development, its template editor as shown in the following diagram:
LLBL Gen Pro starts with the 3.x and changes the original binary project file LGP to XML-formatted file llblgenproj. This is a very important change,
Because the entity properties for the final mapping of database properties can be modified in the designer, you must read the LLBL Gen Pro project file to determine the final mapped property name. My auxiliary development tool also relies on this feature of the Llblgenproj project file, which is not possible in the LLBL Gen Pro 2.x era.
My colleague then made an ORM-based code generation tool to generate the entity interface and implementation code, as explained below:
database table salesorder–> Entity salesorderentity Interface isalesordermanager–> Interface Implementation Salesordermanager
The next two steps are the work to be done, and the prototypes of the tools designed by colleagues are as follows:
For nearly 3 years, I was fascinated by the interface and implementation class code generated by this tool. It was not until later that the client kept on making changes to the details of the interface and implementation that I was slowly unable to endure. NET code to write code generator, but also to compile the distress. At that time, colleagues are highly recommended template generation technology, so with Code Smith wrote the template code, continues to today. Share the code Smith generated interface:
<%@ codetemplate language="C #"Targetlanguage="C #"Src=""inherits=""debug="True"description="Template description here."%><%@ Property Name="Entitypicker"Type="ISL. Extension.entitypickerproperty "Optional="False"category="Project"description="This property uses a custom modal dialog editor."%><%@ Property Name="AssemblyFile"Type="System.String"default=""Optional="False"category="Project"description=""Editor="System.Windows.Forms.Design.FileNameEditor"%> <%@ Assembly name="System.Data"%><%@ Import namespace="System.Data"%><%@ Assembly name="ISL. Empower.extension "%><%@ Import namespace="ISL. Extension "%><%@ Import namespace="System.Collections.Generic"%><%@ Assembly name="SD.LLBLGen.Pro.ORMSupportClasses.NET20"%> <%@ Import namespace="SD. LLBLGen.Pro.ORMSupportClasses "%><script runat="Template"> Public stringentityname{get {returnEntitypicker.entityname; }} Public stringshortentityname{get {returnEntityname.substring (0,entityname.length-6); }} Public stringfullentityname{get {return string. Format ("{0}. Entityclasses. {1} ", Businesslogicprojectname, EntityName); }}Private string_businesslogicprojectname; Public stringbusinesslogicprojectname{get {if(string. Isnullorwhitespace (_businesslogicprojectname)) _businesslogicprojectname=entityclasshelper.prefixprojectname ( AssemblyFile);return_businesslogicprojectname; } } Public stringentityparamerlist{get {IEntity2 policy = entityclasshelper.getentityobject (assemblyfile, Entitypicker.entit Yname);stringParm =string. Empty; list<string> parms=Newlist<string> ();foreach(IEntityField2 FieldinchPolicy. Primarykeyfields) {parm =string. Format (' {0} {1} ', field. Datatype.name, field. Name); Parms. ADD (Parm); }return string. Join (",", Parms. ToArray ()); }} Public stringEntitylowercasename {get {returnEntityPicker.EntityName.Substring (0, 1). ToLower () + EntityPicker.EntityName.Substring (1); }} </script>usingSystem;usingSystem.Collections.Generic;usingSystem.Data;usingSystem.Text;usingSd. LLBLGen.Pro.ORMSupportClasses;using<%=BusinessLogicProjectName%>;using<%=businesslogicprojectname%>. factoryclasses;using<%=businesslogicprojectname%>. entityclasses;using<%=businesslogicprojectname%>. helperclasses;using<%=businesslogicprojectname%>. interfaceclasses;using<%=businesslogicprojectname%>. databasespecific;namespace<%=businesslogicprojectname%>. interfaceclasses{ Public Interface I<%=shortentityname%>manager {<%=EntityName%> get<%=shortentityname%> (Guid sessionid,<%= Entityparamerlist%>); <%=EntityName%> get<%=shortentityname%> (Guid sessionid,<%=entityparamerlist%>,iprefetchpath2 Prefetchpath); <%=EntityName%> get<%=shortentityname%> (Guid sessionid,<%=entityparamerlist%>,iprefetchpath2 Prefetchpath,excludeincludefieldslist fieldlist); Entitycollection get<%=shortentityname%>collection (Guid sessionid,irelationpredicatebucket filterBucket); Entitycollection get<%=shortentityname%>collection (Guid sessionid,irelationpredicatebucket FilterBucket, Isortexpression sortexpression); Entitycollection get<%=shortentityname%>collection (Guid sessionid,irelationpredicatebucket FilterBucket, Isortexpression SortExpression, IPrefetchPath2 Prefetchpath); Entitycollection get<%=shortentityname%>collection (Guid sessionid,irelationpreDicatebucket Filterbucket, Isortexpression sortexpression, IPrefetchPath2 Prefetchpath, excludeincludefieldslist FieldList); <%=EntityName%> save<%=shortentityname%> (Guid sessionid,<%=entityname%> <%= entitylowercasename%>); <%=EntityName%> save<%=shortentityname%> (Guid sessionid,<%=entityname%> <%= Entitylowercasename%>, Entitycollection entitiestodelete); <%=EntityName%> save<%=shortentityname%> (Guid sessionid,<%=entityname%> <%= Entitylowercasename%>, Entitycollection Entitiestodelete,stringSeriescode);voidDelete<%=shortentityname%> (Guid sessionid,<%=entityname%> <%=EntityLowercaseName%>);BOOLIs<%=shortentityname%>exist (Guid sessionid,<%=entityparamerlist%>);BOOLIs<%=shortentityname%>exist (Guid sessionid,irelationpredicatebucket filterbucket);intGet<%=shortentityname%>count (Guid sessionid,irelationpredicatebucket filterbucket); <%=EntityName%> clone<%=shortentityname%> (Guid sessionid,<%=entityparamerlist%>);voidPost<%=shortentityname%> (Guid sessionid,<%=entityparamerlist%>);voidPost<%=shortentityname%> (Guid sessionid,<%=entityname%> <%=EntityLowercaseName%>); }}
Then Microsoft introduced the T4 template code generation tool, there was a time to change code Smith into a T4 template, Code Smith 5.x does not support. NET3.5, some of the extension methods written by the. NET class library, the code Smith template is not available, which is why you want to turn it into a T4 template. However on the internet to find a smart hint, syntax highlighting T4 template editor is quite difficult to find a trial version in foreign countries, there is no cracked version, and then there is no full power to toss. Code Smith 6.x fully supports. NET 3.5, which continues to be used today.
With the help of Llbl Gen Pro, together with some of the previously accumulated public code libraries, a set of original ERP system molding, refer to the following view:
In this project, three public base class libraries were abstracted, public method Common, common control WinUI, and public program core. Then the hard drive is lost, I can't find the source code of this project, but the design idea and the project structure have been clear to the chest.
By 2012, it was exposed to the Infragistics interface control package, which almost rewritten the entire WinForms control, providing very rich properties. At that time, the company purchased the license for this set of controls to see all the source code of the control. But most of the time not to see the source code, only to encounter an incomprehensible error, will be tracked into the source code to see if the parameters are properly passed.
The combination of entities and controls that support strongly typed objects has far-reaching implications for later programming careers. Although there are occasional DataTable uses, the large-area development model is still using entity + data binding.
. NET data binding is another area that requires deep learning, with data binding, the following code can be omitted:
//get value from Control string refno=txtrefno.text; //set value to controltxtrefno.text="SO201507190001";
You only need to bind the entity to the BindingSource control, and the controls on the entire interface all have values that don't have to be assigned the code above.
protected Override void Bindcontrols (EntityBase2 entity) { base. Bindcontrols (entity); Inventorymovemententity inventorymovement = (inventorymovemententity) entity; Inventorymovementbindingsource.datasource = inventorymovement;}
For WinForms Development, a large number of values and assignment operation codes are omitted, the code is reduced, and the system maintainability is improved.
Basically here, I have been able to independently develop the system, the various parts of the system can be handled well, my development steps are as follows:
1 Design Database tables. A number of case tools have been found to help build SQL Server datasheets, and finally, to return to SQL Server Management Studio, which is the simplest tool to use and facilitates communication with colleagues. When two of people use database design tools differently, and some minor errors or differences occur, it is often maddening.
2 Llbl Gen Pro generates entities to set up inter-entity relationships. Basically, you connect to the database, refresh the entities, generate or update the entity files.
3 generates an interface and implementation class for entity reads and writes. High efficiency with the Code Smith template
4 Drag the interface, bind the data source control. Even if you have not learned to program, you can quickly get started with a short training development interface.
5 Add business logic code to Entities, interface and logic separation. This is where you write your code, writing business logic that contains computational logic and validation logic.
Contact LLBL Gen Pro Object-Relational mapping framework and the future becomes brighter