Llbl Gen Pro 4.2 Lite Free Object Relational Mapping development framework and tools

Source: Internet
Author: User

Llbl Gen Pro is an excellent framework for object-relational mapping and has a broad customer base since its release in 2003. Llbl Gen Pro has several iconic versions, 2.5/2.6 is a very stable version, and some of the company's old projects still use this version. 3.1 Change the project's file to XML format (llblgenproj), greatly facilitates and simplifies the third-party tool interaction with Llbl Gen, the code generation template used in my project generates the interface and implementation file, even with the help of parsing its XML format file. 3.1 also modifies the order of the parameters of the generated entity. For example, the 2.5/2.6 version of the delivery Order detail entity code is as follows:

Public shipmentdetailentity (System.String refno,system.decimal entryno): Base ("Shipmentdetailentity")
{
Initclassempty (null, NULL);
This. fields["Entryno"]. CurrentValue = Entryno;
This. fields["Refno"]. CurrentValue = REFNO;
}

3.1 will generate the following code

Public shipmentdetailentity (System.Decimal Entryno, System.String refno): Base ("Shipmentdetailentity")
{
Initclassempty (null, NULL);
This. fields["Entryno"]. CurrentValue = Entryno;
This. fields["Refno"]. CurrentValue = REFNO;
}

Note that the parameter order of the two constructors is different, the 2.x is generated in the order in which the primary key is defined in the database, and 3.1 is based on the alphabetical order of the primary key.

Then to LLGL Gen Pro 3.5,3.5 abandoned the traditional entitycollection, no longer maintain entitycollection design mode, and choose Microsoft Recommended BindingSource Control, Binds the BindingSource control directly to a strongly typed entity definition.

LLBL Gen Pro 4.2 Lite main interface as shown:

Lite Edition does not use the time limit to limit the creation of only 8 entities for an item. The actual project development may not be enough, a practical project usually has dozens of hundred tables, but doing project practice or study is enough.

Humorous, 7.20 Microsoft officially publishes Visual Studio 2015, and also provides a full-featured version of Visual Studio Comunitiy Edition, which can be used for the development of non-commercial software. Such strategies can make progress in technology and tools, and customers who use the free version can also offer many reasonable and constructive suggestions. Some domestic software also provides such a strategy, while promoting their own software, the free version is completely free to use, including basic features, while maintaining some high-level features for paying users. Also some extreme do very unfriendly software: Baidu network disk client Baidu Cloud, in does not provide accelerated download function before, speed is very fast, launched the accelerated download service, no paid users download slow as snail, usually 2MB download speed fell to about 300K, this let free user sentiment why. This is a bit like Enterprise mailbox, free mailbox users support paid users, if not these free users in use, in the promotion, paid users will certainly be large area fled. The same is the network disk function, the enterprise's paid users to share a file, free users to read, the latter because of the speed of the experience is too bad, the ultimate impact is the loss of paid users.

Enterprise Application Architecture Patterns A pattern of two organizational domain logic is mentioned in the book: Transactional scripting (Transaction script) and domain model. The former is what we typically do in encapsulating SQL statements into a type definition file, and the logical organization is implemented by encapsulating calls to SQL statements to see an example of a transactional script (Transaction scripts):

interface layer, directly read the class to get the data:

DataTable table = Database.getpendingdesigntask (Database.connnection_string_company, Database.userid);
Table. Columns.Add ("Submitdrawing", typeof (String));
Table. Columns.Add ("submitsubmited", typeof (String));
Designtaskbindingsource.datasource = table;
Griddesigntask.datasource = Designtaskbindingsource;

The logical Layer database class defines the following methods:

