mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-04 15:30:53 +08:00
update
8
AOP.md
8
AOP.md
@@ -8,10 +8,10 @@ FreeSql 支持简单的类似功能:
|
||||
|
||||
```csharp
|
||||
fsql.Aop.CurdAfter += (s, e) => {
|
||||
if (e.ElapsedMilliseconds > 200) {
|
||||
//记录日志
|
||||
//发送短信给负责人
|
||||
}
|
||||
if (e.ElapsedMilliseconds > 200) {
|
||||
//记录日志
|
||||
//发送短信给负责人
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
38
骚操作.md
38
骚操作.md
@@ -170,8 +170,8 @@ fsql.Select<Goods>().IncludeMany(a => a.Comment.Take(10));
|
||||
```csharp
|
||||
//定义临时类,也可以是 Dto 类
|
||||
class Dto {
|
||||
public int TypeId { get; set; }
|
||||
public List<Goods > GoodsList { get; set; }
|
||||
public int TypeId { get; set; }
|
||||
public List<Goods > GoodsList { get; set; }
|
||||
}
|
||||
|
||||
//查询 Goods 商品表,分类1、分类2、分类3 各10条数据
|
||||
@@ -427,16 +427,16 @@ fsql.Aop.CurdAfter += (s, e) => {
|
||||
|
||||
```csharp
|
||||
fsql.Aop.AuditValue += (s, e) => {
|
||||
if (e.Column.CsType == typeof(long)
|
||||
&& e.Property.GetCustomAttribute<SnowflakeAttribute>(false) != null
|
||||
&& e.Value?.ToString() == 0)
|
||||
e.Value = new Snowflake().GetId();
|
||||
if (e.Column.CsType == typeof(long)
|
||||
&& e.Property.GetCustomAttribute<SnowflakeAttribute>(false) != null
|
||||
&& e.Value?.ToString() == 0)
|
||||
e.Value = new Snowflake().GetId();
|
||||
};
|
||||
|
||||
class Order {
|
||||
[Snowflake]
|
||||
public long Id { get; set; }
|
||||
//...
|
||||
[Snowflake]
|
||||
public long Id { get; set; }
|
||||
//...
|
||||
}
|
||||
```
|
||||
|
||||
@@ -455,19 +455,19 @@ using FreeSql;
|
||||
|
||||
using (var conn = new SqlConnection(...))
|
||||
{
|
||||
IFreeSql fsql = conn.GetIFreeSql();
|
||||
fsql.CodeFirst.IsNoneCommandParameter = true;
|
||||
fsql.CodeFirst.IsSyncStructureToUpper = true;
|
||||
fsql.Aop.CommandBefore += (_, e) => Trace.WriteLine(e.Command.CommandText);
|
||||
//以上整个程序只需要设置一次
|
||||
IFreeSql fsql = conn.GetIFreeSql();
|
||||
fsql.CodeFirst.IsNoneCommandParameter = true;
|
||||
fsql.CodeFirst.IsSyncStructureToUpper = true;
|
||||
fsql.Aop.CommandBefore += (_, e) => Trace.WriteLine(e.Command.CommandText);
|
||||
//以上整个程序只需要设置一次
|
||||
|
||||
conn.Select<T>().Where(...).ToList();
|
||||
conn.Select<T>().Where(...).ToList();
|
||||
|
||||
conn.Insert(new T {}).ExecuteAffrows();
|
||||
conn.Update().SetSource(new T {}).ExecuteAffrows();
|
||||
conn.InsertOrUpdate().SetSource(new T {}).ExecuteAffrows();
|
||||
conn.Insert(new T {}).ExecuteAffrows();
|
||||
conn.Update().SetSource(new T {}).ExecuteAffrows();
|
||||
conn.InsertOrUpdate().SetSource(new T {}).ExecuteAffrows();
|
||||
|
||||
conn.Delete<T>().Where(...).ExecuteAffrows();
|
||||
conn.Delete<T>().Where(...).ExecuteAffrows();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user