Repository pattern in.NET core yog dab tsi?
Repository pattern in.NET core yog dab tsi?

Video: Repository pattern in.NET core yog dab tsi?

Video: Repository pattern in.NET core yog dab tsi?
Video: GeeCON 2017: Cyrille Martraire - DDD beyond the infamous repository pattern 2024, Kaum ib hlis
Anonim

Repository Pattern yog ib qho abstraction ntawm Data Access Layer. Nws zais cov ntsiab lus ntawm yuav ua li cas raws nraim cov ntaub ntawv tau txais kev cawmdim los yog rov qab los ntawm cov ntaub ntawv hauv qab. Cov ntsiab lus ntawm yuav ua li cas cov ntaub ntawv khaws cia thiab muab rov qab yog nyob rau hauv feem chaw cia khoom.

Hauv qhov no, qhov chaw khaws cia hauv. NET core yog dab tsi?

Cov chaw cia khoom qauv yog npaj los tsim cov txheej txheem abstraction ntawm cov ntaub ntawv nkag mus rau txheej thiab cov txheej txheem kev lag luam ntawm daim ntawv thov. Nws yog tus qauv nkag mus rau cov ntaub ntawv uas ua rau muaj kev sib txuas ntau ntxiv rau kev nkag mus rau cov ntaub ntawv.

Ib sab saum toj no, tus qauv repository puas muaj txiaj ntsig nrog Entity Framework Core? Tsis yog, lub chaw cia khoom /unit-of-ua haujlwm qauv (shortened to Rep/UoW) tsis yog pab tau nrog EF Core . Ib qho kev daws teeb meem zoo dua yog siv EF Core ncaj qha, uas tso cai rau koj siv tag nrho cov EF Cores feature los tsim cov kev ua tau zoo database nkag.

Hauv qhov no, tus qauv repository yog dab tsi?

Cov Repository qauv . Repositories yog cov chav kawm lossis cov khoom siv uas encapsulate lub logic yuav tsum tau nkag mus rau cov ntaub ntawv. Lawv centralize ntau cov ntaub ntawv nkag mus rau functionality, muab kev ruaj ntseg zoo dua thiab decoupling cov infrastructure los yog technology siv los nkag tau rau databases los ntawm tus sau qauv txheej.

Vim li cas peb thiaj siv Repository qauv?

Cov Repository qauv yog siv kom decouple lub lag luam logic thiab cov ntaub ntawv nkag txheej hauv koj daim ntawv thov. Cov ntaub ntawv nkag txheej feem ntau muaj cov cai tshwj xeeb thiab cov txheej txheem los ua haujlwm ntawm cov ntaub ntawv mus thiab los ntawm cov ntaub ntawv khaws cia.

Pom zoo: