FreeSql接入Abp
#1274
Replies: 3 comments 2 replies
-
abp 接入,建议不要替换,可以考虑共存。事务用 efcore,查询用 freesql。 freesql 支持像 dapper 那样的用法,文档《你不知道的功能》有介绍,由于 freesql 可以移动识别 efcore 实体注解,所以这种接入成本最低。 |
Beta Was this translation helpful? Give feedback.
1 reply
-
Ado.Net 扩展方法提供了类似 Dapper 的使用方法,FreeSql 增加了 IDbConnection/IDbTransaction 对象的扩展方法 Select/Insert/Update/Delete 实现 CRUD。 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);
//以上整个程序只需要设置一次
conn.Select<T>().Where(...).ToList();
conn.Insert(new T {}).ExecuteAffrows();
conn.Update().SetSource(new T {}).ExecuteAffrows();
conn.InsertOrUpdate().SetSource(new T {}).ExecuteAffrows();
conn.Delete<T>().Where(...).ExecuteAffrows();
}
利用本功能可以快速将 FreeSql 使用到项目中,只需要处理好实体类的特性。 提示:FreeSql 兼容 EFCore 99% 的实体特性 |
Beta Was this translation helpful? Give feedback.
0 replies
-
自然依旧要依赖EFCore,除非完全重新他的各个EFCore的模块,工作量比较大。 可参考这二个issues |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
使用FreeSql作为Abp的ORM的话,是不是会让Abp原来的一些默认功能无法兼容?类似于权限部分,需要依赖EFCore的包。
Beta Was this translation helpful? Give feedback.
All reactions