Domestic - Dameng database and its addition, deletion, modification and query under. Net. ORM

1, Introduction

I happened to see the domestic database - Dameng database. Suddenly became interested and made a fuss.

The following introduction is taken from Baidu Encyclopedia

Dameng database is a high-performance database product with completely independent intellectual property rights launched by Wuhan Huagong Dameng database Co., Ltd. It adopts the security management mechanism of "separation of powers", and the security level reaches level B1. It has made breakthroughs and improvements in large data storage management, concurrency control, data query optimization, transaction processing, backup and recovery and support for SMP system. More about: http://baike.baidu.com/view/581717.htm

Dameng database has free version and paid version (I feel that Chinese people are a little eager for quick success and instant benefit).

Free version download address: https://www.dameng.com/

There are windows and Linux versions.

 

2, Installation

I choose to download the Windows version here. The current version is 6.2, and the UI is still very beautiful.  

The installation process is very simple. Just "next step" all the way:

2.1)   Select language version

 

2.2)   Select the verification Key file. The verification file is provided in the free download package.  

 

2.3) setting initialization parameters  

 

  2.4) modify the database password (password), of course, you can ignore it. The default password is SYSDBA

 

 

 

3, Use

 

3.1)   Open the tube   Log in to "management tool Manager"  

 

Enter the password set during installation. If the password is not modified during installation, enter the default password "SYSDBA" for initial test  

3.2)   After logging in, you can see that the SYSTEM has two databases "SYSTEM" and "boothop" by default. Here I have created a new database called "cnlogs". Creating a new is very simple, similar to operating SQL server.  

 

  3.3)   Click the "cnblogs" node, and you will find that unlike SQL server, it directly includes "table" and "view".

Under it is "schema". A database can have multiple schemas, and only under the schema can there be "table", "view" and so on.

 

  Schema is used to represent a set of objects in a specific database. Conceptually, it can be regarded as a set of objects containing tables, views, indexes and permission definitions. A schema only works on one database. Different databases can have schemas with the same name.

  I created a "Users" table under the schema "SYSDBA".

3.4)   Damon SQL   

Because Damon database has a concept of "pattern", its query statements and SQL Server   It is also different. Add "mode" before "table". For example:

 

select  *  from  SYSDBA.Users

  Of course, you can write directly like in SQL server without adding  

 

   select * from  Users 

At this time, it will use SYSDBA mode by default.

 

3, ORM   Operation of Damon database

.net framework   Install sqlsugar

.net 5&.net core   Installing sqlsugarcore

nuget only needs to reference a dll file, which is easy to use out of the box

 

4, Connection string

  It is closer to Oracle, more inclined to independent research and development, and less friendly to developers than Jincang  

  As for other domestic databases, they are basically the same as 99.9% of PgSQL. It is recommended that you use NPC gold warehouse to save your worry

  Connection string:

  Old version: PORT=5236;DATABASE=DAMENG;HOST=localhost;PASSWORD=SYSDBA;USER ID=SYSDBA

  New version: Server=localhost;   User   Id=SYSDBA;   PWD=SYSDBA;DATABASE = new DB

 

5, CURD

Create database object

 //Create database object SqlSugarClient   
 SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
 {
            ConnectionString = "Server=.xxxxx",//Connector string
            DbType = DbType.Dm, //Set to Da Meng
            IsAutoCloseConnection = true //Not set as true To manually close
 });

query

db.Queryable<Student>().ToList()//Query all
db.Queryable<Student>().Where(it=>it.Id==1).ToList()//Query by criteria

//paging

  int pageIndex = 1; // pageindex starts with 1, not zero
  int pageSize = 20;
  int totalCount=0;
  //Single table paging
  var page = db.Queryable<Student>().ToPageList(pageIndex, pageSize, ref totalCount);

insert

//Returns the number of inserted rows
db.Insertable(insertObj).ExecuteCommand(); //Are parameterized
 
//Insert return auto increment column
db.Insertable(insertObj).ExecuteReturnIdentity();
 
//Return to snowflake ID Look at document 3.1 Specific usage (at the bottom)
long id= db.Insertable(entity).ExecuteReturnSnowflakeId();

delete

//Single entity
db.Deleteable<Student>().Where(new Student() { Id = 1 }).ExecuteCommand();
 
//List<entity>
List<Student> list=new List<Student>(){
  new Student() { Id = 1 }
};
db.Deleteable<Student>(list).ExecuteCommand(); //Batch delete

to update

//Update a single parameter according to the primary key Class
var result= db.Updateable(updateObj).ExecuteCommand();
 
 
//Batch update parameters List<Class>
var result= db.Updateable(updateObjs).ExecuteCommand();

 

Source code:

https://github.com/donet5/SqlSugar

Tags: orm

Posted on Thu, 11 Nov 2021 04:11:01 -0500 by Tuck