Browse Source

Update demo

pull/12/MERGE
sunkaixuan 6 years ago
parent
commit
ee05df69f6
  1. 7
      Src/Asp.Net/SqlServerTest/Demo/Demo9_EntityMain.cs
  2. 6
      Src/Asp.Net/SqlServerTest/Demo/DemoA_DbMain.cs
  3. 31
      Src/Asp.Net/SqlServerTest/Demo/DemoB_Aop.cs

7
Src/Asp.Net/SqlServerTest/Demo/Demo9_EntityMain.cs

@ -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 ####");
}
}

6
Src/Asp.Net/SqlServerTest/Demo/DemoA_DbMain.cs

@ -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 ####");
}
}

31
Src/Asp.Net/SqlServerTest/Demo/DemoB_Aop.cs

@ -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…
Cancel
Save