日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

ABP引入Dapper框架的創建使用_實用技巧

作者:騙你學計算機 ? 更新時間: 2022-06-27 編程語言

ABP使用Dapper框架已經有很成熟的第三方包,簡單的幾句代碼就能完成

一. 首先準備好一個數據庫建一個表

二.建一個實體表

    [Table("BasBloodLevel")]
    public class BasBloodLevel:Entity<int>
    {
        public string Code { get; set; }
    }

三.然后再ABP框架的EF層安裝?Abp.Dapper包

?Abp.Dapper包

并且在EF層的 xxxEntityFrameworkModule添加以下代碼

?

到此引用?Dapper框架就完成了,接下來就是使用了

使用

首先DbContext引入對應的DbSet

最后在應用層直接使用

使用?IDapperRepository的倉儲就能使用Dapper的ORM框架了

    public class BasBloodLevelAppService : IApplicationService
    {
 
 
         private readonly IDapperRepository<BasBloodLevel, int> _basBloodLevelRepository;
 
        public BasBloodLevelAppService(
            IDapperRepository<BasBloodLevel, int> basBloodLevelRepository
           ) 
        {
           _basBloodLevelRepository = basBloodLevelRepository;
          
        }
 
     
        public List<BasBloodLevel> GetBasAllMessage2()
        {
            var entity = _basBloodLevelRepository.Query("select * from BasBloodLevel").ToList();
            return entity;
        }
    }

?調用以下證明我成功了

原文鏈接:https://blog.csdn.net/wangwengrui40/article/details/122747445

欄目分類
最近更新