您好,登錄后才能下訂單哦!
本節(jié)目錄
介紹
分析Abp源碼
實(shí)現(xiàn)UOW
UOW(全稱UnitOfWork)是指工作單元.
在Abp中,工作單元對(duì)于倉(cāng)儲(chǔ)和應(yīng)用服務(wù)方法默認(rèn)開啟。并在一次請(qǐng)求中,共享同一個(gè)工作單元.
同時(shí)在Abp中,不僅支持同一個(gè)數(shù)據(jù)庫(kù)連接,還支持事務(wù)處理.
1.UnitOfWorkRegistrar
2.ComponentRegistered
3.IsConventionalUowClass
4.Intercept
5.PerformSyncUow
定義IUnitOfWork
1 2 3 4 5 6 7 8 9 10 11 12 |
|
實(shí)現(xiàn)uow,在uow中會(huì)提供db的創(chuàng)建,這樣才能管理到每個(gè)db.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
定義與實(shí)現(xiàn)倉(cāng)儲(chǔ)層,這里不再做DbProvider.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
定義與實(shí)現(xiàn)應(yīng)用層
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
定義與實(shí)現(xiàn)uow攔截器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
定義在IApplicationService與IRepository接口下攔截
1 2 3 4 5 6 7 8 |
|
執(zhí)行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
會(huì)自動(dòng)在application method的結(jié)尾調(diào)用Complete.
另外也可以在uow上定義option為啟用事務(wù).在本例中稍作擴(kuò)展即可實(shí)現(xiàn).
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。