mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update demo
This commit is contained in:
parent
1e6f2496ad
commit
ee05df69f6
@ -29,7 +29,12 @@ namespace OrmTest
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var entityInfo = db.EntityMaintenance.GetEntityInfo<Order>();
|
||||
foreach (var column in entityInfo.Columns)
|
||||
{
|
||||
Console.WriteLine(column.DbColumnName);
|
||||
}
|
||||
//more https://github.com/sunkaixuan/SqlSugar/wiki/9.EntityMain
|
||||
Console.WriteLine("#### EntityMain End ####");
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,12 @@ namespace OrmTest
|
||||
}
|
||||
});
|
||||
|
||||
var tables = db.DbMaintenance.GetTableInfoList();
|
||||
foreach (var table in tables)
|
||||
{
|
||||
Console.WriteLine(table.Description);
|
||||
}
|
||||
//more https://github.com/sunkaixuan/SqlSugar/wiki/a.DbMain
|
||||
Console.WriteLine("#### DbMain End ####");
|
||||
}
|
||||
}
|
||||
|
@ -19,16 +19,29 @@ namespace OrmTest
|
||||
DbType = DbType.SqlServer,
|
||||
ConnectionString = Config.ConnectionString,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
IsAutoCloseConnection = true,
|
||||
AopEvents = new AopEvents
|
||||
{
|
||||
OnLogExecuting = (sql, p) =>
|
||||
{
|
||||
Console.WriteLine(sql);
|
||||
Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
|
||||
}
|
||||
}
|
||||
IsAutoCloseConnection = true
|
||||
});
|
||||
db.Aop.OnLogExecuted = (sql, pars) => //SQL executed event
|
||||
{
|
||||
Console.WriteLine("OnLogExecuted"+sql);
|
||||
};
|
||||
db.Aop.OnLogExecuting = (sql, pars) => //SQL executing event (pre-execution)
|
||||
{
|
||||
Console.WriteLine("OnLogExecuting" + sql);
|
||||
};
|
||||
db.Aop.OnError = (exp) =>//SQL execution error event
|
||||
{
|
||||
//exp.sql
|
||||
};
|
||||
db.Aop.OnExecutingChangeSql = (sql, pars) => //SQL executing event (pre-execution,SQL script can be modified)
|
||||
{
|
||||
return new KeyValuePair<string, SugarParameter[]>(sql, pars);
|
||||
};
|
||||
|
||||
|
||||
|
||||
db.Queryable<Order>().ToList();
|
||||
db.Queryable<OrderItem>().ToList();
|
||||
|
||||
Console.WriteLine("#### Aop End ####");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user