mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Update demo
This commit is contained in:
parent
defebcf194
commit
4c76c2e594
@ -15,7 +15,7 @@ namespace OrmTest
|
|||||||
/// Account have permission to create database
|
/// Account have permission to create database
|
||||||
/// 用有建库权限的数据库账号
|
/// 用有建库权限的数据库账号
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// Account have permission to create database
|
/// Account have permission to create database
|
||||||
/// 用有建库权限的数据库账号
|
/// 用有建库权限的数据库账号
|
||||||
|
@ -17,16 +17,35 @@ namespace OrmTest
|
|||||||
DbType = DbType.Dm,
|
DbType = DbType.Dm,
|
||||||
ConnectionString = Config.ConnectionString3,
|
ConnectionString = Config.ConnectionString3,
|
||||||
InitKeyType = InitKeyType.Attribute,
|
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();
|
// 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.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1
|
||||||
db.Insertable(new CodeFirstTable1() { Name = "a", Text="a" }).ExecuteCommand();
|
db.Insertable(new CodeFirstTable1() { Name = "a", Text="a" }).ExecuteCommand();
|
||||||
var list = db.Queryable<CodeFirstTable1>().ToList();
|
var list = db.Queryable<CodeFirstTable1>().ToList();
|
||||||
|
db.CodeFirst.InitTables<CodeFirstLong>();
|
||||||
|
var tableInfo=db.DbMaintenance.GetColumnInfosByTableName("CodeFirstLong", false);
|
||||||
Console.WriteLine("#### CodeFirst end ####");
|
Console.WriteLine("#### CodeFirst end ####");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class CodeFirstLong
|
||||||
|
{
|
||||||
|
[SugarColumn(IsPrimaryKey =true,IsIdentity =true)]
|
||||||
|
public long id { get; set; }
|
||||||
|
}
|
||||||
public class CodeFirstTable1
|
public class CodeFirstTable1
|
||||||
{
|
{
|
||||||
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
||||||
|
Loading…
Reference in New Issue
Block a user