Update demo

This commit is contained in:
sunkaixuan 2022-09-29 19:55:27 +08:00
parent defebcf194
commit 4c76c2e594
2 changed files with 21 additions and 2 deletions

View File

@ -15,7 +15,7 @@ namespace OrmTest
/// Account have permission to create database
/// 用有建库权限的数据库账号
/// </summary>
public static string ConnectionString = "Server=120.79.19.7:10374;User Id=SYSDBA;PWD=Ldkie#21;DATABASE=DAMENG";
public static string ConnectionString = "Server=116.242.92.57:5511;User Id=S;PWD=S0718;DATABASE=DAMENG";
/// <summary>
/// Account have permission to create database
/// 用有建库权限的数据库账号

View File

@ -17,16 +17,35 @@ namespace OrmTest
DbType = DbType.Dm,
ConnectionString = Config.ConnectionString3,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true
IsAutoCloseConnection = true,
AopEvents = new AopEvents
{
OnLogExecuting = (sql, p) =>
{
Console.WriteLine(sql);
Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
}
}
});
// db.DbMaintenance.CreateDatabase();
if (db.DbMaintenance.IsAnyTable("CodeFirstTable1", false))
db.DbMaintenance.DropTable("CodeFirstTable1");
if (db.DbMaintenance.IsAnyTable("CodeFirstLong", false))
db.DbMaintenance.DropTable("CodeFirstLong");
db.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1
db.Insertable(new CodeFirstTable1() { Name = "a", Text="a" }).ExecuteCommand();
var list = db.Queryable<CodeFirstTable1>().ToList();
db.CodeFirst.InitTables<CodeFirstLong>();
var tableInfo=db.DbMaintenance.GetColumnInfosByTableName("CodeFirstLong", false);
Console.WriteLine("#### CodeFirst end ####");
}
}
public class CodeFirstLong
{
[SugarColumn(IsPrimaryKey =true,IsIdentity =true)]
public long id { get; set; }
}
public class CodeFirstTable1
{
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]