update

28810
2020-03-26 23:53:18 +08:00
parent a804ff1cd3
commit 838335c00d
4 changed files with 10 additions and 9 deletions

8
AOP.md

@@ -7,7 +7,7 @@ FreeSql AOP 已有的功能介绍,未来为会根据用户需求不断增强
FreeSql 支持简单的类似功能:
```csharp
fsql.Aop.CurdAfter = (s, e) => {
fsql.Aop.CurdAfter += (s, e) => {
if (e.ElapsedMilliseconds > 200) {
//记录日志
//发送短信给负责人
@@ -72,7 +72,7 @@ A 为了考虑一致性用法,全部封装在 ColumnAttribute 下,这样
FreeSql 提供 AOP 自定义特性功能,实现与多个 orm 共同拥有一套实体特性,可避免重复定义特性。
```csharp
fsql.Aop.ConfigEntity = (s, e) => {
fsql.Aop.ConfigEntity += (s, e) => {
var attr = e.EntityType.GetCustomAttributes(
typeof(System.ComponentModel.DataAnnotations.Schema.TableAttribute), false).FirstOrDefault()
as System.ComponentModel.DataAnnotations.Schema.TableAttribute;
@@ -81,7 +81,7 @@ fsql.Aop.ConfigEntity = (s, e) => {
//e.ModifyIndexResult.Add(new IndexAttribute("idx_xx", "Title")); //索引
};
fsql.Aop.ConfigEntityProperty = (s, e) => {
fsql.Aop.ConfigEntityProperty += (s, e) => {
if (e.Property.GetCustomAttributes(
typeof(System.ComponentModel.DataAnnotations.KeyAttribute), false).Any())
e.ModifyResult.IsPrimary = true; //主键
@@ -99,7 +99,7 @@ FreeSql 内部表达式支持非常丰富,对各大数据库的兼容度也做
即便如此丰富也仍然无法满足用户需求FreeSql 对外开放了自定义表达式解析接口:
```csharp
fsql.Aop.ParseExpression = (s, e) => {
fsql.Aop.ParseExpression += (s, e) => {
if (e.Expression.NodeType == Call && e.Expression.Name == "get_Item")
e.Result = "1111";
};

@@ -20,6 +20,7 @@
- 增加 延时属性重写类对 protected set 的支持;
- 优化 ConnectionPool 提升被动连接断开的体验(会卡的可以升级);
- 调整 Repository 接口定义,合并为一个 IBaseRepository
- 优化 集合导航属性表达式中忘记使用 AsSelect() 的友好错误提示;
## v1.2.1

@@ -3,13 +3,13 @@
```csharp
fsql.CodeFirst.ConfigEntity<ModelAopConfigEntity>(a => a.Property(b => b.pkid).IsPrimary(true));
fsql.Aop.ConfigEntity = (s, e) => {
fsql.Aop.ConfigEntity += (s, e) => {
var attr = e.EntityType.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.Schema.TableAttribute), false).FirstOrDefault() as System.ComponentModel.DataAnnotations.Schema.TableAttribute;
if (attr != null)
e.ModifyResult.Name = attr.Name; //表名
//e.ModifyIndexResult.Add(new IndexAttribute("idx_xx", "Title")); //索引
};
fsql.Aop.ConfigEntityProperty = (s, e) => {
fsql.Aop.ConfigEntityProperty += (s, e) => {
if (e.Property.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.KeyAttribute), false).Any())
e.ModifyResult.IsPrimary = true; //主键
};

@@ -286,12 +286,12 @@ var sql1 = fsql.Select<SysModule>()
抛砖引玉以下的示例代码FreeSql 使用 EFCore 的实体特性:
```csharp
fsql.Aop.ConfigEntity = (s, e) => {
fsql.Aop.ConfigEntity += (s, e) => {
var attr = e.EntityType.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.Schema.TableAttribute), false).FirstOrDefault() as System.ComponentModel.DataAnnotations.Schema.TableAttribute;
if (attr != null)
e.ModifyResult.Name = attr.Name; //表名
};
fsql.Aop.ConfigEntityProperty = (s, e) => {
fsql.Aop.ConfigEntityProperty += (s, e) => {
if (e.Property.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.KeyAttribute), false).Any())
e.ModifyResult.IsPrimary = true; //主键
};
@@ -315,7 +315,7 @@ class ModelAopConfigEntity {
FreeSql 支持简单的类似功能:
```csharp
fsql.Aop.CurdAfter = (s, e) => {
fsql.Aop.CurdAfter += (s, e) => {
if (e.ElapsedMilliseconds > 200) {
//记录日志
//发送短信给负责人