2017-06-17 19:28:30 +08:00
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace OrmTest.Demo
|
|
|
|
|
{
|
2018-11-11 13:15:18 +08:00
|
|
|
|
[SugarTable("CodeTable", " table CodeTable")]
|
2017-06-17 19:28:30 +08:00
|
|
|
|
public class CodeTable
|
|
|
|
|
{
|
2017-06-18 05:29:42 +08:00
|
|
|
|
|
2018-11-11 13:15:18 +08:00
|
|
|
|
|
|
|
|
|
[SugarColumn(IsNullable =false ,IsPrimaryKey =true,IsIdentity =true,ColumnDescription ="XXhaha primary key!!")]
|
2017-06-17 19:28:30 +08:00
|
|
|
|
public int Id { get; set; }
|
2017-06-18 05:46:02 +08:00
|
|
|
|
[SugarColumn(Length = 21,OldColumnName = "Name2")]
|
|
|
|
|
public string Name{ get; set; }
|
2017-06-21 20:58:22 +08:00
|
|
|
|
public string IsOk { get; set; }
|
2017-06-17 20:28:15 +08:00
|
|
|
|
public Guid Guid { get; set; }
|
2017-07-03 02:07:35 +08:00
|
|
|
|
[SugarColumn(ColumnDataType ="int")]
|
2017-06-17 20:28:15 +08:00
|
|
|
|
public decimal Decimal { get; set; }
|
|
|
|
|
[SugarColumn(IsNullable = true)]
|
|
|
|
|
public DateTime? DateTime { get; set; }
|
2017-06-18 04:15:09 +08:00
|
|
|
|
[SugarColumn(IsNullable = true,OldColumnName = "Dob")]
|
|
|
|
|
public double? Dob2 { get; set; }
|
2017-08-26 01:57:24 +08:00
|
|
|
|
[SugarColumn(Length =11000)]
|
2017-06-25 19:16:10 +08:00
|
|
|
|
public string A1 { get; set; }
|
2017-08-26 01:57:24 +08:00
|
|
|
|
[SugarColumn(Length = 18,DecimalDigits=2)]
|
|
|
|
|
public decimal Dec { get; set; }
|
2017-06-17 19:28:30 +08:00
|
|
|
|
}
|
2017-06-18 01:44:00 +08:00
|
|
|
|
public class CodeTable2 {
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
public string Name { get; set; }
|
2017-06-18 04:15:09 +08:00
|
|
|
|
[SugarColumn(IsIgnore =true)]
|
|
|
|
|
public string TestId { get; set; }
|
2017-06-18 01:44:00 +08:00
|
|
|
|
}
|
2017-06-17 19:28:30 +08:00
|
|
|
|
public class CodeFirst : DemoBase
|
|
|
|
|
{
|
|
|
|
|
public static void Init()
|
|
|
|
|
{
|
|
|
|
|
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
|
|
|
|
|
{
|
|
|
|
|
ConnectionString = Config.ConnectionString,
|
|
|
|
|
DbType = DbType.SqlServer,
|
|
|
|
|
IsAutoCloseConnection = true,
|
2017-06-18 01:44:00 +08:00
|
|
|
|
InitKeyType = InitKeyType.Attribute
|
2017-06-17 19:28:30 +08:00
|
|
|
|
});
|
2017-06-18 01:44:00 +08:00
|
|
|
|
|
|
|
|
|
//Backup table
|
2017-06-18 04:15:09 +08:00
|
|
|
|
//db.CodeFirst.BackupTable().InitTables(typeof(CodeTable),typeof(CodeTable2));
|
2017-06-18 01:44:00 +08:00
|
|
|
|
|
|
|
|
|
//No backup table
|
2018-11-11 16:10:45 +08:00
|
|
|
|
db.CodeFirst.SetStringDefaultLength(10).InitTables(typeof(CodeTable),typeof(CodeTable2));
|
2017-06-17 19:28:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|