mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +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 ####");
|
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 ####");
|
Console.WriteLine("#### DbMain End ####");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,16 +19,29 @@ namespace OrmTest
|
|||||||
DbType = DbType.SqlServer,
|
DbType = DbType.SqlServer,
|
||||||
ConnectionString = Config.ConnectionString,
|
ConnectionString = Config.ConnectionString,
|
||||||
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.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 ####");
|
Console.WriteLine("#### Aop End ####");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user