CodePudding user response:
Even can be directly,CodePudding user response:
@ lorimoon hello, connect to the database I know can be connected directly, but I don't know use ADO.NET entity data model can connect?CodePudding user response:
Using sqlsugar orm can easily reach the dream database source DEMO at https://github.com/sunkaixuan/SqlSugarCodePudding user response:
A DmTest folder inside, as long as with good connection string manual build library, F5 to run automatically build table to run the DEMO,Create the Db object
SqlSugarClient db=new SqlSugarClient (new ConnectionConfig ()
{
The ConnectionString=Server="XXXXX",//connector string
DbType=DbType. Dm,
IsAutoCloseConnection=true,
InitKeyType=InitKeyType. Attribute//read from the characteristics of the primary key information on the
});
Query
Var getAll=db. QueryableToList () ();//query all
Var getFirst=db. Queryable(). The First (it=& gt; It. The Id=1);//query a single
Var getAllNoLock=db. Queryable(.) With (SqlWith. NoLock). ToList ();//is essentially the withnolock inside
Var getByPrimaryKey=db. Queryable(). InSingle (2);//query according to the primary key
Var sum=db. QueryableIt=(). The Sum (& gt; It. Id);//query combined
Var isAny=db. Queryable() Where (it=& gt; It. The Id==1). Any ();//if there is a
Var isAny2=db. Queryable(a). Any (it=& gt; It. Id==1);
Var getListByRename=db. Queryable(). AS (" Student "). ToList ();
Var getByWhere=db. Queryable() Where (it=& gt; It. The Id==1 | | it. The Name=="a".) ToList ();
Var list=db. Queryable(). AS (" student2019 "). ToList ();//select * from student2019
Var list2=db. Queryable() Where (it=& gt; It. The Name. The Contains (" jack ")). ToList ();//fuzzy query name like '%' + @ name + '%'