mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
-
This commit is contained in:
parent
14d556fe5c
commit
57ef4c1b0e
40
Src/Asp.Net/SqlServerTest/Demo/DemoD_DbFirst.cs
Normal file
40
Src/Asp.Net/SqlServerTest/Demo/DemoD_DbFirst.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
public class DemoD_DbFirst
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
DbType = DbType.SqlServer,
|
||||
ConnectionString = Config.ConnectionString,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
IsAutoCloseConnection = true,
|
||||
AopEvents = new AopEvents
|
||||
{
|
||||
OnLogExecuting = (sql, p) =>
|
||||
{
|
||||
Console.WriteLine(sql);
|
||||
}
|
||||
}
|
||||
});
|
||||
db.DbFirst.CreateClassFile("c:\\Demo\\1", "Models");
|
||||
|
||||
|
||||
db.DbFirst.Where("Student").CreateClassFile("c:\\Demo\\2", "Models");
|
||||
|
||||
|
||||
db.DbFirst.Where(it => it.ToLower().StartsWith("view")).CreateClassFile("c:\\Demo\\3");
|
||||
|
||||
db.DbFirst.Where(it => it.ToLower().StartsWith("view")).CreateClassFile("c:\\Demo\\4");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ namespace OrmTest
|
||||
|
||||
Demo1_SqlSugarClient.Init();
|
||||
Democ_GobalFilter.Init();
|
||||
DemoD_DbFirst.Init();
|
||||
|
||||
Console.WriteLine("all successfully.");
|
||||
Console.ReadKey();
|
||||
|
@ -51,6 +51,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Demo\Democ_GobalFilter.cs" />
|
||||
<Compile Include="Demo\Demo2_Queryable.cs" />
|
||||
<Compile Include="Demo\DemoD_DbFirst.cs" />
|
||||
<Compile Include="Models\MyCustomAttributeTable.cs" />
|
||||
<Compile Include="Models\Order.cs" />
|
||||
<Compile Include="Models\OrderItem.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user