public static DataTable Getpendingdesigntask (string connectionString, string designer)
{
DataTable table=new DataTable ("Query");
string query = @ "SELECT [Recnum],[refno], [Entryno],[taskno], [scheduledate]
, [Projectno], [Projectname],[orderno],[itemno],[contractno]
, [Designer],[reviewer],[closed],[closedby], [closeddate]
, [confirmed], [Confirmdate], [Confirmby], [Path]
, [Drawing], [submitdate], [submited], [reviewed]
, [Reviewdate], [contractproduct], [CheckIn]
, [Checkindate], [Checkinby],[libraryfoldername]
, [Libraryfullpath], [ecnpath],[ecndrawing]
From [Pdmdesigntaskdetail] WHERE confirmed= ' Y ' and submited= ' N ' and designer= ' {0} ' ";
Table=sqlhelper.executedatatable (connectionString, String. Format (query, designer));
return table;
}

In a transactional script, the logical organization is implemented through code combination SQL statement calls.

Look again at the domain model:

interface layer, only data binding

protected override void Bindcontrols (EntityBase2 entity)
{
Base. Bindcontrols (entity);
This.salesBindingSource.DataSource = entity;

}

Logical Layer Posting Logic Section code example:

private void Processpaymentdetail (Guid sessionId, accountspayablepaymentdetailentity Accountspayablepaymentdetail)
{
          Iaccountspayableinvoicemanager Accountspayableinvoicemapager = clientproxyfactory.createproxyinstance< Iaccountspayableinvoicemanager> ();
          if (!accountspayableinvoicemapager.isinoviceexist ( SessionId, Accountspayablepaymentdetail.invoctrlno))
               return;

          accountspayableinvoiceentity Apinvoice = Accountspayableinvoicemapager.getaccountspayableinvoice (sessionId, Accountspayablepaymentdetail.invoctrlno, NULL );
          this. Updatesettledinvoice (Apinvoice, Accountspayablepaymentdetail);
          this. Updatesettlementsledger (SessionId, Accountspayablepaymentdetail);

accountspayablepaymentdetail.posted = false;
Accountspayablepaymentdetail.settledamt = 0m;
Accountspayablepaymentdetail.logno = 0m;
Accountspayablepaymentdetail.invrounddiff = 0m;
Accountspayablepaymentdetail.lastlogno = Apinvoice.lastlogno;

Accountspayableinvoicemapager.saveaccountspayableinvoice (SessionId, Apinvoice);
}

The logical way of organizing is object-oriented programming, the object's interactive invocation.

After a few years of object-oriented programming, the code that encounters the type of transactional script is even intolerable. I list some practical experiences of object-relational mapping for readers ' reference:

1 keeps track of the value source or calculation method of a variable. This is an issue that management software often encounters and tracks how a field is calculated. For transactional scripting, you need tools such as SQL Server Profiler to track changes in values, or to search for related program code calls with field names, and if you're using a domain model, you'll often just need to place a breakpoint at the computed assignment method and start the caller:

This picture is simple to set a set breakpoint on the Trancount property, the simple action contains a profound meaning, in the debug state, all the places assigned to the Trancount will pause the following to facilitate the calculation of the observation value.

If you have a ReSharper plugin installed, right-click on the variable name and choose Find Usage to render the following window:

With this function, it is not necessary to debug the source code in a simple case to know how to calculate the variable. This method is often used in maintaining large-scale systems and is also a manifestation of the good maintainability of object-oriented programming.

2 The SQL statement is generated when the field value has changed. The transactional script or domain pattern is ultimately generated by generating SQL statements that are sent to the database engine for execution. If it is a transactional script, write a field update statement directly, as in the following example

