mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 16:18:47 +08:00
Update Demo
This commit is contained in:
parent
3f34cea687
commit
b28ab059c5
35
Src/Asp.Net/SqlServerTest/Demo/DemoE_CodeFirst.cs
Normal file
35
Src/Asp.Net/SqlServerTest/Demo/DemoE_CodeFirst.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
public class DemoE_CodeFirst
|
||||||
|
{
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
|
||||||
|
{
|
||||||
|
DbType = DbType.SqlServer,
|
||||||
|
ConnectionString = Config.ConnectionString,
|
||||||
|
InitKeyType = InitKeyType.Attribute,
|
||||||
|
IsAutoCloseConnection = true
|
||||||
|
});
|
||||||
|
|
||||||
|
db.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CodeFirstTable1
|
||||||
|
{
|
||||||
|
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
[SugarColumn(ColumnDataType = "Nvarchar(255)")]//custom
|
||||||
|
public string Text { get; set; }
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,7 @@ namespace OrmTest
|
|||||||
Demo1_SqlSugarClient.Init();
|
Demo1_SqlSugarClient.Init();
|
||||||
Democ_GobalFilter.Init();
|
Democ_GobalFilter.Init();
|
||||||
DemoD_DbFirst.Init();
|
DemoD_DbFirst.Init();
|
||||||
|
DemoE_CodeFirst.Init();
|
||||||
|
|
||||||
//Unit test
|
//Unit test
|
||||||
NewUnitTest.Init();
|
NewUnitTest.Init();
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
<Compile Include="Demo\DemoC_GobalFilter.cs" />
|
<Compile Include="Demo\DemoC_GobalFilter.cs" />
|
||||||
<Compile Include="Demo\Demo1_Queryable.cs" />
|
<Compile Include="Demo\Demo1_Queryable.cs" />
|
||||||
<Compile Include="Demo\DemoD_DbFirst.cs" />
|
<Compile Include="Demo\DemoD_DbFirst.cs" />
|
||||||
|
<Compile Include="Demo\DemoE_CodeFirst.cs" />
|
||||||
<Compile Include="Models\MyCustomAttributeTable.cs" />
|
<Compile Include="Models\MyCustomAttributeTable.cs" />
|
||||||
<Compile Include="Models\Order.cs" />
|
<Compile Include="Models\Order.cs" />
|
||||||
<Compile Include="Models\OrderItem.cs" />
|
<Compile Include="Models\OrderItem.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user