ABP框架—后台:引入Abp.Dapper(10)

ABP框架整合Dapper教程
本文详细介绍了如何在ABP框架中使用Dapper进行数据访问。从添加NuGet包开始,通过创建实体、定义DbContext集合,到实现服务接口,一步步展示了Dapper与ABP的集成过程。

一、NuGet获取Abp.Dapper

项目类库Application和项目类库EntityFrameworkCore添加Abp.Dapper引用,如图:


二、创建实体Entity


项目类库Core创建实体,如图:

 


 
  1. using Abp.Domain.Entities;

  2.  
  3. namespace PD.Menu

  4. {

  5.     public class Sys_Menu : Entity  

  6.     {

  7.         public virtual string Path { get; set; }

  8.         public virtual string Name { get; set; }

  9.         public virtual string Permission { get; set; }

  10.         public virtual string Meta { get; set; }

  11.         public virtual string Title { get; set; }

  12.         public virtual string Icon { get; set; }

  13.         public virtual string Component { get; set; }

  14.         public virtual int FatherId { get; set; }

  15.         public virtual int LevelType { get; set; }

  16.         public virtual int StatusType { get; set; }

  17.     }

  18. }

三、DbContext中为实体定义数据库集

public virtual DbSet<Menu.Sys_Menu> Sys_Menu { set; get; }


四、EntityFrameworkModule添加依赖

typeof(AbpDapperModule)
DapperExtensions.DapperExtensions.SetMappingAssemblies(new List<Assembly> { typeof(VerifyServiceEntityFrameworkModule).GetAssembly()})


五、创建服务接口Application


调用默认的IDapperRepository


 
  1. using Abp.Dapper.Repositories;

  2. using System;

  3. using System.Collections.Generic;

  4. using System.Text;

  5.  
  6. namespace PD.Menu

  7. {

  8.     public class MenuTestAppService : PDAppServiceBase, IMenuTestAppService

  9.     {

  10.         private readonly IDapperRepository<Sys_Menu> _Sys_MenuDapperRepository;

  11.         public MenuTestAppService(IDapperRepository<Sys_Menu> sys_MenuDapperRepository)

  12.         {

  13.             _Sys_MenuDapperRepository = sys_MenuDapperRepository;

  14.         }

  15.  
  16.         public void Get()

  17.         {

  18.             var aa = _Sys_MenuDapperRepository.GetAll();

  19.             var bb = _Sys_MenuDapperRepository.Query("select * from Sys_Menu");

  20.         }

  21.     }

  22. }


说明:ABP官方说明https://aspnetboilerplate.com/Pages/Documents/Dapper-Integration

