-
Notifications
You must be signed in to change notification settings - Fork 849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如何在IRepository,Repository,IServices,Services 这种代码结构下使用工作单元模式 #159
Comments
FreeSql.Repository 是通用的仓储实现,里面有接口,如果延用到项目使用,有两种办法:
public interface ITopicRrpository : IBasicRepository
{
//定义其他方法
}
public class TopicRepository : BaseRepository<Topic, int>
{
public TopicRepository(IFreeSql fsql) : base(fsql, null, null)
{
}
//实现其他方法
} 手机整理的,大概是这样。 构造参数 IFreeSql 可以改成 IUnitOfWork ,后话…… |
第一种,意味着省略了原有的 Repository 层 第二种,意味着 Repsiroty 层会有很多基本空着的类 |
@2881099 目前我是用第二种方式实现的,但是在多库注入的时候就卡主了,不太清楚我要如何才能解决一个项目多库的问题,以下是我注入的方法: |
IFreeSql 多库目前使用 .new FreeSqlBuilder()
.Build<TMark>() ,他的返回类型是 IFreeSql<TMark>,这样ioc 中就可以区分多个 IFreeSql 了。 仓储层注入,参数是固定的 IFreeSql,所以看下能不能重新定义一个 class MyBaseRepository<TMark, TEntity, TKey> : FreeSql.BaseRepository<TEntity, TKey>
{
public MyBaseRepository(IFreeSql<TMark> fsql) : base(fsql, null, null) {}
} |
大神,新手请教一下,项目是工厂模式的,项目中使用FreeSql.Repository的时候不知道咋个创建IRepository,Repository了,好像直接在Services层就能直接用了,但是项目是IRepository,Repository,IServices,Services 这种代码结构的
The text was updated successfully, but these errors were encountered: