You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicinterfaceITenant{stringTenantId{get;set;}}publicclassSong:ITenant{publicstringTenantId{get;set;}}publicclassSongContext:DbContext{privatestring_tenantId;publicDbSet<Song>Songs{get;set;}publicSongContext(IHttpContextAccessorhttpContextAccessor){_tenantId=httpContextAccessor.HttpContext.Request.Headers["TenantId"];}protectedoverridevoidOnModelCreating(ICodeFirstcodefirst){codefirst.AddQueryFilter<ITenant>( t =>t.TenantId==_tenantId);}}
publicclassPublishController:Controller{privatereadonlyICapPublisher_capBus;publicPublishController(ICapPublishercapPublisher){_capBus=capPublisher;}[Route("~/adonet/transaction")]publicIActionResultAdonetWithTransaction(){using(varconnection=newMySqlConnection(ConnectionString)){using(vartransaction=connection.BeginTransaction(_capBus,autoCommit:true)){//your business logic code_capBus.Publish("xxx.services.show.time",DateTime.Now);}}returnOk();}[Route("~/ef/transaction")]publicIActionResultEntityFrameworkWithTransaction([FromServices]AppDbContextdbContext){using(vartrans=dbContext.Database.BeginTransaction(_capBus,autoCommit:true)){//your business logic code_capBus.Publish("xxx.services.show.time",DateTime.Now);}returnOk();}}
publicinterfaceITenant{stringTenantId{get;set;}}publicclassSong:ITenant{publicstringTenantId{get;set;}}publicclassSongContext:DbContext{privatestring_tenantId;publicDbSet<Song>Songs{get;set;}publicSongContext(IHttpContextAccessorhttpContextAccessor){_tenantId=httpContextAccessor.HttpContext.Request.Headers["TenantId"];}protectedoverridevoidOnModelCreating(ICodeFirstcodefirst){codefirst.AddQueryFilter<ITenant>( t =>t.TenantId==_tenantId);}}
Activity
ghost commentedon Sep 22, 2020
我技术有限只能说一句牛逼!~~
tianxin8206 commentedon Sep 23, 2020
支持tidb
wangjunniit commentedon Sep 23, 2020
叶老板牛逼!!!!!!!!!!!!!
希望实现DbContext级别的过滤器。
比如有个需求,根据http请求header里的某个值增加过滤条件,伪代码如下:
wangjunniit commentedon Sep 23, 2020
有没有可能与https://github.com/dotnetcore/CAP集成(DbContext模式)
CAP的常见用法下面两种,关键点是与一个Transaction进行关联
叶老板要不要考虑下
luoyunchong commentedon Sep 23, 2020
@wangjunniit https://github.com/luoyunchong/DotNetCore.CAP.Provider
2种方式。
luoyunchong/DotNetCore.CAP.Provider#1
NMSAzulX commentedon Sep 24, 2020
在做封装的时遇到的问题:
如果使用 Freesql 自带的 JoinIn 泛型方法则没办法自定义外联表别名, 但使用不带泛型的 Join 方法参数就写死了字符串,不能兼容其他特殊语法的数据库了,所以那个泛型方法希望改进一下。
建议: Left/Inner/RightJoin(exp) API 增加一个参数,即自定义别名,
LeftJoin(exp,string alias=default)
优点:
1、不耽误旧版本的使用
2、当 ToList(string) API 支持匿名类映射后,参数需支持灵活多变的调整,以便返回表和匿名类字段一一对应,此时 JOIN 查询方法提供了别名方法之后,开发者可以手动构造 ToList 方法的参数来调整匿名类映射,封装起来极有用。
例如:
2881099 commentedon Sep 24, 2020
目前 FreeSql.Repository 有仓储级别的过滤器,还有全局过滤器。文档:https://github.com/dotnetcore/FreeSql/wiki/%E8%BF%87%E6%BB%A4%E5%99%A8
2881099 commentedon Sep 24, 2020
大帅,是针对 LeftJoin<T2>((a,b) => a.id == b.id) 这个方法吗?这个方法别名是 lambda 参数名 b
2881099 commentedon Sep 24, 2020
不知道引用 FreeSql.Provider.MySqlConnector.dll 能不能访问,等有空了搭建好环境了试试
NMSAzulX commentedon Sep 24, 2020
LeftJoin/RightJoin/InnerJoin 如果多表联合查询的话 这种命名怕是不太妥,如果加上参数,你的方法里可以判断以下,如果有命名了就用参数的命名,没有命名,就用b, 这样开放出来API对于二次开发的人员更加友好。
lzw5399 commentedon Sep 27, 2020
有没有计划支持一下SAP HANA。。。最近着实被这玩意搞得有点难受
文档地址:
https://help.sap.com/viewer/b3ee5778bc2e4a089d3299b82ec762a7/2.0.02/en-US/9165807e2ded490ea06f46035c3e58b1.html
2881099 commentedon Sep 27, 2020
.LeftJoin("table2 AS MyAliasOut on a.id = MyAliasOut.xxid")
ToList("MyAliasOut.Name AS MyName")
如果这样使用是否可行,都是纯字符串操作。
2881099 commentedon Sep 27, 2020
今天做了调研:
1、从文档来看,技术上实现起来问题不大(都是关系型数据库),适配需要时间
2、从 nuget 上下载量来看(参数的 linq2db),实在太少
暂时作出的决定:
国内大环境正在实行”安可“国产化,我们更希望多点支持国产数据库。
从 nuget 查看下载量太少,暂时不会安排专门支持该数据库的开发。
建议:
可以参考 Odbc 通用方案进行适配访问 SAP HANA,文档:https://github.com/dotnetcore/FreeSql/blob/master/Providers/FreeSql.Provider.Odbc/readme.md
该方案需要自己重写一套适配器:https://github.com/dotnetcore/FreeSql/blob/master/Providers/FreeSql.Provider.Odbc/Default/OdbcAdapter.cs
- 优化 通用 Odbc 支持 Limit 风格的分页;#469
60 remaining items