mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-26 10:10:56 +08:00
update
8
AOP.md
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";
|
||||
};
|
||||
|
||||
1
更新日志.md
1
更新日志.md
@@ -20,6 +20,7 @@
|
||||
- 增加 延时属性重写类对 protected set 的支持;
|
||||
- 优化 ConnectionPool 提升被动连接断开的体验(会卡的可以升级);
|
||||
- 调整 Repository 接口定义,合并为一个 IBaseRepository;
|
||||
- 优化 集合导航属性表达式中忘记使用 AsSelect() 的友好错误提示;
|
||||
|
||||
## v1.2.1
|
||||
|
||||
|
||||
4
自定义特性.md
4
自定义特性.md
@@ -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; //主键
|
||||
};
|
||||
|
||||
6
骚操作.md
6
骚操作.md
@@ -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) {
|
||||
//记录日志
|
||||
//发送短信给负责人
|
||||
|
||||
Reference in New Issue
Block a user