Knowledge management system data solution R & D diary 15th Data Storage Technology llbl Gen ORM + db4o

Source: Internet
Author: User
Tags configuration settings

This seriesArticleAs mentioned in section 15th, the technology to be explained today is the data storage technology used by data solution.

Because I am used to ORM development, the first response to database-related content is to use Orm, which greatly simplifies data read/write.CodeWrite volume.

Data solution data storage also uses the llbl Gen ORM framework,Source codeThe view

When you see the databasegeneric and databasespecific folders, this project may be written using the llbl Gen ORM framework.

Let's take a look at what it looks like in The ORM designer. There are only four basic data tables, respectively storing documents, document categories, notes, and settings.

Here, the auto-increment seed ID is used as the primary key of the data table to simplify the operation. Relative to 2. llbl Gen of X, 3. the X Series open the project file format. Its project file llblgenproj is an XML file that saves the project configuration settings and ing relationships between entities and tables, you can use XML technology to perform secondary development or read and write the required project data. In my ERP development tool series, there is a small tool that parses this project file.

Save the. NETProgramYes.

PublicDocumententity savedocument (documententity DOC ){Using(Dataaccessadapter adapter = getdataaccessadapter ()){Try{Adapter. starttransaction (isolationlevel. readcommitted,"Savedocument"); Adapter. saveentity (Doc,True,False); Adapter. Commit ();}Catch{Adapter. rollback ();Throw;}}ReturnDoc ;}
 
 

Code for deleting a document

Public VoidDeletedocument (IntEntid) {documententity Doc =NewDocumententity (entid );Using(Dataaccessadapter adapter = getdataaccessadapter () {Adapter. deleteentity (DOC );}}

If you have llbl Gen development experience, these codes are all template Code and are directly generated using the code generator. See the following code Smith diagram.


Upload the parameter table name to the written code Smith template to quickly generate the corresponding entity read/write code. The accumulation of templates is very important at ordinary times. When it comes to use, you can easily complete the work.

However, code generation cannot complete all the work, and some code still needs to be written. For example:

    1. Clear the code of all documents. If you use a code generator to write the code, it will write it like this.
Public VoidClearalldocument (){Using(Dataaccessadapter adapter = getdataaccessadapter () {excludeincludefieldslist fields =NewExcludeincludefieldslist (False); Fields. Add (documentfields. recnum); entitycollection <documententity> docs = getdocumentcollection (Null,Null,Null, Fields );Foreach(Documententity dInDocs) {deletedocument (D. recnum );}}}
 
 

This is fetch first, and then delete. If there are many documents in the database, this is obviously unreasonable. Even if you see it, it reads only one field.

SQL statements should be directly sent to the database server, which is the fastest speed.

DeleteDocument --Or--Truncate TableDocument

2. the batch import function cannot be directly generated. The interface and Implementation Code are as follows:

 
 Public Static VoidRtfbatchimport (String[] Files ){Foreach(StringFileInFiles) {import (File );}}Public Static VoidImport (StringFile) {documentmanager manager =NewDocumentmanager ();StringSubject = path. getfilenamewithoutextension (File); manager. savedocument (file, subject );}

Interface provides a string array, indicating a group of file names. The system then reads the file from the disk to the memory, creates a documententity object, and writes the file to the memory.

 

let's look at the rule Saving Method in the Rule editor. It uses db4o to save the rule. Because the Access Jet. oledb cannot run in the x64 environment, access is not used as a rule database. The rules are not stored in SQL Server, although it is easy to do so. The basic requirement of a rule is that it can be moved and shared. After developing the system, you also need to provide some basic rules for customers to learn and study. In this way, a small file storage rule is the best choice, without any software installation. Therefore, you can use db4o's object manager to open the rule file, which is a db40 data file. If you want to learn the code, the following basic example can be used as a reference

  using  (iobjectcontainer DB = db4oembedded. openfile (yapfilename )) { // do something with db4o }< SPAN class = "REM"> // save  pilot pilot1 =  New  pilot ( "Michael Schumacher" , 100); dB. store (pilot1 );  // retrieve  pilot proto =  New  pilot ( null , 0); iobjectset result = dB. querybyexample (PROTO);  // update  iobjectset result = dB. querybyexample ( New  pilot ( "Michael Schumacher" , 0 )); pilot found = (pilot) result. next (); found. addpoints (11); dB. store (found);  // Delete  iobjectset result = dB. querybyexample ( New  pilot ( "Michael Schumacher" , 0 )); pilot found = (pilot) result. next (); dB. delete (found); 

This is a basic example of db4o. You can go to the official website to find more in-depth examples. The rule Storage Method of Data solution is to use the db4o database to read and write rules with its managed API.

 

Go to epn.codeplex.com to download the latest data loader program.

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.