mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 10:08:19 +08:00
-
This commit is contained in:
12
OrmTest/Demo/Delete.cs
Normal file
12
OrmTest/Demo/Delete.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest.Demo
|
||||
{
|
||||
class Delete
|
||||
{
|
||||
}
|
||||
}
|
12
OrmTest/Demo/Insert.cs
Normal file
12
OrmTest/Demo/Insert.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest.Demo
|
||||
{
|
||||
class Insert
|
||||
{
|
||||
}
|
||||
}
|
77
OrmTest/Demo/Query.cs
Normal file
77
OrmTest/Demo/Query.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using OrmTest.Models;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest.Demo
|
||||
{
|
||||
public class Query
|
||||
{
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
Easy();
|
||||
Page();
|
||||
Where();
|
||||
Join();
|
||||
Funs();
|
||||
Select();
|
||||
}
|
||||
|
||||
public static void Easy()
|
||||
{
|
||||
var db = GetInstance();
|
||||
var getAll = db.Queryable<Student>().ToList();
|
||||
var getByPrimaryKey = db.Queryable<Student>().InSingle(2);
|
||||
var getByWhere = db.Queryable<Student>().Where(it => it.Id == 1 || it.Name == "a").ToList();
|
||||
var getByFuns = db.Queryable<Student>().Where(it => NBORM.IsNullOrEmpty(it.Name)).ToList();
|
||||
}
|
||||
|
||||
public static void Page()
|
||||
{
|
||||
|
||||
}
|
||||
public static void Where()
|
||||
{
|
||||
var db = GetInstance();
|
||||
//join
|
||||
var list = db.Queryable<Student, School>((st, sc) => new object[] {
|
||||
JoinType.Left,st.SchoolId==sc.Id
|
||||
})
|
||||
.Where<School>(sc => sc.Id == 1)
|
||||
.Where<Student>(st => st.Id == 1)
|
||||
.Where<Student, School>((st, sc) => st.Id == 1 && sc.Id == 2).ToList();
|
||||
|
||||
//SELECT [st].[Id],[st].[SchoolId],[st].[Name],[st].[CreateTime] FROM [Student] st
|
||||
//Left JOIN School sc ON ( [st].[SchoolId] = [sc].[Id] )
|
||||
//WHERE ( [sc].[Id] = @Id0 ) AND ( [st].[Id] = @Id1 ) AND (( [st].[Id] = @Id2 ) AND ( [sc].[Id] = @Id3 ))
|
||||
}
|
||||
public static void Join()
|
||||
{
|
||||
|
||||
}
|
||||
public static void Funs()
|
||||
{
|
||||
|
||||
}
|
||||
public static void Select()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static SqlSugarClient GetInstance()
|
||||
{
|
||||
SqlSugarClient db = new SqlSugarClient(new SystemTablesConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
|
||||
db.Ado.IsEnableLogEvent = true;
|
||||
db.Ado.LogEventStarting = (sql, pars) =>
|
||||
{
|
||||
Console.WriteLine(sql + "\r\n" + db.RewritableMethods.SerializeObject(pars));
|
||||
Console.WriteLine();
|
||||
};
|
||||
return db;
|
||||
}
|
||||
}
|
||||
}
|
12
OrmTest/Demo/Update.cs
Normal file
12
OrmTest/Demo/Update.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest.Demo
|
||||
{
|
||||
class Update
|
||||
{
|
||||
}
|
||||
}
|
@@ -56,6 +56,10 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Config.cs" />
|
||||
<Compile Include="Demo\Delete.cs" />
|
||||
<Compile Include="Demo\Insert.cs" />
|
||||
<Compile Include="Demo\Query.cs" />
|
||||
<Compile Include="Demo\Update.cs" />
|
||||
<Compile Include="Models\ViewModelStudent.cs" />
|
||||
<Compile Include="PerformanceTesting\ChloeORMPerformance.cs" />
|
||||
<Compile Include="PerformanceTesting\PerformanceBase.cs" />
|
||||
@@ -90,9 +94,7 @@
|
||||
<Name>SqlSugar</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Demo\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
@@ -17,7 +17,7 @@ namespace OrmTest
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
/***Unit Test***/
|
||||
///***Unit Test***/
|
||||
//new Field(1).Init();
|
||||
//new Where(1).Init();
|
||||
//new Method(1).Init();
|
||||
@@ -25,16 +25,16 @@ namespace OrmTest
|
||||
//new SingleQuery(1).Init();
|
||||
//new SelectQuery(1).Init();
|
||||
//new AutoClose(1).Init();
|
||||
new Insert(1).Init();
|
||||
//new Insert(1).Init();
|
||||
//new Delete(1).Init();
|
||||
//new Update(1).Init();
|
||||
//new Mapping(1).Init();
|
||||
|
||||
/***Performance Test***/
|
||||
///***Performance Test***/
|
||||
//new SqlSugarPerformance(100).Select();
|
||||
|
||||
|
||||
//Demo
|
||||
/***Demo***/
|
||||
OrmTest.Demo.Query.Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user