public static void Updatependingdesigntaskforsubmitapproval (String connectionString, String Refno,decimal entryno, String drawing)
{
string query = String. Format ("UPDATE pdmdesigntaskdetail SET submited= ' Y ', [path]= ' {2} ', [drawing]= ' {2} ', Submitdate=getdate () WHERE refno= ' {0} ' and Entryno={1} ', Refno, Entryno, drawing);
Sqlhelper.executenonquery (connectionString, query);
}

Such code can be very bad as the number of parameters is different. When I need to modify, increase the field value update of the set part, it will cause need to modify the SQL statement and interface file, it is very troublesome to maintain.

For the domain model, LLBL Gen Pro detects whether the field value changes when the UPDATE statement is generated, and does not generate an UPDATE statement for the SQL set section if there is no change.

So, no matter how many controls are modified on the interface, the saved code is always the same sentence:

Adapter. Saveentity (Inventorymovement, True, false);

Maintainability aspects of throwing a business script a few blocks.

3 Object-oriented advantages (encapsulation, inheritance, polymorphism) are embodied in the project based on object-relational mapping, which brings great convenience to project development and maintenance.

Llbl Gen Pro's built-in entity features:

Provides a set of validation frameworks: Include field validation, entity validation, delete validation, save validation, update validation

Example code for the validation type:

[Serializable]
public partial class Accountvalidator:validatorbase
{
ADD your own validation code between the region markers below. You can also with a partial class and add your overrides in that partial class.
__llblgenpro_user_code_region_start Validationcode
public override void Validateentitybeforedelete (Ientitycore involvedentity)
{
Base. Validateentitybeforedelete (involvedentity);

            accountentity account = (accountentity) involvedentity;
            Relationpredicatebucket filterbucket = new Relationpredicatebucket ();
            FilterBucket.PredicateExpression.Add ( Voucherdetailfields.acctno = = account. ACCTNO);

Ivoucherdetailmanager Voucherdetailmanager = clientproxyfactory.createproxyinstance<ivoucherdetailmanager> ( );
if (Voucherdetailmanager.isvoucherdetailexist (Shared.currentusersessionid, Filterbucket))
throw new Entityvalidationexception (account. Acctno, "cannot delete. Voucher entry for account exists ");
}

Provides a set of expression methods for relationships between objects: the association reference between objects and the master-slave relationship is easy to get started and handled, everything is an object.

The example of the query relation of master and slave table, indicates the warehouse entry and exit details under warehouse documents, and the batch number and the cargo grid are also referenced at the same time.

Private IPrefetchPath2 Defaultprefetchpath
{
Get
{
IPrefetchPath2 Prefetchpath = new PrefetchPath2 ((int) entitytype.inventorymovemententity);
IPrefetchPathElement2 element = Prefetchpath.add (inventorymovemententity.prefetchpathinventorymovementdetails);
Element. Subpath.add (Inventorymovementdetailentity.prefetchpathinventorymovementbins);
element = element. Subpath.add (inventorymovementdetailentity.prefetchpathinventorymovementlots);
Element. Subpath.add (inventorymovementlotentity.prefetchpathinventorymovementserials);

return prefetchpath;
}
}

Provide several sets of query syntax, convenient data query. LLBL Gen Pro provides the following query syntax:

Traditional writing, this kind of writing is good in generality, can be directly generated by the code generator.

Inventorymovemententity inventorymovement = new inventorymovemententity (REFNO);
BOOL found = adapter. Fetchentity (inventorymovement, Prefetchpath, NULL, fieldlist);

Queryspec's wording:

Query. ("FullName"). Ascending ());

LINQ notation:

var trans = new Transaction (isolationlevel.readcommitted, "sstest");
var metaData = new Linqmetadata (trans);
var q = from C in metadata.customers select C;

The latter two kinds of writing seldom used in the actual development, the experience is insufficient.

Summarize the basic features provided by the LLBL Gen Development framework:

1 code generator (GUI or console), you can regenerate the entity definition when the field changes or increases or decreases the entity.

2 validation framework that provides validation of the value of an object or object.

3 query syntax, you can retrieve data in an object-oriented manner.

4 The expression of the object relationship. LLBL Gen Pro can generate master-slave relationships between objects based on the master-slave relationship of the database to facilitate data manipulation.

The general Entity code generator based on the database table, can not be implemented or flexible and simple implementation of the following 3, in code development speed and maintainability far less than Llbl Gen Pro.

Llbl Gen Pro 4.2 Lite Free Object Relational Mapping development framework and tools

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.