I OllieMsgCenter: publishEvt=2135228419 10-26 11:12:24.649 4081 4564 I WeakSignalPredictCollect: wifiDatas size 12 for recognize 10-26 11:12:24.649 4081 4564 E PositionFenceRecognize: RecognizeByWifi fail, highPrecisionConfirmedFence is empty 10-26 11:12:24.649 4081 4564 E PositionFenceRecognize: RecognizeByWifi fail, highPrecisionConfirmedFence is empty 10-26 11:12:24.653 3889 3892 I aptouch_daemon: DriverThp::ReportEvents[1476]0x10000000 10-26 11:12:24.694 712 712 I android.system.suspend@1.0-service: incSuspendCounter kname=native_radio-interface ++mSuspendCounter= 4 10-26 11:12:24.695 1819 7127 I PowerManagerService: schedul eye detect nextTimeout: 65995473 now: 65971570 mRemainTime: 10000 10-26 11:12:24.697 712 712 I android.system.suspend@1.0-service: decSuspendCounter kname=native_radio-interface --mSuspendCounter= 3 10-26 11:12:24.699 4081 4564 E BoosterNty: onOemHookRawEvent decodes failed. 10-26 11:12:24.700 4081 4564 I SceneMapCellInfoBase: init handleMessage: 11 10-26 11:12:24.700 4081 4564 E SceneMapCellInfoBase: handleMessage: 11 10-26 11:12:24.700 4081 4564 I SceneMapCellInfoCrowdsourcing: handleMessage: 11 10-26 11:12:24.700 4081 4564 I HighspeedPresetManager: handleMessage: 4 10-26 11:12:24.711 5335 5526 W fwkit_coresm: [fwkit CoreServiceManager.java:34] Wait for Kims ready, coreReady:false 10-26 11:12:24.711 5335 5335 W fwkit_coresm: [fwkit CoreServiceManager.java:10] KPMS has not been initialized. 10-26 11:12:24.721 5335 7533 I fwkit_kams: [fwkit KAMSServiceController.java:34] getKimsManager await ret:false 10-26 11:12:24.722 5335 7533 W fwkit_coresm: [fwkit CoreServiceManager.java:48] Get kit.info Service !but its binder is null! 10-26 11:12:24.722 5335 7533 W fwkit_kams: [fwkit KAMSServiceController.java:76] [getExplicitStubIntent] X. kims not ready, pending ... 10-26 11:12:24.722 5335 7533 W fwkit_container_util: [fwkit ConnectCoreUtil.java:88] get stubInfo failed when time up 10-26 11:12:24.722 5335 7533 W fwkit_utils: [fwkit CommonUtils.java:20] getKitInfo failed for in params invalid! 10-26 11:12:24.722 5335 7533 W fwkit_kac_service_help: [fwkit ContainerServiceHelper.java:198] explicit stub loaded kit error! Intent { act=com.android.location.service.v3.NetworkLocationProvider typ=system cmp=com.huawei.hwid/com.huawei.locatorservice.ability.nlpservice.HwNLPService (has extras) } 10-26 11:12:24.722 5335 7533 W fwkit_kac_service_help: [fwkit ContainerServiceHelper.java:31] init resource fail: [ Intent { act=com.android.location.service.v3.NetworkLocationProvider typ=system cmp=com.huawei.hwid/com.huawei.locatorservice.ability.nlpservice.HwNLPService }] 10-26 11:12:24.723 5335 7533 E fwkit_kac_kitloader: [fwkit KitLoaderManager.java:167] getPackgeIdFromKitUid kitUid:null is invalid 10-26 11:12:24.727 5335 7533 E SecurityComp10201304: IntentUtils: g*t*a*c*l*b*e *x*e*t*o*: A*t*m*t *o *n*o*e *i*t*a* m*t*o* 'a*d*o*d.*s.*a*c*l*b*e *n*r*i*.o*.B*n*l*.g*t*a*c*l*b*e(*a*a.*a*g.*t*i*g)' *n * n*l* o*j*c* r*f*r*n*e 10-26 11:12:24.728 5335 30901 I fwkit_CountryCodeBean: [fwkit CountryCodeBean.java:40] countryCode by ro.hw.country is: cn 10-26 11:12:24.728 5335 30901 I fwkit_CountryCodeBean: [fwkit CountryCodeBean.java:16] get issue_country code from VENDOR_COUNTRY 10-26 11:12:24.729 5335 7533 E fwkit_kac_service_help: [fwkit ContainerServiceHelper.java:138] ContainerServiceHelper binderService调用异常. 10-26 11:12:24.729 5335 7533 W fwkit_IPC_wrap: [fwkit BaseExplicitStubService.java:128] mBinder is null, forward Call FAILED! 10-26 11:12:24.729 5335 7533 I uawei.hwid.cor: oneway function results for code 2 on binder at 0x73abf876e0 will be dropped but finished with status UNKNOWN_TRANSACTION 10-26 11:12:24.729 5335 7533 I fwkit_IPC_wrap: [fwkit BaseExplicitStubService.java:46] IPCInterfaceWrapper onTransact: 1 caller pid:0, component:ComponentInfo{com.huawei.hwid/com.huawei.locatorservice.ability.nlpservice.HwNLPService} 10-26 11:12:24.729 5335 7533 I fwkit_IPC_wrap: [fwkit BaseExplicitStubService.java:64] mLatch wait enter 10-26 11:12:24.729 5335 7533 I fwkit_IPC_wrap: [fwkit BaseExplicitStubService.java:80] mLatch wait end 10-26 11:12:24.729 5335 7533 I fwkit_IPC_wrap: [fwkit BaseExplicitStubService.java:103] mBinder is null, try onBind again 10-26 11:12:24.764 3889 3892 I aptouch_daemon: status=0x80000102 10-26 11:12:24.778 3889 3892 I aptouch_daemon: status=0x80000002 10-26 11:12:24.799 4081 4564 I SmartDualCardSM: IdleState:got msg.what=85 10-26 11:12:24.812 5335 5526 W fwkit_coresm: [fwkit CoreServiceManager.java:34] Wait for Kims ready, coreReady:false 10-26 11:12:24.813 5335 5335 W fwkit_coresm: [fwkit CoreServiceManager.java:10] KPMS has not been initialized. 10-26 11:12:24.818 5335 7536 I fwkit_kpms_utils: [fwkit PackageManagerUtil.java:105] [Binder:5335_B] lock stop wait 10-26 11:12:24.818 5335 7536 W fwkit_coresm: [fwkit CoreServiceManager.java:34] Wait for Kims ready, coreReady:false 10-26 11:12:24.818 5335 7536 E fwkit_kpms_utils: [fwkit PackageManagerUtil.java:136] getKitInfoManagerMayWait, ims still not ready in 2000 ms 10-26 11:12:24.818 5335 7536 I fwkit_provider_manager: [fwkit ContentProviderManager.java:12] getProviderInfo kimsManager is null 10-26 11:12:24.818 5335 7536 E fwkit_provider_manager: [fwkit ContentProviderManager.java:10] getProviderInfo failed 10-26 11:12:24.819 5335 7536 E fwkit_provider: [fwkit ContentProviderDelegateImpl.java:20] query getKitContentProvider failed 10-26 11:12:24.820 23460 23460 I 00501/HwParentControl: MainFragment - checkRemoteLocationBindStatus -> account not login 10-26 11:12:24.821 23460 23460 I 00501/HwParentControl: PackageUtils - System app: com.huawei.hwid 10-26 11:12:24.823 5335 7536 I fwkit_AbP: [fwkit AbsContentProvider.java:13] cp:com.huawei.parentcontrol;query;content://com.huawei.hwid.api.provider/has_login 10-26 11:12:24.823 5335 7536 W fwkit_coresm: [fwkit CoreServiceManager.java:34] Wait for Kims ready, coreReady:false 10-26 11:12:24.823 5335 7536 I fwkit_kpms_utils: [fwkit PackageManagerUtil.java:65] [Binder:5335_B] lock start wait 10-26 11:12:24.826 3889 3892 I aptouch_daemon: touch:1, down:1(+0) 10-26 11:12:24.827 3889 3892 I aptouch_daemon: DriverThp::ReportEvents[1476]0x8000000 10-26 11:12:24.827 1819 2223 I InputReader: eventHub getEvents 12 10-26 11:12:24.828 1819 1892 I osfingersense: Acc read ok 10-26 11:12:24.828 1819 1892 I osfingersense: osf: wait tp event in 10-26 11:12:24.828 1819 2223 I osfingersense: fingersense_classify_touch: entrance, v8.8.8 with 0.0 bin 10-26 11:12:24.828 1819 2223 I osfingersense: touch down-id: 0 10-26 11:12:24.828 1819 2223 I osfingersense: fingersense_classify_touch: Pre check for decision 10-26 11:12:24.828 1819 2223 I osfingersense: fingersense_classify_touch acc model off 10-26 11:12:24.828 1819 2223 I osfingersense: fingersense_classify_touch: Part I 10-26 11:12:24.828 1819 2223 I osfingersense: fingersense_classify_touch: inference = 0 10-26 11:12:24.829 1819 2223 I InputReader: UL_Input first down 10-26 11:12:24.829 993 1577 I Layer : Sprite#53307: created 10-26 11:12:24.831 4120 4756 I PG_ash : package = null, pid = 23460, touch input 10-26 11:12:24.831 4120 4756 I PG_ash : Default InputMethod : com.huawei.ohos.inputmethod 10-26 11:12:24.832 993 1315 I Layer : bbq-wrapper#53308: created 10-26 11:12:24.832 1819 2222 I PowerManagerService: schedul eye detect nextTimeout: 65995698 now: 65971707 mRemainTime: 10000 10-26 11:12:24.835 3889 3892 I aptouch_daemon: DriverThp::ReportEvents[1476]0x8000000 10-26 11:12:24.835 1819 2223 I InputReader: eventHub getEvents 11 10-26 11:12:24.837 4120 4756 I PG_ash : package = null, pid = 23460, touch input 10-26 11:12:24.837 4120 4756 I PG_ash : Default InputMethod : com.huawei.ohos.inputmethod 10-26 11:12:24.841 1819 2223 I InputReader: eventHub getEvents 11 10-26 11:12:24.842 1819 2223 I InputReader: UL_Input first offset move. 10-26 11:12:24.845 4120 4756 I PG_ash : package = null, pid = 23460, touch input 10-26 11:12:24.845 4120 4756 I PG_ash : Default InputMethod : com.huawei.ohos.inputmethod 10-26 11:12:24.849 1819 2223 I InputReader: eventHub getEvents 11 10-26 11:12:24.850 4120 4756 I PG_ash : package = null, pid = 23460, touch input 10-26 11:12:24.850 4120 4756 I PG_ash : Default InputMethod : com.huawei.ohos.inputmethod 10-26 11:12:24.852 993 993 I BufferStateLayer: setBuffer: bbq-wrapper#53308: first buffer comes. 10-26 11:12:24.852 993 993 I Layer : setFlags: Sprite#53307 show 10-26 11:12:24.853 993 993 I BufferLayer: preparePerFrameCompositionState: bbq-wrapper#53308: first buffer updated to LayerFE. frame=1 10-26 11:12:24.856 1819 2223 I InputReader: eventHub getEvents 11 10-26 11:12:24.857 4120 4756 I PG_ash : package = null, pid = 23460, touch input 10-26 11:12:24.857 1819 3604 I PowerManagerService: schedul eye detect nextTimeout: 65995698 now: 65971732 mRemainTime: 10000 10-26 11:12:24.857 4120 4756 I PG_ash : Default InputMethod : com.huawei.ohos.inputmethod 10-26 11:12:24.858 1819 3604 I NetworkStats: performPollLocked, pid = 1819 10-26 11:12:24.861 1819 3604 I NetworkStats: read uidSnapshot from native, totalbytes: 6311809872 10-26 11:12:24.861 1375 8006 I CPU_STATS: iawared: query next cpu load with 2! 10-26 11:12:24.861 1375 8006 I CPU_STATS: total cost time 2011960157 ns 10-26 11:12:24.861 1819 3604 I NetworkStats: read xtSnapshot from native, totalbytes: 6348982214 10-26 11:12:24.862 1819 3604 I NetworkStats: recordSnapshotLocked end, pid = 1819 10-26 11:12:24.862 1819 3955 I NetworkStatsCollection: getSummary, uid = 1000stats size = 3 10-26 11:12:24.862 1375 8006 I CPU_STATS: iawared: current total load is 0.085427, capacity : 5216, pre load: 27278358795417, current load : 27279234289884 10-26 11:12:24.862 979 21926 I asd_in_fwk: L = -infdb, R = -infdb 10-26 11:12:24.863 1819 2223 I InputReader: eventHub getEvents 11 10-26 11:12:24.864 1375 8006 I CPU_STATS: read once cost time 2854 us 10-26 11:12:24.864 4120 4756 I PG_ash : package = null, pid = 23460, touch input 10-26 11:12:24.864 4120 4756 I PG_ash : Default InputMethod : com.huawei.ohos.inputmethod 10-26 11:12:24.865 1819 3604 I NetworkStatsCollection: getSummary, uid = 1000stats size = 5 10-26 11:12:24.865 1819 3604 I NetworkStatsCollection: getSummary, uid = 1000stats size = 5 10-26 11:12:24.865 1819 3604 I NetworkStatsCollection: getSummary, uid = 1000stats size = 188 10-26 11:12:24.866 1819 3604 I NetworkStatsCollection: getSummary, uid = 1000stats size = 5 10-26 11:12:24.866 1819 3604 I NetworkStatsCollection: getSummary, uid = 1000stats size = 5 10-26 11:12:24.866 1819 3604 I NetworkStatsCollection: getSummary, uid = 1000stats size = 188 10-26 11:12:24.866 1819 3604 I NetworkStats: callingPid is system 1819 10-26 11:12:24.866 1819 3604 I PowerManagerService: schedul eye detect nextTimeout: 65995698 now: 65971741 mRemainTime: 10000 10-26 11:12:24.866 886 886 I netd : bandwidthSetGlobalAlert(2097152) <0.13ms> 10-26 11:12:24.867 1819 3604 E UserInfoExt: setUserInfo: userInfo is null! 10-26 11:12:24.867 1819 3604 E UserInfoExt: isClonedProfile: mUserInfo is null! 10-26 11:12:24.867 1819 3604 E UserInfoExt: setUserInfo: userInfo is null! 10-26 11:12:24.867 4081 5744 I Booster_Qoe: Ada,index:6,NisPsSlow:0,NProba:447,rsrp(rssi):-51,rsrq(noise):-9,rtt(chload):0,BFH(uldelay):0,BFC(rtt):101 Real:-61,-9,0,0,101, dlBler:0, ulBler:1 10-26 11:12:24.867 4081 5744 I Booster_Qoe: Ada,index:0,NisPsSlow:0,NProba:447,rsrp(rssi):-51,rsrq(noise):-9,rtt(chload):0,BFH(uldelay):0,BFC(rtt):101 Real:-61,-9,81,0,101, dlBler:0, ulBler:1 10-26 11:12:24.868 1819 3606 I NetworkStats: History for network, uid = 1000 10-26 11:12:24.868 1819 3606 I NetworkStats: Summary for network, uid = 1000 10-26 11:12:24.869 993 993 I Layer : setFlags: Sprite#53305 hide 10-26 11:12:24.869 1819 3606 I NetworkStats: History for network, uid = 1000 10-26 11:12:24.870 4081 4564 E NetworkQoeProxy: invalid channelId = 1 10-26 11:12:24.870 3889 3892 I aptouch_daemon: touch:0, down:0 10-26 11:12:24.870 4081 4564 E NetworkQoeProxy: invalid channelId = 2 10-26 11:12:24.870 3889 3892 I aptouch_daemon: DriverThp::ReportEvents[1476]0x10000000 10-26 11:12:24.871 1819 2223 I InputReader: eventHub getEvents 3 10-26 11:12:24.871 4081 4564 I NetworkQoeProxy: ActivityName com.huawei.parentcontrol.ui.activity.HomeActivityis not in whitelist 10-26 11:12:24.871 4081 4564 I NetworkQoeProxy: channelId:0 upRate:159961, downRate1082 10-26 11:12:24.871 1819 2223 I InputReader: UL_Input last up 10-26 11:12:24.874 4120 4756 I PG_ash : package = null, pid = 23460, touch input 10-26 11:12:24.874 4120 4756 I PG_ash : Default InputMethod : com.huawei.ohos.inputmethod 10-26 11:12:24.874 1819 3606 I NetworkStats: Summary for network, uid = 1000 10-26 11:12:24.877 886 886 I netd : bandwidthRemoveInterfaceQuota(rmnet0) <1.52ms> 10-26 11:12:24.877 4081 4564 E Booster_BroadcastProxy: [isDebugModemEnabled]get package info fail. 10-26 11:12:24.877 4081 4564 I CloudServiceChr: App Qoe normal 10-26 11:12:24.878 3889 3892 I aptouch_daemon: DriverThp::ReportEvents[1476]0x10000000 10-26 11:12:24.878 886 886 I netd : bandwidthSetInterfaceQuota(rmnet0, 9223372036854775807) <0.97ms> 10-26 11:12:24.878 4081 4564 I AppQoeListener: notifyQoeGoodEvent enter 10-26 11:12:24.878 4081 4564 E AppQoeListener: notifyQoeGoodEvent too many times, threshold = 10 10-26 11:12:24.878 4081 4564 I CloudNetworkStateMachine: the Wi-Fi action state is false 10-26 11:12:24.879 4081 4564 I SceneMapCellInfoBase: init handleMessage: 2135031809 10-26 11:12:24.879 4081 4564 E SceneMapCellInfoBase: handleMessage: 2135031809 10-26 11:12:24.879 4081 4564 I SceneMapCellInfoCrowdsourcing: handleMessage: 2135031809 10-26 11:12:24.883 1819 3606 I NetworkStats: History for network, uid = 1000 10-26 11:12:24.884 1819 3606 I NetworkStats: Summary for network, uid = 1000 10-26 11:12:24.898 1819 6984 I PowerManagerService: schedul eye detect nextTimeout: 65995698 now: 65971772 mRemainTime: 10000 10-26 11:12:24.914 5335 5335 W fwkit_coresm: [fwkit CoreServiceManager.java:10] KPMS has not been initialized. 10-26 11:12:24.923 5335 5526 W fwkit_coresm: [fwkit CoreServiceManager.java:34] Wait for Kims ready, coreReady:false 10-26 11:12:24.960 3889 3892 I aptouch_daemon: status=0x80000102 10-26 11:12:24.974 3889 3892 I aptouch_daemon: status=0x80000002 10-26 11:12:25.014 5335 5335 W fwkit_coresm: [fwkit CoreServiceManager.java:10] KPMS has not been initialized. 10-26 11:12:25.026 3889 3892 I aptouch_daemon: status=0x80000001 10-26 11:12:25.026 3889 3892 E aptouch_daemon: TsaFrame::UpdateStatusIdle[1931]idle in. 133 10-26 11:12:25.027 5335 5526 W fwkit_coresm: [fwkit CoreServiceManager.java:34] Wait for Kims ready, coreReady:false 10-26 11:12:25.030 3889 3892 I aptouch_daemon: status=0x80000002 10-26 11:12:25.030 3889 3892 E aptouch_daemon: TsaFrame::UpdateStatusIdle[1933]idle out. 10-26 11:12:25.031 3889 3892 I aptouch_daemon: touch:1, down:1(+0) 10-26 11:12:25.031 3889 3892 I aptouch_daemon: DriverThp::ReportEvents[1476]0x8000000 10-26 11:12:25.032 1819 2223 I InputReader: eventHub getEvents 12 10-26 11:12:25.033 1819 2223 I osfingersense: fingersense_classify_touch: entrance, v8.8.8 with 0.0 bin 10-26 11:12:25.033 1819 2223 I osfingersense: touch down-id: 0 10-26 11:12:25.033 1819 2223 I osfingersense: fingersense_classify_touch: Pre check for decision 10-26 11:12:25.033 3889 3892 I aptouch_daemon: DriverThp::ReportEvents[1476]0x8000000 10-26 11:12:25.033 1819 1892 I osfingersense: Acc read ok 10-26 11:12:25.033 1819 1892 I osfingersense: osf: wait tp event in 10-26 11:12:25.033 1819 2223 I osfingersense: fingersense_classify_touch acc model off 这段日志里有打印点击无响应相关的问题么
最新发布
10-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值