From c366fe8f4d04ee8183259ca8a91f708237a7960f Mon Sep 17 00:00:00 2001 From: Monk Date: Tue, 13 Oct 2020 19:22:55 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=97=20update=20documents.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handbook/build/03ebb857.695212d0.js | 1 - handbook/build/03ebb857.bdee66fe.js | 1 + handbook/build/0ddd808e.cf943861.js | 1 - handbook/build/0ddd808e.d77719f9.js | 1 + handbook/build/17256d0f.0dd677ec.js | 1 - handbook/build/17256d0f.c1719a38.js | 1 + handbook/build/1761adf3.0eeb8b92.js | 1 - handbook/build/1761adf3.37f331f5.js | 1 + handbook/build/17666df9.37cd28d0.js | 1 + handbook/build/17666df9.a5abd77b.js | 1 - handbook/build/1d7b962e.4baa59fe.js | 1 - handbook/build/1d7b962e.7e7e2e9f.js | 1 + handbook/build/1e961311.d7cc7b4c.js | 1 + handbook/build/1e961311.fef4867f.js | 1 - handbook/build/1ea356f4.44a77987.js | 1 + handbook/build/1ea356f4.853d079e.js | 1 - handbook/build/23e7023c.5c499293.js | 1 + ...cd402.dad85cd2.js => 24dcd402.931bd557.js} | 2 +- ...2faa0.393c7313.js => 2792faa0.c8b601b5.js} | 2 +- handbook/build/2a4cb773.949fd694.js | 1 + handbook/build/2a4cb773.c96e5bb6.js | 1 - handbook/build/2ae73ff4.074eace3.js | 1 + handbook/build/2ae73ff4.b4cb8011.js | 1 - handbook/build/2b04a543.660f2802.js | 1 + handbook/build/2b04a543.9fc467bd.js | 1 - handbook/build/34420422.bd14d00b.js | 1 - handbook/build/34420422.f54e4fab.js | 1 + ...93c62.d48973ba.js => 36793c62.81252910.js} | 2 +- ...dbab2.2beebf2b.js => 3a6dbab2.89038ec6.js} | 2 +- handbook/build/3ab56fdf.d254137a.js | 1 + handbook/build/3ab56fdf.dc6c86e1.js | 1 - handbook/build/3e869f93.305c87c2.js | 1 + handbook/build/3e869f93.8686d66c.js | 1 - handbook/build/404.html | 16 ++-- handbook/build/408ae89d.0e87c449.js | 1 - handbook/build/408ae89d.fa344557.js | 1 + handbook/build/409819e6.14b77875.js | 1 + handbook/build/4930ce4d.867af8f3.js | 1 + handbook/build/4930ce4d.e8539812.js | 1 - handbook/build/4bfcf3ee.09b86c5e.js | 1 + handbook/build/4bfcf3ee.9fd3cf97.js | 1 - handbook/build/4c30b939.7af2ecca.js | 1 + handbook/build/4c30b939.95d3ea2a.js | 1 - handbook/build/4dbcf072.43551049.js | 1 - handbook/build/4dbcf072.86aa2a4d.js | 1 + handbook/build/4e3694ae.befe978c.js | 1 - handbook/build/4efad03e.7367e18f.js | 1 + handbook/build/525b9089.4330aea1.js | 1 + handbook/build/59d16f51.61813dfb.js | 1 - handbook/build/59d16f51.b99a9697.js | 1 + handbook/build/5c4ee1d6.84f4a477.js | 1 - handbook/build/5ce0ebbd.4ab6a852.js | 1 - handbook/build/5ce0ebbd.e81097b1.js | 1 + handbook/build/5e077782.49e1c594.js | 1 + handbook/build/5e077782.5c58ae24.js | 1 - handbook/build/62953dcd.c8565443.js | 1 + handbook/build/62953dcd.dc05b734.js | 1 - ...ac364.b869a9ae.js => 654ac364.56187509.js} | 2 +- handbook/build/66076b72.841838a5.js | 1 + ...5c492.5589b6a0.js => 6875c492.45df4276.js} | 2 +- ...99f3e.0d9dc710.js => 70699f3e.ab80af1c.js} | 2 +- ...6a0ae.872ee861.js => 7696a0ae.5c74cfa6.js} | 2 +- handbook/build/7b4b163f.4808d427.js | 1 - handbook/build/7b4b163f.dcdeae35.js | 1 + handbook/build/7c7b3a8a.a8db9a6c.js | 1 + handbook/build/7c7b3a8a.f2448b6a.js | 1 - handbook/build/7d3779e7.20c05f2d.js | 1 - handbook/build/7d3779e7.e94a61da.js | 1 + handbook/build/8009abd7.d3326cc7.js | 1 + handbook/build/8231c802.e9b1c61b.js | 1 + handbook/build/8231c802.f5780f8f.js | 1 - handbook/build/8bbf9761.bb6f6ac0.js | 1 + handbook/build/8bbf9761.f64cda87.js | 1 - handbook/build/8e2b7b33.016f2f3a.js | 1 - handbook/build/8e2b7b33.168f86ee.js | 1 + handbook/build/902d8112.8f2a4136.js | 1 + handbook/build/902d8112.b9a6df3a.js | 1 - handbook/build/904cf40b.09e071c4.js | 1 - handbook/build/904cf40b.806b2fcf.js | 1 + handbook/build/97c3ef29.22942c40.js | 1 - handbook/build/97c3ef29.5e50707c.js | 1 + handbook/build/9958fd43.319bacf7.js | 1 - handbook/build/9bdac8f0.aaac8e03.js | 1 + handbook/build/9bdac8f0.b38ef64e.js | 1 - handbook/build/a133dc31.7638bbc5.js | 1 - handbook/build/a133dc31.e6723c63.js | 1 + handbook/build/a688d5cc.44b37d46.js | 1 - handbook/build/a688d5cc.9eea910c.js | 1 + ...a9e1f.dad92990.js => a6aa9e1f.7b044f24.js} | 2 +- handbook/build/a74774ac.19465b58.js | 1 - handbook/build/a74774ac.fc99cc53.js | 1 + handbook/build/af3e9b99.0b631e94.js | 1 - handbook/build/af3e9b99.6400b5bf.js | 1 + handbook/build/b0be1305.06a3f89a.js | 1 - handbook/build/b0be1305.e0298c3e.js | 1 + handbook/build/b30e5fe3.41db337f.js | 1 - handbook/build/b30e5fe3.f4083332.js | 1 + handbook/build/b80c29d5.100571d2.js | 1 - handbook/build/b80c29d5.ae39c9b4.js | 1 + handbook/build/blog/index.html | 40 ++++---- handbook/build/blog/tags/fur/index.html | 40 ++++---- handbook/build/blog/tags/furos/index.html | 40 ++++---- handbook/build/blog/tags/index.html | 32 +++---- handbook/build/blog/tags/net-5/index.html | 40 ++++---- handbook/build/blog/tags/net/index.html | 40 ++++---- handbook/build/blog/tags/netcore/index.html | 40 ++++---- handbook/build/blog/welcome/index.html | 36 ++++---- handbook/build/c456980b.530a8035.js | 1 - handbook/build/c456980b.ea5bf524.js | 1 + handbook/build/cb0a942e.6dfad658.js | 1 + handbook/build/cb0a942e.ba8927ad.js | 1 - ...49370.3426e43a.js => ccc49370.3837ba9b.js} | 2 +- handbook/build/ce4b3b2d.873ebbc4.js | 1 - handbook/build/d3c206bc.2684bdea.js | 1 + handbook/build/d3c206bc.5e7da086.js | 1 - handbook/build/d3ee75d5.89d8c15a.js | 1 - handbook/build/d3ee75d5.b589f955.js | 1 + handbook/build/d43b3010.eaa01519.js | 1 - handbook/build/d43b3010.f67b79ab.js | 1 + handbook/build/d631a3bf.2d8e6cb4.js | 1 - handbook/build/d63edb86.067dc58e.js | 1 - handbook/build/d80bb0e0.35e8ea68.js | 1 - handbook/build/d80bb0e0.7f8d0918.js | 1 + handbook/build/d8c8d2dc.1ab280a0.js | 1 - handbook/build/d8c8d2dc.92db30cc.js | 1 + handbook/build/d8f92c54.6ec458d9.js | 1 - handbook/build/d8f92c54.f93d860e.js | 1 + handbook/build/dc10b9c8.92049b15.js | 1 - handbook/build/dc10b9c8.f1d42dde.js | 1 + handbook/build/dea2fede.13d0ddb5.js | 1 + handbook/build/dea2fede.c67f06e6.js | 1 - handbook/build/docs/answer/index.html | 48 +++++----- handbook/build/docs/appstartup/index.html | 50 +++++----- handbook/build/docs/auth-control/index.html | 48 +++++----- handbook/build/docs/author/index.html | 48 +++++----- handbook/build/docs/cache/index.html | 48 +++++----- handbook/build/docs/configuration/index.html | 50 +++++----- handbook/build/docs/contribute/index.html | 48 +++++----- handbook/build/docs/cors/index.html | 48 +++++----- .../build/docs/data-validation/index.html | 58 ++++++------ .../docs/dbcontext-Interceptor/index.html | 50 +++++----- .../docs/dbcontext-add-or-update/index.html | 50 +++++----- handbook/build/docs/dbcontext-add/index.html | 50 +++++----- .../build/docs/dbcontext-audit/index.html | 50 +++++----- .../build/docs/dbcontext-batch/index.html | 50 +++++----- .../docs/dbcontext-code-first/index.html | 50 +++++----- .../build/docs/dbcontext-db-first/index.html | 50 +++++----- .../build/docs/dbcontext-delete/index.html | 50 +++++----- .../build/docs/dbcontext-filter/index.html | 50 +++++----- .../build/docs/dbcontext-function/index.html | 52 +++++------ .../docs/dbcontext-hight-query/index.html | 50 +++++----- .../build/docs/dbcontext-locator/index.html | 50 +++++----- .../docs/dbcontext-multi-database/index.html | 50 +++++----- handbook/build/docs/dbcontext-proc/index.html | 50 +++++----- .../build/docs/dbcontext-query/index.html | 50 +++++----- .../docs/dbcontext-read-write/index.html | 52 +++++------ .../docs/dbcontext-repository/index.html | 50 +++++----- .../build/docs/dbcontext-seed-data/index.html | 50 +++++----- .../build/docs/dbcontext-sql-proxy/index.html | 50 +++++----- .../docs/dbcontext-sql-template/index.html | 50 +++++----- handbook/build/docs/dbcontext-sql/index.html | 50 +++++----- .../build/docs/dbcontext-update/index.html | 50 +++++----- handbook/build/docs/dbcontext-view/index.html | 50 +++++----- handbook/build/docs/dbcontext/index.html | 52 +++++------ .../docs/dependency-injection/index.html | 54 +++++------ handbook/build/docs/deploy/index.html | 48 +++++----- handbook/build/docs/devops/index.html | 48 +++++----- .../docs/dynamic-api-controller/index.html | 92 +++++++++---------- handbook/build/docs/entity/index.html | 50 +++++----- handbook/build/docs/errors/index.html | 48 +++++----- handbook/build/docs/event-bus/index.html | 48 +++++----- .../build/docs/friendly-exception/index.html | 58 ++++++------ handbook/build/docs/get-start/index.html | 56 +++++------ handbook/build/docs/gooduse/index.html | 48 +++++----- handbook/build/docs/grpc/index.html | 48 +++++----- handbook/build/docs/http/index.html | 48 +++++----- handbook/build/docs/index.html | 48 +++++----- handbook/build/docs/job/index.html | 48 +++++----- handbook/build/docs/local-language/index.html | 48 +++++----- handbook/build/docs/logging/index.html | 48 +++++----- handbook/build/docs/object-mapper/index.html | 50 +++++----- handbook/build/docs/options/index.html | 52 +++++------ handbook/build/docs/performance/index.html | 48 +++++----- .../build/docs/process-service/index.html | 48 +++++----- handbook/build/docs/reference/index.html | 50 +++++----- handbook/build/docs/saas/index.html | 54 +++++------ handbook/build/docs/signalr/index.html | 48 +++++----- handbook/build/docs/source/index.html | 50 +++++----- .../docs/specification-document/index.html | 64 ++++++------- handbook/build/docs/split-db/index.html | 52 +++++------ handbook/build/docs/tran/index.html | 50 +++++----- handbook/build/docs/unittest/index.html | 48 +++++----- handbook/build/docs/view-engine/index.html | 48 +++++----- handbook/build/e0678751.7aa41554.js | 1 + handbook/build/e0678751.ff9b52a4.js | 1 - handbook/build/e1713ffa.623ebfba.js | 1 + handbook/build/e1713ffa.ead08ab9.js | 1 - handbook/build/e50e61ad.088b77e2.js | 1 - handbook/build/e50e61ad.ffe07c07.js | 1 + handbook/build/e6346b20.50623fe1.js | 1 - handbook/build/e6346b20.a0ca1d5f.js | 1 + handbook/build/e6c62f29.d1455fa1.js | 1 + handbook/build/e6c62f29.d44ea22f.js | 1 - handbook/build/f9353588.088c672a.js | 1 + handbook/build/f9353588.bfe4bdd2.js | 1 - handbook/build/f976f453.d1d87a8b.js | 1 - handbook/build/f976f453.e58ba037.js | 1 + handbook/build/fa529204.0f5c487b.js | 1 - handbook/build/fa529204.27cfb9da.js | 1 + handbook/build/fd31aa8c.1e90fa36.js | 1 + handbook/build/fde1f028.00ab3fc0.js | 1 - handbook/build/index.html | 28 +++--- handbook/build/main.2cb9d26e.js | 1 - handbook/build/main.c43a60e9.js | 1 + ...CENSE.txt => main.c43a60e9.js.LICENSE.txt} | 0 handbook/build/runtime~main.9427b071.js | 1 + handbook/build/runtime~main.c11cdd7c.js | 1 - handbook/build/sitemap.xml | 2 +- handbook/docusaurus.config.js | 2 +- 219 files changed, 1831 insertions(+), 1831 deletions(-) delete mode 100644 handbook/build/03ebb857.695212d0.js create mode 100644 handbook/build/03ebb857.bdee66fe.js delete mode 100644 handbook/build/0ddd808e.cf943861.js create mode 100644 handbook/build/0ddd808e.d77719f9.js delete mode 100644 handbook/build/17256d0f.0dd677ec.js create mode 100644 handbook/build/17256d0f.c1719a38.js delete mode 100644 handbook/build/1761adf3.0eeb8b92.js create mode 100644 handbook/build/1761adf3.37f331f5.js create mode 100644 handbook/build/17666df9.37cd28d0.js delete mode 100644 handbook/build/17666df9.a5abd77b.js delete mode 100644 handbook/build/1d7b962e.4baa59fe.js create mode 100644 handbook/build/1d7b962e.7e7e2e9f.js create mode 100644 handbook/build/1e961311.d7cc7b4c.js delete mode 100644 handbook/build/1e961311.fef4867f.js create mode 100644 handbook/build/1ea356f4.44a77987.js delete mode 100644 handbook/build/1ea356f4.853d079e.js create mode 100644 handbook/build/23e7023c.5c499293.js rename handbook/build/{24dcd402.dad85cd2.js => 24dcd402.931bd557.js} (78%) rename handbook/build/{2792faa0.393c7313.js => 2792faa0.c8b601b5.js} (79%) create mode 100644 handbook/build/2a4cb773.949fd694.js delete mode 100644 handbook/build/2a4cb773.c96e5bb6.js create mode 100644 handbook/build/2ae73ff4.074eace3.js delete mode 100644 handbook/build/2ae73ff4.b4cb8011.js create mode 100644 handbook/build/2b04a543.660f2802.js delete mode 100644 handbook/build/2b04a543.9fc467bd.js delete mode 100644 handbook/build/34420422.bd14d00b.js create mode 100644 handbook/build/34420422.f54e4fab.js rename handbook/build/{36793c62.d48973ba.js => 36793c62.81252910.js} (56%) rename handbook/build/{3a6dbab2.2beebf2b.js => 3a6dbab2.89038ec6.js} (79%) create mode 100644 handbook/build/3ab56fdf.d254137a.js delete mode 100644 handbook/build/3ab56fdf.dc6c86e1.js create mode 100644 handbook/build/3e869f93.305c87c2.js delete mode 100644 handbook/build/3e869f93.8686d66c.js delete mode 100644 handbook/build/408ae89d.0e87c449.js create mode 100644 handbook/build/408ae89d.fa344557.js create mode 100644 handbook/build/409819e6.14b77875.js create mode 100644 handbook/build/4930ce4d.867af8f3.js delete mode 100644 handbook/build/4930ce4d.e8539812.js create mode 100644 handbook/build/4bfcf3ee.09b86c5e.js delete mode 100644 handbook/build/4bfcf3ee.9fd3cf97.js create mode 100644 handbook/build/4c30b939.7af2ecca.js delete mode 100644 handbook/build/4c30b939.95d3ea2a.js delete mode 100644 handbook/build/4dbcf072.43551049.js create mode 100644 handbook/build/4dbcf072.86aa2a4d.js delete mode 100644 handbook/build/4e3694ae.befe978c.js create mode 100644 handbook/build/4efad03e.7367e18f.js create mode 100644 handbook/build/525b9089.4330aea1.js delete mode 100644 handbook/build/59d16f51.61813dfb.js create mode 100644 handbook/build/59d16f51.b99a9697.js delete mode 100644 handbook/build/5c4ee1d6.84f4a477.js delete mode 100644 handbook/build/5ce0ebbd.4ab6a852.js create mode 100644 handbook/build/5ce0ebbd.e81097b1.js create mode 100644 handbook/build/5e077782.49e1c594.js delete mode 100644 handbook/build/5e077782.5c58ae24.js create mode 100644 handbook/build/62953dcd.c8565443.js delete mode 100644 handbook/build/62953dcd.dc05b734.js rename handbook/build/{654ac364.b869a9ae.js => 654ac364.56187509.js} (78%) create mode 100644 handbook/build/66076b72.841838a5.js rename handbook/build/{6875c492.5589b6a0.js => 6875c492.45df4276.js} (96%) rename handbook/build/{70699f3e.0d9dc710.js => 70699f3e.ab80af1c.js} (79%) rename handbook/build/{7696a0ae.872ee861.js => 7696a0ae.5c74cfa6.js} (69%) delete mode 100644 handbook/build/7b4b163f.4808d427.js create mode 100644 handbook/build/7b4b163f.dcdeae35.js create mode 100644 handbook/build/7c7b3a8a.a8db9a6c.js delete mode 100644 handbook/build/7c7b3a8a.f2448b6a.js delete mode 100644 handbook/build/7d3779e7.20c05f2d.js create mode 100644 handbook/build/7d3779e7.e94a61da.js create mode 100644 handbook/build/8009abd7.d3326cc7.js create mode 100644 handbook/build/8231c802.e9b1c61b.js delete mode 100644 handbook/build/8231c802.f5780f8f.js create mode 100644 handbook/build/8bbf9761.bb6f6ac0.js delete mode 100644 handbook/build/8bbf9761.f64cda87.js delete mode 100644 handbook/build/8e2b7b33.016f2f3a.js create mode 100644 handbook/build/8e2b7b33.168f86ee.js create mode 100644 handbook/build/902d8112.8f2a4136.js delete mode 100644 handbook/build/902d8112.b9a6df3a.js delete mode 100644 handbook/build/904cf40b.09e071c4.js create mode 100644 handbook/build/904cf40b.806b2fcf.js delete mode 100644 handbook/build/97c3ef29.22942c40.js create mode 100644 handbook/build/97c3ef29.5e50707c.js delete mode 100644 handbook/build/9958fd43.319bacf7.js create mode 100644 handbook/build/9bdac8f0.aaac8e03.js delete mode 100644 handbook/build/9bdac8f0.b38ef64e.js delete mode 100644 handbook/build/a133dc31.7638bbc5.js create mode 100644 handbook/build/a133dc31.e6723c63.js delete mode 100644 handbook/build/a688d5cc.44b37d46.js create mode 100644 handbook/build/a688d5cc.9eea910c.js rename handbook/build/{a6aa9e1f.dad92990.js => a6aa9e1f.7b044f24.js} (98%) delete mode 100644 handbook/build/a74774ac.19465b58.js create mode 100644 handbook/build/a74774ac.fc99cc53.js delete mode 100644 handbook/build/af3e9b99.0b631e94.js create mode 100644 handbook/build/af3e9b99.6400b5bf.js delete mode 100644 handbook/build/b0be1305.06a3f89a.js create mode 100644 handbook/build/b0be1305.e0298c3e.js delete mode 100644 handbook/build/b30e5fe3.41db337f.js create mode 100644 handbook/build/b30e5fe3.f4083332.js delete mode 100644 handbook/build/b80c29d5.100571d2.js create mode 100644 handbook/build/b80c29d5.ae39c9b4.js delete mode 100644 handbook/build/c456980b.530a8035.js create mode 100644 handbook/build/c456980b.ea5bf524.js create mode 100644 handbook/build/cb0a942e.6dfad658.js delete mode 100644 handbook/build/cb0a942e.ba8927ad.js rename handbook/build/{ccc49370.3426e43a.js => ccc49370.3837ba9b.js} (98%) delete mode 100644 handbook/build/ce4b3b2d.873ebbc4.js create mode 100644 handbook/build/d3c206bc.2684bdea.js delete mode 100644 handbook/build/d3c206bc.5e7da086.js delete mode 100644 handbook/build/d3ee75d5.89d8c15a.js create mode 100644 handbook/build/d3ee75d5.b589f955.js delete mode 100644 handbook/build/d43b3010.eaa01519.js create mode 100644 handbook/build/d43b3010.f67b79ab.js delete mode 100644 handbook/build/d631a3bf.2d8e6cb4.js delete mode 100644 handbook/build/d63edb86.067dc58e.js delete mode 100644 handbook/build/d80bb0e0.35e8ea68.js create mode 100644 handbook/build/d80bb0e0.7f8d0918.js delete mode 100644 handbook/build/d8c8d2dc.1ab280a0.js create mode 100644 handbook/build/d8c8d2dc.92db30cc.js delete mode 100644 handbook/build/d8f92c54.6ec458d9.js create mode 100644 handbook/build/d8f92c54.f93d860e.js delete mode 100644 handbook/build/dc10b9c8.92049b15.js create mode 100644 handbook/build/dc10b9c8.f1d42dde.js create mode 100644 handbook/build/dea2fede.13d0ddb5.js delete mode 100644 handbook/build/dea2fede.c67f06e6.js create mode 100644 handbook/build/e0678751.7aa41554.js delete mode 100644 handbook/build/e0678751.ff9b52a4.js create mode 100644 handbook/build/e1713ffa.623ebfba.js delete mode 100644 handbook/build/e1713ffa.ead08ab9.js delete mode 100644 handbook/build/e50e61ad.088b77e2.js create mode 100644 handbook/build/e50e61ad.ffe07c07.js delete mode 100644 handbook/build/e6346b20.50623fe1.js create mode 100644 handbook/build/e6346b20.a0ca1d5f.js create mode 100644 handbook/build/e6c62f29.d1455fa1.js delete mode 100644 handbook/build/e6c62f29.d44ea22f.js create mode 100644 handbook/build/f9353588.088c672a.js delete mode 100644 handbook/build/f9353588.bfe4bdd2.js delete mode 100644 handbook/build/f976f453.d1d87a8b.js create mode 100644 handbook/build/f976f453.e58ba037.js delete mode 100644 handbook/build/fa529204.0f5c487b.js create mode 100644 handbook/build/fa529204.27cfb9da.js create mode 100644 handbook/build/fd31aa8c.1e90fa36.js delete mode 100644 handbook/build/fde1f028.00ab3fc0.js delete mode 100644 handbook/build/main.2cb9d26e.js create mode 100644 handbook/build/main.c43a60e9.js rename handbook/build/{main.2cb9d26e.js.LICENSE.txt => main.c43a60e9.js.LICENSE.txt} (100%) create mode 100644 handbook/build/runtime~main.9427b071.js delete mode 100644 handbook/build/runtime~main.c11cdd7c.js diff --git a/handbook/build/03ebb857.695212d0.js b/handbook/build/03ebb857.695212d0.js deleted file mode 100644 index 9978015484e..00000000000 --- a/handbook/build/03ebb857.695212d0.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{142:function(e,t,a){"use strict";a.d(t,"a",(function(){return d})),a.d(t,"b",(function(){return s}));var n=a(0),b=a.n(n);function c(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function i(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function r(e){for(var t=1;t=0||(b[a]=e[a]);return b}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(b[a]=e[a])}return b}var o=b.a.createContext({}),p=function(e){var t=b.a.useContext(o),a=t;return e&&(a="function"==typeof e?e(t):r(r({},t),e)),a},d=function(e){var t=p(e.components);return b.a.createElement(o.Provider,{value:t},e.children)},O={inlineCode:"code",wrapper:function(e){var t=e.children;return b.a.createElement(b.a.Fragment,{},t)}},j=b.a.forwardRef((function(e,t){var a=e.components,n=e.mdxType,c=e.originalType,i=e.parentName,o=l(e,["components","mdxType","originalType","parentName"]),d=p(a),j=n,s=d["".concat(i,".").concat(j)]||d[j]||O[j]||c;return a?b.a.createElement(s,r(r({ref:t},o),{},{components:a})):b.a.createElement(s,r({ref:t},o))}));function s(e,t){var a=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var c=a.length,i=new Array(c);i[0]=j;var r={};for(var l in t)hasOwnProperty.call(t,l)&&(r[l]=t[l]);r.originalType=e,r.mdxType="string"==typeof e?e:n,i[1]=r;for(var o=2;o();\n')),Object(c.b)("p",null,"\u5982\u9700\u8de8\u5e93\u67e5\u8be2\uff0c\u9700\u7528\u5230\u6570\u636e\u5e93\u6280\u672f\uff0c\u5982 ",Object(c.b)("inlineCode",{parentName:"p"},"SqlServer")," \u94fe\u63a5\u670d\u52a1\u5668\u6216\u540c\u4e49\u8bcd\u3002"),Object(c.b)("ul",null,Object(c.b)("li",{parentName:"ul"},Object(c.b)("strong",{parentName:"li"},"\u52a8\u6001\u5207\u6362\u6570\u636e\u5e93\u8868"))),Object(c.b)("pre",null,Object(c.b)("code",Object(n.a)({parentName:"pre"},{className:"language-cs"}),'// \u76f4\u63a5\u6539\u53d8\u8868\uff0c\u4f1a\u6709\u591a\u7ebf\u7a0b\u64cd\u4f5cbug\uff0c\u540c\u65f6\u65e0\u6cd5\u5237\u65b0\u6a21\u578b\nrepository.ChangeTable("\u6570\u636e\u5e93\u8868");\n\n// \u521b\u5efa\u65b0\u7684 DbContext\uff0c\u7136\u540e\u5237\u65b0 OnModelCreating\uff08\u63a8\u8350\u65b9\u5f0f\uff09\nvar dynamicDbContextResolve = App.TransientServices.GetService>();\nvar dynamicDbContext = dynamicDbContextResolve(typeof(MyDbContextLocator), default);\n// \u91cd\u65b0\u8c03\u7528 OnModelCreating\uff0c\u5728 OnModelCreating \u4e2d\u914d\u7f6e ToTable("\u52a8\u6001\u8868") \u5373\u53ef\u3002\nDynamicModelCacheKeyFactory.RebuildModels();\nvar persons= dynamicDbContext.Set();\npersons.Add(new Person{});\n')),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(n.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(n.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(n.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(n.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(c.b)("div",Object(n.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(c.b)("inlineCode",{parentName:"p"},"DynamicModelCacheKeyFactory")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(c.b)("a",Object(n.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/ef/core/modeling/dynamic-model"}),"EF Core - \u591a\u4e2a\u6a21\u578b\u4e4b\u95f4\u4ea4\u66ff")," \u7ae0\u8282\u3002"))),Object(c.b)("h2",{id:"9277-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.27.7 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(n.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(n.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(n.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(n.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(c.b)("div",Object(n.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(c.b)("a",Object(n.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/03ebb857.bdee66fe.js b/handbook/build/03ebb857.bdee66fe.js new file mode 100644 index 00000000000..77ced039159 --- /dev/null +++ b/handbook/build/03ebb857.bdee66fe.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{142:function(e,t,a){"use strict";a.d(t,"a",(function(){return d})),a.d(t,"b",(function(){return s}));var n=a(0),b=a.n(n);function c(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function i(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function r(e){for(var t=1;t=0||(b[a]=e[a]);return b}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(b[a]=e[a])}return b}var o=b.a.createContext({}),p=function(e){var t=b.a.useContext(o),a=t;return e&&(a="function"==typeof e?e(t):r(r({},t),e)),a},d=function(e){var t=p(e.components);return b.a.createElement(o.Provider,{value:t},e.children)},O={inlineCode:"code",wrapper:function(e){var t=e.children;return b.a.createElement(b.a.Fragment,{},t)}},j=b.a.forwardRef((function(e,t){var a=e.components,n=e.mdxType,c=e.originalType,i=e.parentName,o=l(e,["components","mdxType","originalType","parentName"]),d=p(a),j=n,s=d["".concat(i,".").concat(j)]||d[j]||O[j]||c;return a?b.a.createElement(s,r(r({ref:t},o),{},{components:a})):b.a.createElement(s,r({ref:t},o))}));function s(e,t){var a=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var c=a.length,i=new Array(c);i[0]=j;var r={};for(var l in t)hasOwnProperty.call(t,l)&&(r[l]=t[l]);r.originalType=e,r.mdxType="string"==typeof e?e:n,i[1]=r;for(var o=2;o();\n')),Object(c.b)("p",null,"\u5982\u9700\u8de8\u5e93\u67e5\u8be2\uff0c\u9700\u7528\u5230\u6570\u636e\u5e93\u6280\u672f\uff0c\u5982 ",Object(c.b)("inlineCode",{parentName:"p"},"SqlServer")," \u94fe\u63a5\u670d\u52a1\u5668\u6216\u540c\u4e49\u8bcd\u3002"),Object(c.b)("ul",null,Object(c.b)("li",{parentName:"ul"},Object(c.b)("strong",{parentName:"li"},"\u52a8\u6001\u5207\u6362\u6570\u636e\u5e93\u8868"))),Object(c.b)("pre",null,Object(c.b)("code",Object(n.a)({parentName:"pre"},{className:"language-cs"}),'// \u76f4\u63a5\u6539\u53d8\u8868\uff0c\u4f1a\u6709\u591a\u7ebf\u7a0b\u64cd\u4f5cbug\uff0c\u540c\u65f6\u65e0\u6cd5\u5237\u65b0\u6a21\u578b\nrepository.ChangeTable("\u6570\u636e\u5e93\u8868");\n\n// \u521b\u5efa\u65b0\u7684 DbContext\uff0c\u7136\u540e\u5237\u65b0 OnModelCreating\uff08\u63a8\u8350\u65b9\u5f0f\uff09\nvar dynamicDbContextResolve = App.TransientServices.GetService>();\nvar dynamicDbContext = dynamicDbContextResolve(typeof(MyDbContextLocator), default);\n// \u91cd\u65b0\u8c03\u7528 OnModelCreating\uff0c\u5728 OnModelCreating \u4e2d\u914d\u7f6e ToTable("\u52a8\u6001\u8868") \u5373\u53ef\u3002\nDynamicModelCacheKeyFactory.RebuildModels();\nvar persons= dynamicDbContext.Set();\npersons.Add(new Person{});\n')),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(n.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(n.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(n.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(n.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(c.b)("div",Object(n.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(c.b)("inlineCode",{parentName:"p"},"DynamicModelCacheKeyFactory")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(c.b)("a",Object(n.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/ef/core/modeling/dynamic-model"}),"EF Core - \u591a\u4e2a\u6a21\u578b\u4e4b\u95f4\u4ea4\u66ff")," \u7ae0\u8282\u3002"))),Object(c.b)("h2",{id:"9277-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.27.7 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(n.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(n.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(n.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(n.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(c.b)("div",Object(n.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(c.b)("a",Object(n.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/0ddd808e.cf943861.js b/handbook/build/0ddd808e.cf943861.js deleted file mode 100644 index 973864887ff..00000000000 --- a/handbook/build/0ddd808e.cf943861.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return m})),t.d(n,"b",(function(){return d}));var a=t(0),i=t.n(a);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function b(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function c(e){for(var n=1;n=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var p=i.a.createContext({}),o=function(e){var n=i.a.useContext(p),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},m=function(e){var n=o(e.components);return i.a.createElement(p.Provider,{value:n},e.children)},s={inlineCode:"code",wrapper:function(e){var n=e.children;return i.a.createElement(i.a.Fragment,{},n)}},u=i.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,r=e.originalType,b=e.parentName,p=l(e,["components","mdxType","originalType","parentName"]),m=o(t),u=a,d=m["".concat(b,".").concat(u)]||m[u]||s[u]||r;return t?i.a.createElement(d,c(c({ref:n},p),{},{components:t})):i.a.createElement(d,c({ref:n},p))}));function d(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var r=t.length,b=new Array(r);b[0]=u;var c={};for(var l in n)hasOwnProperty.call(n,l)&&(c[l]=n[l]);c.originalType=e,c.mdxType="string"==typeof e?e:a,b[1]=c;for(var p=2;pMvc \u63a7\u5236\u5668 \u7ea6\u5b9a\u548c\u7f3a\u70b9",id:"52-mvc-\u63a7\u5236\u5668-\u7ea6\u5b9a\u548c\u7f3a\u70b9",children:[{value:"5.2.1 WebAPI \u7ea6\u5b9a",id:"521-webapi-\u7ea6\u5b9a",children:[]},{value:"5.2.2 .NET Core WebAPI \u7f3a\u70b9",id:"522-net-core-webapi-\u7f3a\u70b9",children:[]}]},{value:"5.3 \u52a8\u6001 WebAPI \u63a7\u5236\u5668",id:"53-\u52a8\u6001-webapi-\u63a7\u5236\u5668",children:[]},{value:"5.4 \u6ce8\u518c\u52a8\u6001 WebAPI \u670d\u52a1",id:"54-\u6ce8\u518c\u52a8\u6001-webapi-\u670d\u52a1",children:[]},{value:"5.5 \u7b2c\u4e00\u4e2a\u4f8b\u5b50",id:"55-\u7b2c\u4e00\u4e2a\u4f8b\u5b50",children:[]},{value:"5.6 \u52a8\u6001 WebAPI \u539f\u7406\u89e3\u6790",id:"56-\u52a8\u6001-webapi-\u539f\u7406\u89e3\u6790",children:[{value:"5.6.1 \u63a7\u5236\u5668\u7279\u6027\u63d0\u4f9b\u5668",id:"561-\u63a7\u5236\u5668\u7279\u6027\u63d0\u4f9b\u5668",children:[]},{value:"5.6.2 \u5e94\u7528\u6a21\u578b\u8f6c\u6362\u5668",id:"562-\u5e94\u7528\u6a21\u578b\u8f6c\u6362\u5668",children:[]}]},{value:"5.7 \u52a8\u6001 WebAPI \u914d\u7f6e\u7ea6\u5b9a",id:"57-\u52a8\u6001-webapi-\u914d\u7f6e\u7ea6\u5b9a",children:[{value:"5.7.1 \u63a7\u5236\u5668\u9ed8\u8ba4\u7ea6\u5b9a",id:"571-\u63a7\u5236\u5668\u9ed8\u8ba4\u7ea6\u5b9a",children:[]},{value:"5.7.2 \u52a8\u4f5c\u65b9\u6cd5\u9ed8\u8ba4\u7ea6\u5b9a",id:"572-\u52a8\u4f5c\u65b9\u6cd5\u9ed8\u8ba4\u7ea6\u5b9a",children:[]},{value:"5.7.3 \u8bf7\u6c42\u8c13\u8bcd\u9ed8\u8ba4\u7ea6\u5b9a",id:"573-\u8bf7\u6c42\u8c13\u8bcd\u9ed8\u8ba4\u7ea6\u5b9a",children:[]},{value:"5.7.4 \u8def\u7531\u5730\u5740\u9ed8\u8ba4\u7ea6\u5b9a",id:"574-\u8def\u7531\u5730\u5740\u9ed8\u8ba4\u7ea6\u5b9a",children:[]},{value:"5.7.5 \u5176\u4ed6\u7ea6\u5b9a",id:"575-\u5176\u4ed6\u7ea6\u5b9a",children:[]}]},{value:"5.8 \u66f4\u591a\u4f8b\u5b50",id:"58-\u66f4\u591a\u4f8b\u5b50",children:[{value:"5.8.1 \u591a\u79cd\u8bf7\u6c42\u8c13\u8bcd\u65b9\u6cd5",id:"581-\u591a\u79cd\u8bf7\u6c42\u8c13\u8bcd\u65b9\u6cd5",children:[]},{value:"5.8.2 \u591a\u4e2a\u81ea\u5b9a\u4e49\u52a8\u4f5c\u65b9\u6cd5",id:"582-\u591a\u4e2a\u81ea\u5b9a\u4e49\u52a8\u4f5c\u65b9\u6cd5",children:[]},{value:"5.8.3 \u5e26\u53c2\u6570\u52a8\u4f5c\u65b9\u6cd5",id:"583-\u5e26\u53c2\u6570\u52a8\u4f5c\u65b9\u6cd5",children:[]},{value:"5.8.5 GET/HEAD \u7c7b\u7c7b\u578b\u53c2\u6570",id:"585-gethead-\u7c7b\u7c7b\u578b\u53c2\u6570",children:[]},{value:"5.8.6 \u81ea\u5b9a\u4e49\u53c2\u6570\u4f4d\u7f6e",id:"586-\u81ea\u5b9a\u4e49\u53c2\u6570\u4f4d\u7f6e",children:[]},{value:"5.8.7 \u81ea\u5b9a\u4e49\u8bf7\u6c42\u8c13\u8bcd",id:"587-\u81ea\u5b9a\u4e49\u8bf7\u6c42\u8c13\u8bcd",children:[]},{value:"5.8.8 \u652f\u6301\u591a\u4e2a\u8c13\u8bcd",id:"588-\u652f\u6301\u591a\u4e2a\u8c13\u8bcd",children:[]},{value:"5.8.9 \u652f\u6301\u81ea\u5b9a\u4e49\u8def\u7531",id:"589-\u652f\u6301\u81ea\u5b9a\u4e49\u8def\u7531",children:[]},{value:"5.8.10 \u591a\u8def\u7531\u968f\u610f\u7ec4\u5408",id:"5810-\u591a\u8def\u7531\u968f\u610f\u7ec4\u5408",children:[]},{value:"5.8.11 \u652f\u6301\u7248\u672c\u63a7\u5236",id:"5811-\u652f\u6301\u7248\u672c\u63a7\u5236",children:[]},{value:"5.8.12 \u4e0d\u516c\u5f00\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5",id:"5812-\u4e0d\u516c\u5f00\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5",children:[]}]},{value:"5.9 [ApiDescriptionSettings]",id:"59-apidescriptionsettings",children:[{value:"5.9.1 \u5185\u7f6e\u914d\u7f6e",id:"591-\u5185\u7f6e\u914d\u7f6e",children:[]},{value:"5.9.2 Name \u914d\u7f6e",id:"592-name-\u914d\u7f6e",children:[]},{value:"5.9.3 KeepName \u914d\u7f6e",id:"593-keepname-\u914d\u7f6e",children:[]},{value:"5.9.4 SplitCamelCase \u914d\u7f6e",id:"594-splitcamelcase-\u914d\u7f6e",children:[]},{value:"5.9.5 KeepVerb \u914d\u7f6e",id:"595-keepverb-\u914d\u7f6e",children:[]},{value:"5.9.6 Enabled \u914d\u7f6e",id:"596-enabled-\u914d\u7f6e",children:[]},{value:"5.9.7 Module \u914d\u7f6e",id:"597-module-\u914d\u7f6e",children:[]},{value:"5.9.8 Version \u914d\u7f6e",id:"598-version-\u914d\u7f6e",children:[]},{value:"5.9.9 Groups \u914d\u7f6e",id:"599-groups-\u914d\u7f6e",children:[]},{value:"5.9.10 Tag \u914d\u7f6e",id:"5910-tag-\u914d\u7f6e",children:[]}]},{value:"5.10 DynamicApiControllerSettings \u914d\u7f6e",id:"510-dynamicapicontrollersettings-\u914d\u7f6e",children:[{value:"5.10.1 \u652f\u6301 Mvc \u63a7\u5236\u5668 \u52a8\u6001\u914d\u7f6e",id:"5101-\u652f\u6301-mvc-\u63a7\u5236\u5668-\u52a8\u6001\u914d\u7f6e",children:[]}]},{value:"5.11 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"511-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],s={rightToc:m};function u(e){var n=e.components,t=Object(i.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},s,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"51-\u4ec0\u4e48\u662f\u63a7\u5236\u5668"},"5.1 \u4ec0\u4e48\u662f\u63a7\u5236\u5668"),Object(r.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u63a7\u5236\u5668\u662f\u4e00\u4e2a\u627f\u4e0a\u542f\u4e0b\u7684\u4f5c\u7528\uff0c\u6839\u636e\u7528\u6237\u8f93\u5165\uff0c\u6267\u884c\u54cd\u5e94\u884c\u4e3a\uff08\u52a8\u4f5c\u65b9\u6cd5\uff09\uff0c\u540c\u65f6\u5728\u884c\u4e3a\u4e2d\u8c03\u7528\u6a21\u578b\u7684\u4e1a\u52a1\u903b\u8f91\uff0c\u8fd4\u56de\u7ed9\u7528\u6237\u7ed3\u679c\uff08\u89c6\u56fe\uff09\u3002"),Object(r.b)("img",{src:Object(b.a)("img/kzq.png")}),Object(r.b)("p",null),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u4e2d\uff0c\u63a7\u5236\u5668\u6709\u4e24\u79cd\u8868\u73b0\u5f62\u5f0f\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Mvc"),"\uff08\u5e26\u89c6\u56fe\uff09"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"WebAPI"),"\uff08RESTful API\uff09")),Object(r.b)(c.a,{defaultValue:"mvc",values:[{label:"Mvc \u63a7\u5236\u5668",value:"mvc"},{label:"WebAPI \u63a7\u5236\u5668",value:"webapi"}],mdxType:"Tabs"},Object(r.b)(l.a,{value:"mvc",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,7}","{1,5,7}":!0}),"using Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n public class MvcController : Controller\n {\n public IActionResult Index()\n {\n return View();\n }\n }\n}\n"))),Object(r.b)(l.a,{value:"webapi",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,6,8,9}","{1,5,6,8,9}":!0}),'using Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n public class WebApiController : ControllerBase\n {\n [HttpGet]\n public IActionResult Get()\n {\n return Content(nameof(Fur));\n }\n }\n}\n')))),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Mvc")," \u63a7\u5236\u5668\u548c ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a7\u5236\u5668\u6700\u5927\u7684\u533a\u522b\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a7\u5236\u5668\u4e0d\u5e26 ",Object(r.b)("strong",{parentName:"p"},"\u89c6\u56fe")," \u548c\u901a\u8fc7 ",Object(r.b)("strong",{parentName:"p"},"\u8bf7\u6c42\u8c13\u8bcd\u548c\u8def\u7531\u5730\u5740\u54cd\u5e94\u884c\u4e3a"),"\u3002"),Object(r.b)("h2",{id:"52-mvc-\u63a7\u5236\u5668-\u7ea6\u5b9a\u548c\u7f3a\u70b9"},"5.2 ",Object(r.b)("inlineCode",{parentName:"h2"},"Mvc \u63a7\u5236\u5668")," \u7ea6\u5b9a\u548c\u7f3a\u70b9"),Object(r.b)("p",null,"\u5728\u5b66\u4e60\u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a7\u5236\u5668\u4e4b\u524d\uff0c\u9996\u5148\u4e86\u89e3 ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u4e2d ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u7684\u4e00\u4e9b\u7ea6\u5b9a\u548c\u6ce8\u610f\u4e8b\u9879\u3002"),Object(r.b)("h3",{id:"521-webapi-\u7ea6\u5b9a"},"5.2.1 ",Object(r.b)("inlineCode",{parentName:"h3"},"WebAPI")," \u7ea6\u5b9a"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u5e94\u7528\u4e2d\uff0c\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a7\u5236\u5668\u9700\u9075\u5faa\u4ee5\u4e0b\u7ea6\u5b9a\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u63a7\u5236\u5668\u7c7b",Object(r.b)("strong",{parentName:"li"},"\u5fc5\u987b\u7ee7\u627f ",Object(r.b)("inlineCode",{parentName:"strong"},"ControllerBase")," \u6216\u95f4\u63a5\u7ee7\u627f")),Object(r.b)("li",{parentName:"ul"},"\u52a8\u4f5c\u65b9\u6cd5",Object(r.b)("strong",{parentName:"li"},"\u5fc5\u987b\u8d34\u6709 ",Object(r.b)("inlineCode",{parentName:"strong"},"[HttpMethod]")," \u7279\u6027\uff0c\u5982\uff1a",Object(r.b)("inlineCode",{parentName:"strong"},"[HttpGet]"))),Object(r.b)("li",{parentName:"ul"},"\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5",Object(r.b)("strong",{parentName:"li"},"\u81f3\u5c11\u6709\u4e00\u4e2a\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"strong"},"[Route]")," \u7279\u6027")),Object(r.b)("li",{parentName:"ul"},"\u751f\u6210 ",Object(r.b)("inlineCode",{parentName:"li"},"WebAPI")," \u8def\u7531\u5730\u5740\u65f6\u4f1a\u81ea\u52a8\u53bb\u6389\u63a7\u5236\u5668\u540d\u79f0 ",Object(r.b)("inlineCode",{parentName:"li"},"Controller")," \u540e\u7f00\uff0c\u540c\u65f6\u4e5f\u4f1a\u53bb\u6389\u52a8\u4f5c\u65b9\u6cd5\u5339\u914d\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"HttpVerb")," \u8c13\u8bcd\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"li"},"GET\uff0cPOST\uff0cDELETE\uff0cPUT")," \u7b49"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("strong",{parentName:"li"},"\u4e0d\u652f\u6301\u8fd4\u56de\u975e ",Object(r.b)("inlineCode",{parentName:"strong"},"IEnumerable")," \u6cdb\u578b\u5bf9\u8c61")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("strong",{parentName:"li"},"\u4e0d\u652f\u6301\u7c7b\u7c7b\u578b\u53c2\u6570\u5728 ",Object(r.b)("inlineCode",{parentName:"strong"},"GET\uff0cHEAD")," \u8bf7\u6c42\u4e0b\u751f\u6210 ",Object(r.b)("inlineCode",{parentName:"strong"},"Query")," \u53c2\u6570"))),Object(r.b)("p",null,"\u9664\u4e86\u4e0a\u8ff0\u7ea6\u5b9a\u5916\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u8def\u7531\u5730\u5740",Object(r.b)("strong",{parentName:"p"},"\u57fa\u672c\u9760\u624b\u5de5\u5b8c\u6210"),"\uff0c\u4e0d\u5229\u4e8e\u4e66\u5199\uff0c\u4e0d\u5229\u4e8e\u7ef4\u62a4\uff0c\u518d\u8005\uff0c\u5728\u79fb\u52a8\u5e94\u7528\u5bf9\u63a5\u4e2d\u96be\u4ee5\u8fdb\u884c\u591a\u7248\u672c\u63a7\u5236\u3002"),Object(r.b)("h3",{id:"522-net-core-webapi-\u7f3a\u70b9"},"5.2.2 ",Object(r.b)("inlineCode",{parentName:"h3"},".NET Core WebAPI")," \u7f3a\u70b9"),Object(r.b)("p",null,"\u901a\u8fc7\u4e0a\u4e00\u7ae0\u8282\u53ef\u4ee5\u770b\u51fa\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u5e94\u7528\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u9700\u8981\u9075\u5faa\u79cd\u79cd\u7ea6\u5b9a\uff0c\u800c\u4e14\u5bb9\u6613\u51fa\u9519\u3002"),Object(r.b)("p",null,"\u9664\u4e86\u8fd9\u4e9b\u7ea6\u5b9a\uff0c",Object(r.b)("inlineCode",{parentName:"p"},".NET Core WebAPI")," \u6709\u4ee5\u4e0b\u7f3a\u70b9\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u8def\u7531\u5730\u5740\u57fa\u672c\u9760\u624b\u5de5\u5b8c\u6210"),Object(r.b)("li",{parentName:"ul"},"\u5728\u73b0\u5728\u79fb\u52a8\u4e3a\u738b\u7684\u65f6\u4ee3\uff0c\u4e0d\u5229\u4e8e\u8fdb\u884c\u591a\u7248\u672c\u63a7\u5236"),Object(r.b)("li",{parentName:"ul"},"\u5bf9\u63a5 ",Object(r.b)("inlineCode",{parentName:"li"},"Swagger")," \u6587\u6863\u5206\u7ec4\u6bd4\u8f83\u590d\u6742"),Object(r.b)("li",{parentName:"ul"},"\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"li"},"Policy")," \u7b56\u7565\u6388\u6743\u4e5f\u6bd4\u8f83\u590d\u6742"),Object(r.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\u63a7\u5236\u5668\u70ed\u62d4\u63d2\u63d2\u4ef6\u5316"),Object(r.b)("li",{parentName:"ul"},"\u96be\u4ee5\u5b9e\u73b0\u590d\u6742\u81ea\u5b9a\u4e49\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"RESTful API")," \u98ce\u683c")),Object(r.b)("h2",{id:"53-\u52a8\u6001-webapi-\u63a7\u5236\u5668"},"5.3 \u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"h2"},"WebAPI")," \u63a7\u5236\u5668"),Object(r.b)("p",null,"\u9488\u5bf9\u4ee5\u4e0a ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u63d0\u4f9b\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u5fc5\u987b\u9075\u5faa\u7684\u7ea6\u5b9a\u548c\u4e0d\u53ef\u907f\u514d\u7684\u7f3a\u70b9\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u521b\u9020\u51fa\u4e00\u79cd\u66f4\u52a0\u7075\u6d3b\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a7\u5236\u5668\u7684\u65b9\u5f0f\u3002"),Object(r.b)("p",null,"\u8fd9\u4e2a\u65b9\u5f0f\u5728\u7ee7\u627f\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core WebAPI")," \u6240\u6709\u4f18\u70b9\uff0c\u540c\u65f6\u8fdb\u884c\u4e86\u5927\u91cf\u62d3\u5c55\u548c\u4f18\u5316\u3002\u4f18\u5316\u540e\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u5177\u6709\u4ee5\u4e0b\u4f18\u70b9\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u5177\u5907\u539f\u6709\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"ControllerBase")," \u6240\u6709\u529f\u80fd"),Object(r.b)("li",{parentName:"ul"},"\u652f\u6301",Object(r.b)("strong",{parentName:"li"},"\u4efb\u610f\u516c\u5f00 \u975e\u9759\u6001 \u975e\u62bd\u8c61 \u975e\u6cdb\u578b\u7c7b"),"\u8f6c\u63a7\u5236\u5668"),Object(r.b)("li",{parentName:"ul"},"\u63d0\u4f9b\u66f4\u52a0\u7075\u6d3b\u65b9\u4fbf\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"IDynamicApiController")," \u7a7a\u63a5\u53e3\u6216 ",Object(r.b)("inlineCode",{parentName:"li"},"[DynamicApiController]")," \u7279\u6027\u66ff\u4ee3 ",Object(r.b)("inlineCode",{parentName:"li"},"ControllerBase")," \u62bd\u8c61\u7c7b"),Object(r.b)("li",{parentName:"ul"},"\u65e0\u9700\u624b\u52a8\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"li"},"[HttpMethod]")," \u7279\u6027\uff0c\u540c\u65f6\u652f\u6301\u4e00\u4e2a\u52a8\u4f5c\u65b9\u6cd5\u591a\u4e2a ",Object(r.b)("inlineCode",{parentName:"li"},"HttpVerb")),Object(r.b)("li",{parentName:"ul"},"\u65e0\u9700\u624b\u52a8\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"li"},"[Route]")," \u7279\u6027\uff0c\u652f\u6301\u66f4\u52a0\u7075\u6d3b\u7684\u914d\u7f6e\u53ca\u81ea\u52a8\u8def\u7531\u751f\u6210"),Object(r.b)("li",{parentName:"ul"},"\u652f\u6301\u8fd4\u56de\u6cdb\u578b\u63a5\u53e3\uff0c\u6cdb\u578b\u7c7b"),Object(r.b)("li",{parentName:"ul"},"\u548c ",Object(r.b)("inlineCode",{parentName:"li"},"Swagger")," \u6df1\u5ea6\u7ed3\u5408\uff0c\u63d0\u4f9b\u6781\u5176\u65b9\u4fbf\u7684\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"li"},"Swagger")," \u5206\u7ec4\u914d\u7f6e"),Object(r.b)("li",{parentName:"ul"},"\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"li"},"Basic Auth\uff0cJwt\uff0cApiKey")," \u7b49\u591a\u79cd\u6743\u9650\u7075\u6d3b\u914d\u7f6e"),Object(r.b)("li",{parentName:"ul"},"\u652f\u6301\u63a7\u5236\u5668\u3001\u52a8\u4f5c\u65b9\u6cd5",Object(r.b)("strong",{parentName:"li"},"\u7248\u672c\u63a7\u5236"),"\u529f\u80fd"),Object(r.b)("li",{parentName:"ul"},"\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"li"},"GET\u3001HEAD")," \u8bf7\u6c42\u81ea\u52a8\u8f6c\u6362 ",Object(r.b)("inlineCode",{parentName:"li"},"\u7c7b\u7c7b\u578b\u53c2\u6570")),Object(r.b)("li",{parentName:"ul"},"\u652f\u6301\u751f\u6210 ",Object(r.b)("inlineCode",{parentName:"li"},"OAS3")," \u63a5\u53e3\u89c4\u8303")),Object(r.b)("h2",{id:"54-\u6ce8\u518c\u52a8\u6001-webapi-\u670d\u52a1"},"5.4 \u6ce8\u518c\u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"h2"},"WebAPI")," \u670d\u52a1"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{11} title="Fur.Web.Core\\FurWebCoreStartup.cs"',"{11}":!0,title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddControllers()\n .AddDynamicApiControllers();\n }\n }\n}\n")),Object(r.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},".AddDynamicApiControllers()")," \u5fc5\u987b\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"services.AddControllers()")," \u4e4b\u540e\u6ce8\u518c\u3002"))),Object(r.b)("h2",{id:"55-\u7b2c\u4e00\u4e2a\u4f8b\u5b50"},"5.5 \u7b2c\u4e00\u4e2a\u4f8b\u5b50"),Object(r.b)("p",null,"\u521b\u5efa\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"FurAppService")," \u7c7b\u7ee7\u627f ",Object(r.b)("inlineCode",{parentName:"p"},"IDynamicApiController")," \u63a5\u53e3 \u6216 \u8d34 ",Object(r.b)("inlineCode",{parentName:"p"},"[DynamicApiController]")," \u7279\u6027\uff0c\u5e76\u5728\u8fd9\u4e2a\u7c7b\u4e2d\u7f16\u5199\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"Get")," \u65b9\u6cd5\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("strong",{parentName:"li"},Object(r.b)("inlineCode",{parentName:"strong"},"IDynamicApiController")," \u65b9\u5f0f"))),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,7}","{1,5,7}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return $"Hello {nameof(Fur)}";\n }\n }\n}\n')),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("strong",{parentName:"li"},Object(r.b)("inlineCode",{parentName:"strong"},"[DynamicApiController]")," \u65b9\u5f0f"))),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,8}","{1,5,8}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [DynamicApiController]\n public class FurAppService\n {\n public string Get()\n {\n return $"Hello {nameof(Fur)}";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a5\u53e3\u5c31\u8fd9\u4e48\u751f\u6210\u4e86\u3002"),Object(r.b)("img",{src:Object(b.a)("img/dyglz.gif")}),Object(r.b)("h2",{id:"56-\u52a8\u6001-webapi-\u539f\u7406\u89e3\u6790"},"5.6 \u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"h2"},"WebAPI")," \u539f\u7406\u89e3\u6790"),Object(r.b)("h3",{id:"561-\u63a7\u5236\u5668\u7279\u6027\u63d0\u4f9b\u5668"},"5.6.1 \u63a7\u5236\u5668\u7279\u6027\u63d0\u4f9b\u5668"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4f1a\u5728\u5e94\u7528\u542f\u52a8\u65f6\u6ce8\u518c ",Object(r.b)("inlineCode",{parentName:"p"},"DynamicApiControllerFeatureProvider")," \u63a7\u5236\u5668\u7279\u6027\u63d0\u4f9b\u5668\uff0c\u8be5\u63d0\u4f9b\u5668\u7ee7\u627f\u81ea ",Object(r.b)("inlineCode",{parentName:"p"},"ControllerFeatureProvider")," \u7c7b\u3002"),Object(r.b)("p",null,"\u63a5\u7740\u91cd\u5199 ",Object(r.b)("inlineCode",{parentName:"p"},"bool IsController(TypeInfo typeInfo)")," \u65b9\u6cd5\uff0c\u7528\u6765\u6807\u8bc6\u63a7\u5236\u5668\u7c7b\u578b\u3002\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c",Object(r.b)("strong",{parentName:"p"},"\u7ee7\u627f\u81ea ",Object(r.b)("inlineCode",{parentName:"strong"},"ControllerBase")," \u7c7b\u6216 ",Object(r.b)("inlineCode",{parentName:"strong"},"IDynamicApiController")," \u63a5\u53e3\u6216 ",Object(r.b)("inlineCode",{parentName:"strong"},"[DynamicApiController]")," \u7279\u6027\u90fd\u4f1a\u88ab\u6807\u8bb0\u4e3a\u63a7\u5236\u5668\u7c7b\u578b\u3002")),Object(r.b)("h3",{id:"562-\u5e94\u7528\u6a21\u578b\u8f6c\u6362\u5668"},"5.6.2 \u5e94\u7528\u6a21\u578b\u8f6c\u6362\u5668"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u540c\u65f6\u5728\u5e94\u7528\u542f\u52a8\u65f6\u6ce8\u518c ",Object(r.b)("inlineCode",{parentName:"p"},"DynamicApiControllerApplicationModelConvention")," \u5e94\u7528\u6a21\u578b\u8f6c\u6362\u5668\uff0c\u8be5\u8f6c\u6362\u5668\u7ee7\u627f\u81ea ",Object(r.b)("inlineCode",{parentName:"p"},"IApplicationModelConvention")," \u63a5\u53e3\u3002"),Object(r.b)("p",null,"\u63a5\u7740\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"p"},"void Apply(ApplicationModel application)")," \u63a5\u53e3\u65b9\u6cd5\u3002\u5728\u8be5\u65b9\u6cd5\u4e2d\u914d\u7f6e\u63a7\u5236\u5668\u540d\u79f0\u3001\u8def\u7531\u3001\u5bfc\u51fa\u53ef\u89c1\u6027\u53ca\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u3001\u8def\u7531\u3001\u5bfc\u51fa\u53ef\u89c1\u6027\u7b49\u3002"),Object(r.b)("p",null,"\u5b9e\u9645\u4e0a\u8be5\u65b9\u6cd5\u505a\u7684\u5c31\u662f\u6309\u7167 ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("a",Object(a.a)({parentName:"strong"},{href:"#521-webapi-%E7%BA%A6%E5%AE%9A"}),"WebAPI \u7ea6\u5b9a"))," \u63d0\u524d\u5e2e\u6211\u4eec\u914d\u7f6e\u597d\u8def\u7531\u3001\u8bf7\u6c42\u8c13\u8bcd\u7b49\u4fe1\u606f\u3002\u907f\u514d\u4e86\u624b\u52a8\u914d\u7f6e\u7684\u540c\u65f6\u8fd8\u589e\u52a0\u4e86\u8bb8\u591a\u65b0\u7279\u6027\uff0c\u5982",Object(r.b)("strong",{parentName:"p"},"\u7248\u672c\u63a7\u5236\u3002")),Object(r.b)("h2",{id:"57-\u52a8\u6001-webapi-\u914d\u7f6e\u7ea6\u5b9a"},"5.7 \u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"h2"},"WebAPI")," \u914d\u7f6e\u7ea6\u5b9a"),Object(r.b)("h3",{id:"571-\u63a7\u5236\u5668\u9ed8\u8ba4\u7ea6\u5b9a"},"5.7.1 \u63a7\u5236\u5668\u9ed8\u8ba4\u7ea6\u5b9a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u751f\u6210\u63a7\u5236\u5668\u540d\u79f0\u9ed8\u8ba4\u53bb\u9664\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"AppServices\uff0cAppService\uff0cApiController\uff0cController\uff0cServices\uff0cService")," \u4f5c\u4e3a\u524d\u540e\u7f00\u7684\u5b57\u7b26\u4e32\u3002\u89c1\u7b2c\u4e00\u4e2a\u4f8b\u5b50\u4e2d\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"FurAppService -> Fur")," ",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u63a7\u5236\u5668\u540d\u79f0\u5e26 ",Object(r.b)("inlineCode",{parentName:"li"},"V[0-9_]")," \u7ed3\u5c3e\u7684\uff0c\u4f1a\u81ea\u52a8\u751f\u6210\u63a7\u5236\u5668\u7248\u672c\u53f7\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"li"},"FurAppServiceV2 -> Fur@2"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"FurAppServiceV1_1_0 -> Fur@1.1.0"),"\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u7248\u672c\u5206\u9694\u7b26\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u63a7\u5236\u540d\u79f0\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"\u9a86\u9a7c\u547d\u540d\uff08CamelCase\uff09")," \u4f1a\u81ea\u52a8\u5207\u5272\u6210\u591a\u4e2a\u5355\u8bcd ",Object(r.b)("inlineCode",{parentName:"li"},"-")," \u8fde\u63a5\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e"))),Object(r.b)("h3",{id:"572-\u52a8\u4f5c\u65b9\u6cd5\u9ed8\u8ba4\u7ea6\u5b9a"},"5.7.2 \u52a8\u4f5c\u65b9\u6cd5\u9ed8\u8ba4\u7ea6\u5b9a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u751f\u6210\u7684\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u9ed8\u8ba4\u53bb\u9664\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"Post/Add/Create/Insert/Submit\uff0cGetAll/GetList/Get/Find/Fetch/Query/Search\uff0cPut/Update\uff0cDelete/Remove/Clear\uff0cPatch")," \u5f00\u5934\u7684\u5b57\u7b26\u4e32\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u751f\u6210\u7684\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u9ed8\u8ba4\u53bb\u9664\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"Async")," \u4f5c\u4e3a\u524d\u540e\u7f00\u7684\u5b57\u7b26\u4e32\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u5e26 ",Object(r.b)("inlineCode",{parentName:"li"},"V[0-9_]")," \u7ed3\u5c3e\u7684\uff0c\u4f1a\u81ea\u52a8\u751f\u6210\u52a8\u4f5c\u65b9\u6cd5\u7248\u672c\u53f7\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"li"},"ChangePasswordV2 -> ChangePassword@2"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"ChangePasswordV1_1_0 -> ChangePassword@1.1.0"),"\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u7248\u672c\u5206\u9694\u7b26\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"\u9a86\u9a7c\u547d\u540d\uff08CamelCase\uff09")," \u4f1a\u81ea\u52a8\u5207\u5272\u6210\u591a\u4e2a\u5355\u8bcd ",Object(r.b)("inlineCode",{parentName:"li"},"-")," \u8fde\u63a5\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u52a8\u4f5c\u65b9\u6cd5\u53c2\u6570\u5c06\u81ea\u52a8\u8f6c\u4e3a\u5c0f\u5199\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e"))),Object(r.b)("h3",{id:"573-\u8bf7\u6c42\u8c13\u8bcd\u9ed8\u8ba4\u7ea6\u5b9a"},"5.7.3 \u8bf7\u6c42\u8c13\u8bcd\u9ed8\u8ba4\u7ea6\u5b9a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u52a8\u4f5c\u65b9\u6cd5\u540d",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"Post/Add/Create/Insert/Submit")," \u5f00\u5934\uff0c\u5219\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"li"},"[HttpPost]")," \u7279\u6027\u3002"),Object(r.b)("li",{parentName:"ul"},"\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"GetAll/GetList/Get/Find/Fetch/Query")," \u5f00\u5934\uff0c\u5219\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"li"},"[HttpGet]")," \u7279\u6027\u3002"),Object(r.b)("li",{parentName:"ul"},"\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"Put/Update")," \u5f00\u5934\uff0c\u5219\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"li"},"[HttpPut]")," \u7279\u6027\u3002"),Object(r.b)("li",{parentName:"ul"},"\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"Delete/Remove/Clear")," \u5f00\u5934\uff0c\u5219\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"li"},"[HttpDelete]")," \u7279\u6027\u3002"),Object(r.b)("li",{parentName:"ul"},"\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"Patch")," \u5f00\u5934\uff0c\u5219\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"li"},"[HttpPatch]")," \u7279\u6027"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")))),Object(r.b)("li",{parentName:"ul"},"\u5982\u679c\u4e0d\u5728\u4e0a\u9762\u7ea6\u5b9a\u4e2d\uff0c\u5219\u9ed8\u8ba4\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"li"},"[HttpPost]")," \u7279\u6027\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e"))),Object(r.b)("h3",{id:"574-\u8def\u7531\u5730\u5740\u9ed8\u8ba4\u7ea6\u5b9a"},"5.7.4 \u8def\u7531\u5730\u5740\u9ed8\u8ba4\u7ea6\u5b9a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u9ed8\u8ba4\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"api")," \u5f00\u5934\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u9ed8\u8ba4\u8f6c\u6362\u4e3a\u5c0f\u5199\u8def\u7531\u5730\u5740\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u751f\u6210\u63a7\u5236\u5668\u8def\u7531\u6a21\u677f\u683c\u5f0f\u4e3a\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"api/\u524d\u7f6e\u53c2\u6570\u5217\u8868/\u6a21\u5757\u540d\u6216\u9ed8\u8ba4\u533a\u57df\u540d/[controller@\u7248\u672c\u53f7]/\u540e\u7f6e\u53c2\u6570\u5217\u8868")),Object(r.b)("li",{parentName:"ul"},"\u751f\u6210\u52a8\u4f5c\u65b9\u6cd5\u8def\u7531\u6a21\u677f\u683c\u5f0f\u4e3a\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"\u524d\u7f6e\u53c2\u6570\u5217\u8868/\u6a21\u5757\u540d/[action@\u7248\u672c\u53f7]/\u540e\u7f6e\u53c2\u6570\u5217\u8868"))),Object(r.b)("h3",{id:"575-\u5176\u4ed6\u7ea6\u5b9a"},"5.7.5 \u5176\u4ed6\u7ea6\u5b9a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u9ed8\u8ba4\u4e0d\u5904\u7406 ",Object(r.b)("inlineCode",{parentName:"li"},"ControllerBase")," \u63a7\u5236\u5668\u7c7b\u578b\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u9ed8\u8ba4\u4e0d\u5904\u7406 ",Object(r.b)("inlineCode",{parentName:"li"},"GET\uff0cHEAD")," \u8bf7\u6c42\u7684\u5f15\u7528\u7c7b\u578b\u53c2\u6570\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e"))),Object(r.b)("h2",{id:"58-\u66f4\u591a\u4f8b\u5b50"},"5.8 \u66f4\u591a\u4f8b\u5b50"),Object(r.b)("h3",{id:"581-\u591a\u79cd\u8bf7\u6c42\u8c13\u8bcd\u65b9\u6cd5"},"5.8.1 \u591a\u79cd\u8bf7\u6c42\u8c13\u8bcd\u65b9\u6cd5"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,12,17,22,27}","{7,12,17,22,27}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return $"GET \u8bf7\u6c42";\n }\n\n public string Post()\n {\n return $"POST \u8bf7\u6c42";\n }\n\n public string Delete()\n {\n return $"DELETE \u8bf7\u6c42";\n }\n\n public string Put()\n {\n return $"PUT \u8bf7\u6c42";\n }\n\n public string Patch()\n {\n return $"PATCH \u8bf7\u6c42";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dgqqwc.png")}),Object(r.b)("h3",{id:"582-\u591a\u4e2a\u81ea\u5b9a\u4e49\u52a8\u4f5c\u65b9\u6cd5"},"5.8.2 \u591a\u4e2a\u81ea\u5b9a\u4e49\u52a8\u4f5c\u65b9\u6cd5"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,12,17}","{7,12,17}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string GetVersion()\n {\n return $"v1.0.0";\n }\n\n public string ChangeProfile()\n {\n return "\u4fee\u6539\u6210\u529f";\n }\n\n public string DeleteUser()\n {\n return "\u5220\u9664\u6210\u529f";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dzmc.png")}),Object(r.b)("h3",{id:"583-\u5e26\u53c2\u6570\u52a8\u4f5c\u65b9\u6cd5"},"5.8.3 \u5e26\u53c2\u6570\u52a8\u4f5c\u65b9\u6cd5"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,12,17}","{7,12,17}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string GetUser(int id)\n {\n return $"{id}";\n }\n\n public string GetUser(int id, string name)\n {\n return $"{id} {name}";\n }\n\n public TestDto Add(TestDto testDto)\n {\n return testDto;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dcsff.gif")}),Object(r.b)("h3",{id:"585-gethead-\u7c7b\u7c7b\u578b\u53c2\u6570"},"5.8.5 ",Object(r.b)("inlineCode",{parentName:"h3"},"GET/HEAD")," \u7c7b\u7c7b\u578b\u53c2\u6570"),Object(r.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u4f1a\u5c06 ",Object(r.b)("inlineCode",{parentName:"p"},"GET/HEAD")," \u8bf7\u6c42\u4e2d\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"\u7c7b\u7c7b\u578b\u53c2\u6570")," \u8bbe\u7f6e\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"[FromBody]")," \u7ed1\u5b9a\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7}","{7}":!0}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public TestDto GetTest(TestDto testDto)\n {\n return testDto;\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/getyycs.png")}),Object(r.b)("p",null,"\u4f46\u662f\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"GET\u3001HEAD")," \u8bf7\u6c42\u4e0d\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"p"},"From Body")," \u7ed1\u5b9a\u3002\u6240\u4ee5\u6211\u4eec\u9700\u8981\u8f6c\u6362\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"Query")," \u67e5\u8be2\u53c2\u6570\u3002"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u652f\u6301\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u914d\u7f6e\uff1a"),Object(r.b)(c.a,{defaultValue:"fromquery",values:[{label:"[FromQuery] \u7279\u6027",value:"fromquery"},{label:"\u914d\u7f6e DynamicApiControllerSettings",value:"DynamicApiControllerSettings"}],mdxType:"Tabs"},Object(r.b)(l.a,{value:"fromquery",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,8}","{2,8}":!0}),"using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public TestDto GetTest([FromQuery] TestDto testDto)\n {\n return testDto;\n }\n }\n}\n"))),Object(r.b)(l.a,{value:"DynamicApiControllerSettings",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:'{2-4} title="Fur.Web.Entry/appsettings.json"',"{2-4}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "DynamicApiControllerSettings": {\n "ModelToQuery": true\n }\n }\n}\n')))),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/modeltoquery.png")}),Object(r.b)("h3",{id:"586-\u81ea\u5b9a\u4e49\u53c2\u6570\u4f4d\u7f6e"},"5.8.6 \u81ea\u5b9a\u4e49\u53c2\u6570\u4f4d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u65b9\u4fbf\u7684\u81ea\u5b9a\u4e49\u53c2\u6570\u4f4d\u7f6e\u7684\u7279\u6027 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiSeat]"),"\uff0c\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiSeat]")," \u53ef\u914d\u7f6e\u53c2\u6570\u4f4d\u7f6e\uff0c\u652f\u6301\u4ee5\u4e0b\u56db\u79cd\u4f4d\u7f6e\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ApiSeats.ControllerStart"),"\uff1a\u63a7\u5236\u5668\u4e4b\u524d"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ApiSeats.ControllerEnd"),"\uff1a\u63a7\u5236\u5668\u4e4b\u540e"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ApiSeats.ActionStart"),"\uff1a\u52a8\u4f5c\u65b9\u6cd5\u4e4b\u524d"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ApiSeats.ActionEnd"),"\uff1a\u52a8\u4f5c\u65b9\u6cd5\u4e4b\u540e\u3002",Object(r.b)("strong",{parentName:"li"},"\u9ed8\u8ba4\u503c"))),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8-9,15-20}","{8-9,15-20}":!0}),'using Fur.DynamicApiController;\nusing System;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n // \u53c2\u6570\u9ed8\u8ba4\u4e3a ApiSeats.ActionEnd\n public string RouteSeat(int id, string name)\n {\n return "\u914d\u7f6e\u8def\u7531\u53c2\u6570\u4f4d\u7f6e";\n }\n\n public string RouteSeat(\n [ApiSeat(ApiSeats.ControllerStart)] int id, // \u63a7\u5236\u5668\u540d\u79f0\u4e4b\u524d\n [ApiSeat(ApiSeats.ControllerEnd)] string name, // \u63a7\u5236\u5668\u540d\u79f0\u4e4b\u540e\n [ApiSeat(ApiSeats.ControllerEnd)] int age, // \u63a7\u5236\u5668\u540d\u79f0\u4e4b\u540e\n [ApiSeat(ApiSeats.ActionStart)] decimal weight, // \u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u4e4b\u524d\n [ApiSeat(ApiSeats.ActionStart)] float height, // \u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u4e4b\u524d\n [ApiSeat(ApiSeats.ActionEnd)] DateTime birthday) // \u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u4e4b\u540e\uff08\u9ed8\u8ba4\u503c\uff09\n {\n return "\u914d\u7f6e\u8def\u7531\u53c2\u6570\u4f4d\u7f6e";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/cswz.png")}),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u6e29\u99a8\u63d0\u793a")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u591a\u4e2a ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"\u540c\u4f4d\u7f6e"))," \u914d\u7f6e\u7684\u53c2\u6570\u5c06\u6309\u7167 ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"\u5b9a\u4e49\u53c2\u6570\u987a\u5e8f"))," \u8fdb\u884c\u6392\u5e8f\u3002"))),Object(r.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"[ApiSeat]")," \u53ea\u80fd\u5e94\u7528\u4e8e\u8d34\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"[FromRoute]")," \u7279\u6027\u7684\u53c2\u6570\u6216 ",Object(r.b)("inlineCode",{parentName:"p"},"\u57fa\u5143\u7c7b\u578b\u3001\u503c\u7c7b\u578b\u3001\u53ef\u7a7a\u57fa\u5143\u7c7b\u578b\u548c\u53ef\u7a7a\u503c\u7c7b\u578b"),"\u3002"))),Object(r.b)("h3",{id:"587-\u81ea\u5b9a\u4e49\u8bf7\u6c42\u8c13\u8bcd"},"5.8.7 \u81ea\u5b9a\u4e49\u8bf7\u6c42\u8c13\u8bcd"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,8}","{2,8}":!0}),'using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [HttpPost]\n public string GetVersion()\n {\n return "1.0.0";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/zdywc.png")}),Object(r.b)("h3",{id:"588-\u652f\u6301\u591a\u4e2a\u8c13\u8bcd"},"5.8.8 \u652f\u6301\u591a\u4e2a\u8c13\u8bcd"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,8}","{2,8}":!0}),'using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [HttpPost, HttpGet, AcceptVerbs("PUT", "DELETE")]\n public string GetVersion()\n {\n return "1.0.0";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dgwc.png")}),Object(r.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5982\u679c\u52a8\u4f5c\u65b9\u6cd5\u4e2d\u542b\u6709 ",Object(r.b)("inlineCode",{parentName:"p"},"\u7c7b\u7c7b\u578b\u53c2\u6570"),"\uff0c\u4e14\u542b\u6709 ",Object(r.b)("inlineCode",{parentName:"p"},"POST/PUT/DELETE")," \u4efb\u610f\u8bf7\u6c42\u8c13\u8bcd\uff0c\u90a3\u4e48\u8be5\u53c2\u6570\u4f1a\u81ea\u52a8\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"p"},"[FromBody]")," \u53c2\u6570\uff0c\u5373\u4f7f\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"GET/HEAD")," \u8bf7\u6c42\u4e2d\u4e0d\u652f\u6301\u3002"))),Object(r.b)("h3",{id:"589-\u652f\u6301\u81ea\u5b9a\u4e49\u8def\u7531"},"5.8.9 \u652f\u6301\u81ea\u5b9a\u4e49\u8def\u7531"),Object(r.b)("p",null,"\u652f\u6301\u63a7\u5236\u5668\u548c\u52a8\u4f5c\u65b9\u6cd5\u81ea\u5b9a\u4e49\u8def\u7531\uff1a"),Object(r.b)(c.a,{defaultValue:"kzqrl",values:[{label:"\u81ea\u5b9a\u4e49\u63a7\u5236\u5668\u8def\u7531",value:"kzqrl"},{label:"\u81ea\u5b9a\u4e49\u52a8\u4f5c\u65b9\u6cd5\u8def\u7531",value:"dzffrl"},{label:"\u540c\u65f6\u81ea\u5b9a\u4e49\u8def\u7531",value:"allrl"},{label:"\u8c13\u8bcd\u81ea\u5b9a\u4e49\u8def\u7531",value:"vcrl"}],mdxType:"Tabs"},Object(r.b)(l.a,{value:"kzqrl",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,6}","{2,6}":!0}),'using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n [Route("customapi/mobile/[controller]")]\n public class FurAppService : IDynamicApiController\n {\n public string GetVersion()\n {\n return "1.0.0";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/kzqrl.png")})),Object(r.b)(l.a,{value:"dzffrl",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,8}","{2,8}":!0}),'using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [Route("customapi/[action]")]\n public string GetVersion()\n {\n return "1.0.0";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dzffrl.png")})),Object(r.b)(l.a,{value:"allrl",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,6,9}","{2,6,9}":!0}),'using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n [Route("customapi/mobile/[controller]")]\n public class FurAppService : IDynamicApiController\n {\n [Route("get/[action]")]\n public string GetVersion()\n {\n return "1.0.0";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/allrl.png")})),Object(r.b)(l.a,{value:"vcrl",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{9}","{9}":!0}),'using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n [Route("api/[controller]")]\n public class FurAppService : IDynamicApiController\n {\n [HttpGet("get/[action]")]\n public string GetVersion()\n {\n return "1.0.0";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/wcrl.png")}))),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u5c0f\u63d0\u793a")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u52a8\u6001\u65b9\u6cd5\u81ea\u5b9a\u4e49\u8def\u7531\u5982\u679c\u4ee5 ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"/"))," \u5f00\u5934\uff0c\u5219\u4e0d\u4f1a\u5408\u5e76\u63a7\u5236\u5668\u8def\u7531\u3002"))),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u63a8\u8350\u914d\u7f6e")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u81ea\u5b9a\u4e49\u8def\u7531\u5982\u679c\u9700\u8981\u7528\u5230 ",Object(r.b)("strong",{parentName:"p"},"\u63a7\u5236\u5668/\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0"),"\uff0c\u63a8\u8350\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"[controller]")," \u6216 ",Object(r.b)("inlineCode",{parentName:"p"},"[action]")," \u5360\u4f4d\u7b26\uff0c\u56e0\u4e3a\u8be5\u5360\u4f4d\u7b26\u5df2\u7ecf\u81ea\u52a8\u5904\u7406\u4e86 ",Object(r.b)("strong",{parentName:"p"},"\u524d\u540e\u7f00\u3001\u7248\u672c\u53f7\u3001\u6a21\u5757\u540d\u79f0"),"\u7b49\u3002"))),Object(r.b)("h3",{id:"5810-\u591a\u8def\u7531\u968f\u610f\u7ec4\u5408"},"5.8.10 \u591a\u8def\u7531\u968f\u610f\u7ec4\u5408"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u7684\u5404\u79cd\u8def\u7531\u7ec4\u5408\u65b9\u5f0f\uff0c\u652f\u6301\u4e00\u5bf9\u591a\uff0c\u591a\u5bf9\u591a\u8def\u7531\u7ec4\u5408\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{6-8,11-14}","{6-8,11-14}":!0}),'using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n [Route("api/[controller]")]\n [Route("api/[controller]/second")]\n [Route("api/[controller]/three")]\n public class FurAppService : IDynamicApiController\n {\n [HttpGet]\n [HttpGet("get/[action]")]\n [HttpPost]\n [HttpPost("post/cus-version")]\n public string GetVersion()\n {\n return "1.0.0";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dlrzh.gif")}),Object(r.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u52a8\u4f5c\u65b9\u6cd5\u4e0d\u80fd\u540c\u65f6\u8d34 ",Object(r.b)("inlineCode",{parentName:"p"},"[Route]")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"[HttpMethod]")," \u7279\u6027\uff0c\u53ea\u80fd\u4e8c\u53d6\u4e00\u3002"))),Object(r.b)("h3",{id:"5811-\u652f\u6301\u7248\u672c\u63a7\u5236"},"5.8.11 \u652f\u6301\u7248\u672c\u63a7\u5236"),Object(r.b)(c.a,{defaultValue:"kzqbb",values:[{label:"\u63a7\u5236\u5668\u7248\u672c",value:"kzqbb"},{label:"\u52a8\u4f5c\u65b9\u6cd5\u7248\u672c",value:"dzffbb"}],mdxType:"Tabs"},Object(r.b)(l.a,{value:"kzqbb",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,13,21}","{5,13,21}":!0}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppServiceV1 : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n }\n\n public class FurAppServiceV1_2 : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n }\n\n public class FurAppServiceV1_2_1 : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/kzqbb.png")})),Object(r.b)(l.a,{value:"dzffbb",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,12,16}","{7,12,16}":!0}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public string GetV1()\n {\n return nameof(Fur);\n }\n public string GetV2_1()\n {\n return nameof(Fur);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dzffbb.png")}))),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7248\u672c\u751f\u6210\u539f\u7406")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"V[0-9_]"))," \u7ed3\u5c3e\u7684\u547d\u540d\u81ea\u52a8\u89e3\u6790\u6210\u7248\u672c\u53f7\uff0c\u5982 ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"FurAppServiceV2 -> Fur@2")),"\u3002"))),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u7248\u672c\u590d\u5199")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u9664\u4e86\u901a\u8fc7\u7279\u5b9a\u540e\u7f00\u65b9\u5f0f\u4ee5\u5916\uff0c\u7248\u672c\u8fd8\u76f4\u63a5\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiDescriptionSettings]")," \u8fdb\u884c\u590d\u5199\u3002\u5982\uff1a"),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,2}","{1,2}":!0}),'[ApiDescriptionSettings(Version = "4.0")]\npublic string GetV1()\n{\n return nameof(Fur);\n}\n')),Object(r.b)("p",{parentName:"div"},"\u8fd9\u65f6\uff0c\u751f\u6210\u7248\u672c\u5c06\u91c7\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"4.0")," \u66ff\u4ee3 ",Object(r.b)("inlineCode",{parentName:"p"},"1")))),Object(r.b)("h3",{id:"5812-\u4e0d\u516c\u5f00\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5"},"5.8.12 \u4e0d\u516c\u5f00\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5"),Object(r.b)("p",null,"\u6709\u4e9b\u65f6\u5019\uff0c\u6211\u4eec\u65e0\u9700\u5bfc\u51fa\u67d0\u4e2a\u52a8\u4f5c\u65b9\u6cd5\u6216\u63a7\u5236\u5668\uff0c\u53ea\u9700\u8981\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiDescriptionSettings(false)]")," \u6216 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiExplorerSettings(IgnoreApi = true)]"),"\u5373\u53ef\u3002"),Object(r.b)("p",null,"\u53e6\u5916\u52a8\u4f5c\u65b9\u6cd5\u8fd8\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"p"},"[NonAction]")," \u6807\u8bb0\u3002"),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u63a8\u8350\u4f7f\u7528")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u63a8\u8350\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5\u8bbe\u7f6e\u4e0d\u5bfc\u51fa\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiDescriptionSettings(false)]")," \u7279\u6027\u3002\u8be5\u7279\u6027\u9ed8\u8ba4\u7ee7\u627f\u81ea ",Object(r.b)("inlineCode",{parentName:"p"},"ApiExplorerSettingsAttribute")," \u7c7b\u3002"))),Object(r.b)("h2",{id:"59-apidescriptionsettings"},"5.9 ",Object(r.b)("inlineCode",{parentName:"h2"},"[ApiDescriptionSettings]")),Object(r.b)("p",null,"\u9664\u4e86\u4e0a\u8ff0 ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u63d0\u4f9b\u7684\u914d\u7f6e\u5916\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u8fd8\u63d0\u4f9b\u4e86\u975e\u5e38\u5f3a\u5927\u4e14\u7075\u6d3b\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiDescriptionSettings]")," \u7279\u6027\u3002"),Object(r.b)("h3",{id:"591-\u5185\u7f6e\u914d\u7f6e"},"5.9.1 \u5185\u7f6e\u914d\u7f6e"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Name"),"\uff1a\u81ea\u5b9a\u4e49\u63a7\u5236\u5668/\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"null")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"KeepName"),"\uff1a\u662f\u5426\u4fdd\u6301\u539f\u6709\u540d\u79f0\u4e0d\u5904\u7406\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"false")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"SplitCamelCase"),"\uff1a\u5207\u5272\u9a86\u9a7c\u547d\u540d\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"true")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"KeepVerb"),"\uff1a\u662f\u5426\u4fdd\u7559\u52a8\u4f5c\u65b9\u6cd5\u8bf7\u6c42\u8c13\u8bcd\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"false")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Enabled"),"\uff1a\u662f\u5426\u5bfc\u51fa\u63a5\u53e3\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"true")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Module"),"\uff1a\u6a21\u5757\u540d\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"null")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Version"),"\uff1a\u7248\u672c\u53f7\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"null")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Groups"),"\uff1a\u63a5\u53e3\u5206\u7ec4\uff0c\u53ef\u7ed3\u5408 ",Object(r.b)("inlineCode",{parentName:"li"},"Swagger")," \u4e00\u8d77\u4f7f\u7528\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string[]"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"null")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Tags"),"\uff1a\u63a5\u53e3\u6807\u7b7e\uff0c\u53ef\u7ed3\u5408 ",Object(r.b)("inlineCode",{parentName:"li"},"Swagger")," \u4e00\u8d77\u4f7f\u7528\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string[]"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"null")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"AuthPolicies"),"\uff1a\u6388\u6743\u7b56\u7565\uff0c\u53ef\u7ed3\u5408 ",Object(r.b)("inlineCode",{parentName:"li"},"\u6388\u6743\uff0cJWT")," \u4e00\u8d77\u4f7f\u7528\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string[]"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"null"))),Object(r.b)("h3",{id:"592-name-\u914d\u7f6e"},"5.9.2 ",Object(r.b)("inlineCode",{parentName:"h3"},"Name")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Name")," \u53c2\u6570\u53ef\u4ee5\u8986\u76d6\u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u81ea\u52a8\u751f\u6210\u7684\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u3002\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,8}","{5,8}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(Name = "MyFur")]\n public class FurAppService : IDynamicApiController\n {\n [ApiDescriptionSettings(Name = "MyGet")]\n public string Get()\n {\n return nameof(Fur);\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/namepz.png")}),Object(r.b)("h3",{id:"593-keepname-\u914d\u7f6e"},"5.9.3 ",Object(r.b)("inlineCode",{parentName:"h3"},"KeepName")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"KeepName")," \u53c2\u6570\u53ef\u4ee5\u4fdd\u7559\u539f\u6709\u7684\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u3002\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,8}","{5,8}":!0}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(KeepName = true)]\n public class FurAppService : IDynamicApiController\n {\n [ApiDescriptionSettings(KeepName = true)]\n public string Get()\n {\n return nameof(Fur);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/keepnamepz.png")}),Object(r.b)("h3",{id:"594-splitcamelcase-\u914d\u7f6e"},"5.9.4 ",Object(r.b)("inlineCode",{parentName:"h3"},"SplitCamelCase")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"SplitCamelCase")," \u53c2\u6570\u9ed8\u8ba4\u5c06\u9a86\u9a7c\u547d\u540d\u5207\u5272\u6210\u591a\u4e2a\u5355\u8bcd\u5e76\u901a\u8fc7\u6307\u5b9a ",Object(r.b)("inlineCode",{parentName:"p"},"\u5360\u4f4d\u7b26")," \u8fde\u63a5\u8d77\u6765\u3002\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"p"},"\u5360\u4f4d\u7b26")," \u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"-"),"\u3002\u9ed8\u8ba4\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"true"),"\u3002\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,8}","{5,8}":!0}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(SplitCamelCase = false)]\n public class MyFurAppService : IDynamicApiController\n {\n [ApiDescriptionSettings(SplitCamelCase = true)]\n public string ChangeUserName()\n {\n return nameof(Fur);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/splitnamepz.png")}),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"KeepName")," \u4f18\u5148\u7ea7\u9ad8\u4e8e ",Object(r.b)("inlineCode",{parentName:"p"},"SplitCamelCase"),"\uff0c\u4e5f\u5c31\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"KeepName")," \u8bbe\u7f6e\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"true"),"\uff0c\u5219\u4e0d\u4f1a\u5904\u7406 ",Object(r.b)("inlineCode",{parentName:"p"},"SplitCamelCase")," \u53c2\u6570\u3002"))),Object(r.b)("h3",{id:"595-keepverb-\u914d\u7f6e"},"5.9.5 ",Object(r.b)("inlineCode",{parentName:"h3"},"KeepVerb")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"KeepVerb")," \u53c2\u6570\u4f5c\u7528\u4e8e\u52a8\u4f5c\u65b9\u6cd5\uff0c\u6807\u8bc6\u662f\u5426\u4fdd\u7559\u52a8\u4f5c\u8c13\u8bcd\u3002\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7}","{7}":!0}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [ApiDescriptionSettings(KeepVerb = true)]\n public string GetVersion()\n {\n return nameof(Fur);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/keepverbpz.png")}),Object(r.b)("h3",{id:"596-enabled-\u914d\u7f6e"},"5.9.6 ",Object(r.b)("inlineCode",{parentName:"h3"},"Enabled")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Enabled")," \u53c2\u6570\u914d\u7f6e\u63a5\u53e3\u662f\u5426\u5bfc\u51fa\u3002\u901a\u5e38\u7528\u4e8e\u52a8\u4f5c\u65b9\u6cd5\uff0c\u5982\u679c\u7528\u4e8e\u63a7\u5236\u5668\u5b9e\u9645\u4f5c\u7528\u4e0d\u5927\u3002"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{12}","{12}":!0}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string GetVersion()\n {\n return nameof(Fur);\n }\n\n [ApiDescriptionSettings(false)]\n public string NoExport()\n {\n return nameof(Fur);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/enablepz.png")}),Object(r.b)("h3",{id:"597-module-\u914d\u7f6e"},"5.9.7 ",Object(r.b)("inlineCode",{parentName:"h3"},"Module")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Module")," \u53c2\u6570\u53ef\u4ee5\u914d\u7f6e\u8def\u7531\u5206\u79bb\uff0c\u7c7b\u4f3c\u4e8e ",Object(r.b)("inlineCode",{parentName:"p"},"Mvc \u533a\u57df")," \u7684\u4f5c\u7528\u3002"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,8}","{5,8}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(Module = "mobile")]\n public class FurAppService : IDynamicApiController\n {\n [ApiDescriptionSettings(Module = "user")]\n public string GetVersion()\n {\n return nameof(Fur);\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/modulepz.png")}),Object(r.b)("h3",{id:"598-version-\u914d\u7f6e"},"5.9.8 ",Object(r.b)("inlineCode",{parentName:"h3"},"Version")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Version")," \u53c2\u6570\u53ef\u4ee5\u914d\u7f6e\u63a5\u53e3\u7248\u672c\uff0c\u540c\u65f6\u53c8\u53ef\u4ee5\u590d\u5199\u7279\u6b8a\u7248\u672c\u547d\u540d\u914d\u7f6e\u3002\u9ed8\u8ba4\u7248\u672c\u53f7\u5206\u9694\u7b26\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"@"),"\u3002\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,9-10}","{5,9-10}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(Version = "1.0")]\n public class FurAppService : IDynamicApiController\n {\n // V2.0.0 \u88ab\u590d\u5199\u6210 V2.1.1\n [ApiDescriptionSettings(Version = "2.1.1")]\n public string GetVersionV2_0_0()\n {\n return nameof(Fur);\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/versionpz.png")}),Object(r.b)("h3",{id:"599-groups-\u914d\u7f6e"},"5.9.9 ",Object(r.b)("inlineCode",{parentName:"h3"},"Groups")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Groups")," \u914d\u7f6e\u4e3b\u8981\u7528\u4e8e\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u5206\u7ec4\u4fe1\u606f\u3002"),Object(r.b)("p",null,"\u901a\u8fc7\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"Groups")," \u53c2\u6570\u53ef\u4ee5\u5c06",Object(r.b)("inlineCode",{parentName:"p"},"\u63a7\u5236\u5668\u548c\u52a8\u4f5c\u65b9\u6cd5")," \u8fdb\u884c\u5f52\u7c7b\u548c\u591a\u4e2a\u5206\u7ec4\u76f4\u63a5\u5171\u4eab\u3002\u53ef\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiDescriptionSettings(params Groups)]")," \u6784\u9020\u51fd\u6570\u4f20\u5165\u6216\u6307\u5b9a ",Object(r.b)("inlineCode",{parentName:"p"},"Groups")," \u53c2\u6570\u914d\u7f6e\u63a5\u53e3\u662f\u5426\u5bfc\u51fa\u3002\u901a\u5e38\u7528\u4e8e\u52a8\u4f5c\u65b9\u6cd5\uff0c\u5982\u679c\u7528\u4e8e\u63a7\u5236\u5668\u5b9e\u9645\u4f5c\u7528\u4e0d\u5927\u3002"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,13}","{5,13}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings("Default", "Common")]\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n [ApiDescriptionSettings("Custom")]\n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dfz.gif")}),Object(r.b)("h3",{id:"5910-tag-\u914d\u7f6e"},"5.9.10 ",Object(r.b)("inlineCode",{parentName:"h3"},"Tag")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Tag")," \u914d\u7f6e\u4e3b\u8981\u7528\u4e8e\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u6807\u7b7e\u5206\u7ec4\u4fe1\u606f\u53ca\u5408\u5e76\u6807\u7b7e\u3002\u4e5f\u5c31\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"\u7ec4\u4e2d\u7ec4"),":"),Object(r.b)(c.a,{defaultValue:"tag1",values:[{label:"\u6807\u7b7e\u547d\u540d",value:"tag1"},{label:"\u5408\u5e76\u6807\u7b7e",value:"tag2"}],mdxType:"Tabs"},Object(r.b)(l.a,{value:"tag1",mdxType:"TabItem"},Object(r.b)("h4",{id:"\u672a\u8d34\u6807\u7b7e\u4e4b\u524d"},"\u672a\u8d34\u6807\u7b7e\u4e4b\u524d"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n\n public class TestAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n}\n")),Object(r.b)("h4",{id:"\u8d34\u6807\u7b7e\u4e4b\u540e"},"\u8d34\u6807\u7b7e\u4e4b\u540e"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,19}","{5,19}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(Tag = "\u5206\u7ec4\u4e00")]\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n\n [ApiDescriptionSettings(Tag = "\u5206\u7ec4\u4e8c")]\n public class TestAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/tag1.png")})),Object(r.b)(l.a,{value:"tag2",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,19}","{5,19}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(Tag = "\u5408\u5e76\u6240\u6709\u6807\u7b7e")]\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n\n [ApiDescriptionSettings(Tag = "\u5408\u5e76\u6240\u6709\u6807\u7b7e")]\n public class TestAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/tag2.png")}))),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5982\u679c ",Object(r.b)("inlineCode",{parentName:"p"},"Tag")," \u540d\u5b57\u4e00\u6837\uff0c\u5219\u4f1a\u81ea\u52a8\u5408\u5e76\uff0c\u5426\u5219\u53ea\u662f\u547d\u540d\u3002"))),Object(r.b)("h2",{id:"510-dynamicapicontrollersettings-\u914d\u7f6e"},"5.10 ",Object(r.b)("inlineCode",{parentName:"h2"},"DynamicApiControllerSettings")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u8fd8\u63d0\u4f9b\u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a5\u53e3\u4e00\u4e9b\u5168\u5c40\u914d\u7f6e\u9009\u9879\uff0c\u5982\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DefaultRoutePrefix"),"\uff1a\u9ed8\u8ba4\u8def\u7531\u524d\u7f00\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"api")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DefaultHttpMethod"),"\uff1a\u9ed8\u8ba4\u8bf7\u6c42\u8c13\u8bcd\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"POST")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DefaultModule"),"\uff1a\u9ed8\u8ba4\u6a21\u5757\u540d\u79f0\uff08\u533a\u57df\uff09\uff0c\u53ef\u7528\u4f5c\u63a5\u53e3\u7248\u672c\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"v1")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"LowercaseRoute"),"\uff1a\u5c0f\u5199\u8def\u7531\u683c\u5f0f\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"true")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"KeepVerb"),"\uff1a\u662f\u5426\u4fdd\u7559\u52a8\u4f5c\u8c13\u8bcd\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"false")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"CamelCaseSeparator"),"\uff1a\u9a86\u9a7c\u547d\u540d\u5206\u9694\u7b26\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"-")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"VersionSeparator"),"\uff1a\u7248\u672c\u5206\u9694\u7b26\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"@")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ModelToQuery"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"GET/HEAD")," \u8bf7\u6c42\u5c06 ",Object(r.b)("inlineCode",{parentName:"li"},"\u7c7b\u7c7b\u578b\u53c2\u6570\u8f6c\u67e5\u8be2\u53c2\u6570"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"false")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"SupportedMvcController"),"\uff1a\u662f\u5426\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"li"},"Mvc Controller")," \u52a8\u6001\u914d\u7f6e\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"false")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"AbandonControllerAffixes"),"\uff1a\u9ed8\u8ba4\u53bb\u9664\u63a7\u5236\u5668\u540d\u79f0\u524d\u540e\u7f00\u5217\u8868\u540d\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string[]"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"AppServices")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"AppService")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ApiController")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Controller")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Services")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Service")))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"AbandonActionAffixes"),"\uff1a\u9ed8\u8ba4\u53bb\u9664\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u524d\u540e\u7f00\u5217\u8868\u540d\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string[]"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Async"))))),Object(r.b)("h3",{id:"5101-\u652f\u6301-mvc-\u63a7\u5236\u5668-\u52a8\u6001\u914d\u7f6e"},"5.10.1 \u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"h3"},"Mvc \u63a7\u5236\u5668")," \u52a8\u6001\u914d\u7f6e"),Object(r.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a5\u53e3\u4e0d\u5bf9 ",Object(r.b)("inlineCode",{parentName:"p"},"ControllerBase")," \u7c7b\u578b\u8fdb\u884c\u4efb\u4f55\u5904\u7406\u3002\u5f53\u7136\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u624b\u52a8\u542f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"ControllerBase")," \u652f\u6301\u3002"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:'{2-4} title="Fur.Web.Entry/appsettings.json"',"{2-4}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "DynamicApiControllerSettings": {\n "SupportedMvcController": true\n }\n }\n}\n')),Object(r.b)("p",null,"\u8bbe\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"SupportedMvcController: true")," \u540e\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Mvc ControllerBase")," \u7c7b\u578b\u4e5f\u80fd\u548c\u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u4e00\u6837\u7684\u7075\u6d3b\u4e86\u3002\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5}","{5}":!0}),"using Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n public class MvcController : ControllerBase\n {\n public string Get()\n {\n return nameof(Fur);\n }\n }\n}\n\n")),Object(r.b)("div",{className:"admonition admonition-warning alert alert--danger"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"})))),"\u6ce8\u610f\u4e8b\u9879")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u542f\u7528\u8be5\u914d\u7f6e\u540e\uff0c\u5982\u679c ",Object(r.b)("inlineCode",{parentName:"p"},"Mvc \u63a7\u5236\u5668")," \u6ca1\u6709\u4efb\u4f55 ",Object(r.b)("inlineCode",{parentName:"p"},"[Route]")," \u7279\u6027\uff0c\u4f46\u662f\u8d34\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiController]")," \u7279\u6027\u5c06\u4f1a\u62a5\u9519\u3002\u539f\u56e0\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiController]")," \u7279\u6027\u5185\u90e8\u505a\u4e86\u8def\u7531\u7279\u6027\u68c0\u6d4b\u3002\u6240\u4ee5\u5efa\u8bae\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiDataValidation]")," \u4ee3\u66ff\u3002"),Object(r.b)("p",{parentName:"div"},"\u67e5\u770b ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/dotnet/aspnetcore/blob/c565386a3ed135560bc2e9017aa54a950b4e35dd/src/Mvc/Mvc.Core/src/ApplicationModels/ApiBehaviorApplicationModelProvider.cs#L90"}),"ASP.NET Core - ApiBehaviorApplicationModelProvider \u6e90\u7801")))),Object(r.b)("h2",{id:"511-\u53cd\u9988\u4e0e\u5efa\u8bae"},"5.11 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}u.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/0ddd808e.d77719f9.js b/handbook/build/0ddd808e.d77719f9.js new file mode 100644 index 00000000000..4cfb741c939 --- /dev/null +++ b/handbook/build/0ddd808e.d77719f9.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return m})),t.d(n,"b",(function(){return d}));var a=t(0),i=t.n(a);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function b(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function c(e){for(var n=1;n=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var p=i.a.createContext({}),o=function(e){var n=i.a.useContext(p),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},m=function(e){var n=o(e.components);return i.a.createElement(p.Provider,{value:n},e.children)},s={inlineCode:"code",wrapper:function(e){var n=e.children;return i.a.createElement(i.a.Fragment,{},n)}},u=i.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,r=e.originalType,b=e.parentName,p=l(e,["components","mdxType","originalType","parentName"]),m=o(t),u=a,d=m["".concat(b,".").concat(u)]||m[u]||s[u]||r;return t?i.a.createElement(d,c(c({ref:n},p),{},{components:t})):i.a.createElement(d,c({ref:n},p))}));function d(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var r=t.length,b=new Array(r);b[0]=u;var c={};for(var l in n)hasOwnProperty.call(n,l)&&(c[l]=n[l]);c.originalType=e,c.mdxType="string"==typeof e?e:a,b[1]=c;for(var p=2;pMvc \u63a7\u5236\u5668 \u7ea6\u5b9a\u548c\u7f3a\u70b9",id:"52-mvc-\u63a7\u5236\u5668-\u7ea6\u5b9a\u548c\u7f3a\u70b9",children:[{value:"5.2.1 WebAPI \u7ea6\u5b9a",id:"521-webapi-\u7ea6\u5b9a",children:[]},{value:"5.2.2 .NET Core WebAPI \u7f3a\u70b9",id:"522-net-core-webapi-\u7f3a\u70b9",children:[]}]},{value:"5.3 \u52a8\u6001 WebAPI \u63a7\u5236\u5668",id:"53-\u52a8\u6001-webapi-\u63a7\u5236\u5668",children:[]},{value:"5.4 \u6ce8\u518c\u52a8\u6001 WebAPI \u670d\u52a1",id:"54-\u6ce8\u518c\u52a8\u6001-webapi-\u670d\u52a1",children:[]},{value:"5.5 \u7b2c\u4e00\u4e2a\u4f8b\u5b50",id:"55-\u7b2c\u4e00\u4e2a\u4f8b\u5b50",children:[]},{value:"5.6 \u52a8\u6001 WebAPI \u539f\u7406\u89e3\u6790",id:"56-\u52a8\u6001-webapi-\u539f\u7406\u89e3\u6790",children:[{value:"5.6.1 \u63a7\u5236\u5668\u7279\u6027\u63d0\u4f9b\u5668",id:"561-\u63a7\u5236\u5668\u7279\u6027\u63d0\u4f9b\u5668",children:[]},{value:"5.6.2 \u5e94\u7528\u6a21\u578b\u8f6c\u6362\u5668",id:"562-\u5e94\u7528\u6a21\u578b\u8f6c\u6362\u5668",children:[]}]},{value:"5.7 \u52a8\u6001 WebAPI \u914d\u7f6e\u7ea6\u5b9a",id:"57-\u52a8\u6001-webapi-\u914d\u7f6e\u7ea6\u5b9a",children:[{value:"5.7.1 \u63a7\u5236\u5668\u9ed8\u8ba4\u7ea6\u5b9a",id:"571-\u63a7\u5236\u5668\u9ed8\u8ba4\u7ea6\u5b9a",children:[]},{value:"5.7.2 \u52a8\u4f5c\u65b9\u6cd5\u9ed8\u8ba4\u7ea6\u5b9a",id:"572-\u52a8\u4f5c\u65b9\u6cd5\u9ed8\u8ba4\u7ea6\u5b9a",children:[]},{value:"5.7.3 \u8bf7\u6c42\u8c13\u8bcd\u9ed8\u8ba4\u7ea6\u5b9a",id:"573-\u8bf7\u6c42\u8c13\u8bcd\u9ed8\u8ba4\u7ea6\u5b9a",children:[]},{value:"5.7.4 \u8def\u7531\u5730\u5740\u9ed8\u8ba4\u7ea6\u5b9a",id:"574-\u8def\u7531\u5730\u5740\u9ed8\u8ba4\u7ea6\u5b9a",children:[]},{value:"5.7.5 \u5176\u4ed6\u7ea6\u5b9a",id:"575-\u5176\u4ed6\u7ea6\u5b9a",children:[]}]},{value:"5.8 \u66f4\u591a\u4f8b\u5b50",id:"58-\u66f4\u591a\u4f8b\u5b50",children:[{value:"5.8.1 \u591a\u79cd\u8bf7\u6c42\u8c13\u8bcd\u65b9\u6cd5",id:"581-\u591a\u79cd\u8bf7\u6c42\u8c13\u8bcd\u65b9\u6cd5",children:[]},{value:"5.8.2 \u591a\u4e2a\u81ea\u5b9a\u4e49\u52a8\u4f5c\u65b9\u6cd5",id:"582-\u591a\u4e2a\u81ea\u5b9a\u4e49\u52a8\u4f5c\u65b9\u6cd5",children:[]},{value:"5.8.3 \u5e26\u53c2\u6570\u52a8\u4f5c\u65b9\u6cd5",id:"583-\u5e26\u53c2\u6570\u52a8\u4f5c\u65b9\u6cd5",children:[]},{value:"5.8.5 GET/HEAD \u7c7b\u7c7b\u578b\u53c2\u6570",id:"585-gethead-\u7c7b\u7c7b\u578b\u53c2\u6570",children:[]},{value:"5.8.6 \u81ea\u5b9a\u4e49\u53c2\u6570\u4f4d\u7f6e",id:"586-\u81ea\u5b9a\u4e49\u53c2\u6570\u4f4d\u7f6e",children:[]},{value:"5.8.7 \u81ea\u5b9a\u4e49\u8bf7\u6c42\u8c13\u8bcd",id:"587-\u81ea\u5b9a\u4e49\u8bf7\u6c42\u8c13\u8bcd",children:[]},{value:"5.8.8 \u652f\u6301\u591a\u4e2a\u8c13\u8bcd",id:"588-\u652f\u6301\u591a\u4e2a\u8c13\u8bcd",children:[]},{value:"5.8.9 \u652f\u6301\u81ea\u5b9a\u4e49\u8def\u7531",id:"589-\u652f\u6301\u81ea\u5b9a\u4e49\u8def\u7531",children:[]},{value:"5.8.10 \u591a\u8def\u7531\u968f\u610f\u7ec4\u5408",id:"5810-\u591a\u8def\u7531\u968f\u610f\u7ec4\u5408",children:[]},{value:"5.8.11 \u652f\u6301\u7248\u672c\u63a7\u5236",id:"5811-\u652f\u6301\u7248\u672c\u63a7\u5236",children:[]},{value:"5.8.12 \u4e0d\u516c\u5f00\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5",id:"5812-\u4e0d\u516c\u5f00\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5",children:[]}]},{value:"5.9 [ApiDescriptionSettings]",id:"59-apidescriptionsettings",children:[{value:"5.9.1 \u5185\u7f6e\u914d\u7f6e",id:"591-\u5185\u7f6e\u914d\u7f6e",children:[]},{value:"5.9.2 Name \u914d\u7f6e",id:"592-name-\u914d\u7f6e",children:[]},{value:"5.9.3 KeepName \u914d\u7f6e",id:"593-keepname-\u914d\u7f6e",children:[]},{value:"5.9.4 SplitCamelCase \u914d\u7f6e",id:"594-splitcamelcase-\u914d\u7f6e",children:[]},{value:"5.9.5 KeepVerb \u914d\u7f6e",id:"595-keepverb-\u914d\u7f6e",children:[]},{value:"5.9.6 Enabled \u914d\u7f6e",id:"596-enabled-\u914d\u7f6e",children:[]},{value:"5.9.7 Module \u914d\u7f6e",id:"597-module-\u914d\u7f6e",children:[]},{value:"5.9.8 Version \u914d\u7f6e",id:"598-version-\u914d\u7f6e",children:[]},{value:"5.9.9 Groups \u914d\u7f6e",id:"599-groups-\u914d\u7f6e",children:[]},{value:"5.9.10 Tag \u914d\u7f6e",id:"5910-tag-\u914d\u7f6e",children:[]}]},{value:"5.10 DynamicApiControllerSettings \u914d\u7f6e",id:"510-dynamicapicontrollersettings-\u914d\u7f6e",children:[{value:"5.10.1 \u652f\u6301 Mvc \u63a7\u5236\u5668 \u52a8\u6001\u914d\u7f6e",id:"5101-\u652f\u6301-mvc-\u63a7\u5236\u5668-\u52a8\u6001\u914d\u7f6e",children:[]}]},{value:"5.11 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"511-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],s={rightToc:m};function u(e){var n=e.components,t=Object(i.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},s,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"51-\u4ec0\u4e48\u662f\u63a7\u5236\u5668"},"5.1 \u4ec0\u4e48\u662f\u63a7\u5236\u5668"),Object(r.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u63a7\u5236\u5668\u662f\u4e00\u4e2a\u627f\u4e0a\u542f\u4e0b\u7684\u4f5c\u7528\uff0c\u6839\u636e\u7528\u6237\u8f93\u5165\uff0c\u6267\u884c\u54cd\u5e94\u884c\u4e3a\uff08\u52a8\u4f5c\u65b9\u6cd5\uff09\uff0c\u540c\u65f6\u5728\u884c\u4e3a\u4e2d\u8c03\u7528\u6a21\u578b\u7684\u4e1a\u52a1\u903b\u8f91\uff0c\u8fd4\u56de\u7ed9\u7528\u6237\u7ed3\u679c\uff08\u89c6\u56fe\uff09\u3002"),Object(r.b)("img",{src:Object(b.a)("img/kzq.png")}),Object(r.b)("p",null),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u4e2d\uff0c\u63a7\u5236\u5668\u6709\u4e24\u79cd\u8868\u73b0\u5f62\u5f0f\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Mvc"),"\uff08\u5e26\u89c6\u56fe\uff09"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"WebAPI"),"\uff08RESTful API\uff09")),Object(r.b)(c.a,{defaultValue:"mvc",values:[{label:"Mvc \u63a7\u5236\u5668",value:"mvc"},{label:"WebAPI \u63a7\u5236\u5668",value:"webapi"}],mdxType:"Tabs"},Object(r.b)(l.a,{value:"mvc",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,7}","{1,5,7}":!0}),"using Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n public class MvcController : Controller\n {\n public IActionResult Index()\n {\n return View();\n }\n }\n}\n"))),Object(r.b)(l.a,{value:"webapi",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,6,8,9}","{1,5,6,8,9}":!0}),'using Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n public class WebApiController : ControllerBase\n {\n [HttpGet]\n public IActionResult Get()\n {\n return Content(nameof(Fur));\n }\n }\n}\n')))),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Mvc")," \u63a7\u5236\u5668\u548c ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a7\u5236\u5668\u6700\u5927\u7684\u533a\u522b\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a7\u5236\u5668\u4e0d\u5e26 ",Object(r.b)("strong",{parentName:"p"},"\u89c6\u56fe")," \u548c\u901a\u8fc7 ",Object(r.b)("strong",{parentName:"p"},"\u8bf7\u6c42\u8c13\u8bcd\u548c\u8def\u7531\u5730\u5740\u54cd\u5e94\u884c\u4e3a"),"\u3002"),Object(r.b)("h2",{id:"52-mvc-\u63a7\u5236\u5668-\u7ea6\u5b9a\u548c\u7f3a\u70b9"},"5.2 ",Object(r.b)("inlineCode",{parentName:"h2"},"Mvc \u63a7\u5236\u5668")," \u7ea6\u5b9a\u548c\u7f3a\u70b9"),Object(r.b)("p",null,"\u5728\u5b66\u4e60\u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a7\u5236\u5668\u4e4b\u524d\uff0c\u9996\u5148\u4e86\u89e3 ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u4e2d ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u7684\u4e00\u4e9b\u7ea6\u5b9a\u548c\u6ce8\u610f\u4e8b\u9879\u3002"),Object(r.b)("h3",{id:"521-webapi-\u7ea6\u5b9a"},"5.2.1 ",Object(r.b)("inlineCode",{parentName:"h3"},"WebAPI")," \u7ea6\u5b9a"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u5e94\u7528\u4e2d\uff0c\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a7\u5236\u5668\u9700\u9075\u5faa\u4ee5\u4e0b\u7ea6\u5b9a\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u63a7\u5236\u5668\u7c7b",Object(r.b)("strong",{parentName:"li"},"\u5fc5\u987b\u7ee7\u627f ",Object(r.b)("inlineCode",{parentName:"strong"},"ControllerBase")," \u6216\u95f4\u63a5\u7ee7\u627f")),Object(r.b)("li",{parentName:"ul"},"\u52a8\u4f5c\u65b9\u6cd5",Object(r.b)("strong",{parentName:"li"},"\u5fc5\u987b\u8d34\u6709 ",Object(r.b)("inlineCode",{parentName:"strong"},"[HttpMethod]")," \u7279\u6027\uff0c\u5982\uff1a",Object(r.b)("inlineCode",{parentName:"strong"},"[HttpGet]"))),Object(r.b)("li",{parentName:"ul"},"\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5",Object(r.b)("strong",{parentName:"li"},"\u81f3\u5c11\u6709\u4e00\u4e2a\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"strong"},"[Route]")," \u7279\u6027")),Object(r.b)("li",{parentName:"ul"},"\u751f\u6210 ",Object(r.b)("inlineCode",{parentName:"li"},"WebAPI")," \u8def\u7531\u5730\u5740\u65f6\u4f1a\u81ea\u52a8\u53bb\u6389\u63a7\u5236\u5668\u540d\u79f0 ",Object(r.b)("inlineCode",{parentName:"li"},"Controller")," \u540e\u7f00\uff0c\u540c\u65f6\u4e5f\u4f1a\u53bb\u6389\u52a8\u4f5c\u65b9\u6cd5\u5339\u914d\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"HttpVerb")," \u8c13\u8bcd\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"li"},"GET\uff0cPOST\uff0cDELETE\uff0cPUT")," \u7b49"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("strong",{parentName:"li"},"\u4e0d\u652f\u6301\u8fd4\u56de\u975e ",Object(r.b)("inlineCode",{parentName:"strong"},"IEnumerable")," \u6cdb\u578b\u5bf9\u8c61")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("strong",{parentName:"li"},"\u4e0d\u652f\u6301\u7c7b\u7c7b\u578b\u53c2\u6570\u5728 ",Object(r.b)("inlineCode",{parentName:"strong"},"GET\uff0cHEAD")," \u8bf7\u6c42\u4e0b\u751f\u6210 ",Object(r.b)("inlineCode",{parentName:"strong"},"Query")," \u53c2\u6570"))),Object(r.b)("p",null,"\u9664\u4e86\u4e0a\u8ff0\u7ea6\u5b9a\u5916\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u8def\u7531\u5730\u5740",Object(r.b)("strong",{parentName:"p"},"\u57fa\u672c\u9760\u624b\u5de5\u5b8c\u6210"),"\uff0c\u4e0d\u5229\u4e8e\u4e66\u5199\uff0c\u4e0d\u5229\u4e8e\u7ef4\u62a4\uff0c\u518d\u8005\uff0c\u5728\u79fb\u52a8\u5e94\u7528\u5bf9\u63a5\u4e2d\u96be\u4ee5\u8fdb\u884c\u591a\u7248\u672c\u63a7\u5236\u3002"),Object(r.b)("h3",{id:"522-net-core-webapi-\u7f3a\u70b9"},"5.2.2 ",Object(r.b)("inlineCode",{parentName:"h3"},".NET Core WebAPI")," \u7f3a\u70b9"),Object(r.b)("p",null,"\u901a\u8fc7\u4e0a\u4e00\u7ae0\u8282\u53ef\u4ee5\u770b\u51fa\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u5e94\u7528\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u9700\u8981\u9075\u5faa\u79cd\u79cd\u7ea6\u5b9a\uff0c\u800c\u4e14\u5bb9\u6613\u51fa\u9519\u3002"),Object(r.b)("p",null,"\u9664\u4e86\u8fd9\u4e9b\u7ea6\u5b9a\uff0c",Object(r.b)("inlineCode",{parentName:"p"},".NET Core WebAPI")," \u6709\u4ee5\u4e0b\u7f3a\u70b9\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u8def\u7531\u5730\u5740\u57fa\u672c\u9760\u624b\u5de5\u5b8c\u6210"),Object(r.b)("li",{parentName:"ul"},"\u5728\u73b0\u5728\u79fb\u52a8\u4e3a\u738b\u7684\u65f6\u4ee3\uff0c\u4e0d\u5229\u4e8e\u8fdb\u884c\u591a\u7248\u672c\u63a7\u5236"),Object(r.b)("li",{parentName:"ul"},"\u5bf9\u63a5 ",Object(r.b)("inlineCode",{parentName:"li"},"Swagger")," \u6587\u6863\u5206\u7ec4\u6bd4\u8f83\u590d\u6742"),Object(r.b)("li",{parentName:"ul"},"\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"li"},"Policy")," \u7b56\u7565\u6388\u6743\u4e5f\u6bd4\u8f83\u590d\u6742"),Object(r.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\u63a7\u5236\u5668\u70ed\u62d4\u63d2\u63d2\u4ef6\u5316"),Object(r.b)("li",{parentName:"ul"},"\u96be\u4ee5\u5b9e\u73b0\u590d\u6742\u81ea\u5b9a\u4e49\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"RESTful API")," \u98ce\u683c")),Object(r.b)("h2",{id:"53-\u52a8\u6001-webapi-\u63a7\u5236\u5668"},"5.3 \u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"h2"},"WebAPI")," \u63a7\u5236\u5668"),Object(r.b)("p",null,"\u9488\u5bf9\u4ee5\u4e0a ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u63d0\u4f9b\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u5fc5\u987b\u9075\u5faa\u7684\u7ea6\u5b9a\u548c\u4e0d\u53ef\u907f\u514d\u7684\u7f3a\u70b9\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u521b\u9020\u51fa\u4e00\u79cd\u66f4\u52a0\u7075\u6d3b\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a7\u5236\u5668\u7684\u65b9\u5f0f\u3002"),Object(r.b)("p",null,"\u8fd9\u4e2a\u65b9\u5f0f\u5728\u7ee7\u627f\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core WebAPI")," \u6240\u6709\u4f18\u70b9\uff0c\u540c\u65f6\u8fdb\u884c\u4e86\u5927\u91cf\u62d3\u5c55\u548c\u4f18\u5316\u3002\u4f18\u5316\u540e\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u5177\u6709\u4ee5\u4e0b\u4f18\u70b9\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u5177\u5907\u539f\u6709\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"ControllerBase")," \u6240\u6709\u529f\u80fd"),Object(r.b)("li",{parentName:"ul"},"\u652f\u6301",Object(r.b)("strong",{parentName:"li"},"\u4efb\u610f\u516c\u5f00 \u975e\u9759\u6001 \u975e\u62bd\u8c61 \u975e\u6cdb\u578b\u7c7b"),"\u8f6c\u63a7\u5236\u5668"),Object(r.b)("li",{parentName:"ul"},"\u63d0\u4f9b\u66f4\u52a0\u7075\u6d3b\u65b9\u4fbf\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"IDynamicApiController")," \u7a7a\u63a5\u53e3\u6216 ",Object(r.b)("inlineCode",{parentName:"li"},"[DynamicApiController]")," \u7279\u6027\u66ff\u4ee3 ",Object(r.b)("inlineCode",{parentName:"li"},"ControllerBase")," \u62bd\u8c61\u7c7b"),Object(r.b)("li",{parentName:"ul"},"\u65e0\u9700\u624b\u52a8\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"li"},"[HttpMethod]")," \u7279\u6027\uff0c\u540c\u65f6\u652f\u6301\u4e00\u4e2a\u52a8\u4f5c\u65b9\u6cd5\u591a\u4e2a ",Object(r.b)("inlineCode",{parentName:"li"},"HttpVerb")),Object(r.b)("li",{parentName:"ul"},"\u65e0\u9700\u624b\u52a8\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"li"},"[Route]")," \u7279\u6027\uff0c\u652f\u6301\u66f4\u52a0\u7075\u6d3b\u7684\u914d\u7f6e\u53ca\u81ea\u52a8\u8def\u7531\u751f\u6210"),Object(r.b)("li",{parentName:"ul"},"\u652f\u6301\u8fd4\u56de\u6cdb\u578b\u63a5\u53e3\uff0c\u6cdb\u578b\u7c7b"),Object(r.b)("li",{parentName:"ul"},"\u548c ",Object(r.b)("inlineCode",{parentName:"li"},"Swagger")," \u6df1\u5ea6\u7ed3\u5408\uff0c\u63d0\u4f9b\u6781\u5176\u65b9\u4fbf\u7684\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"li"},"Swagger")," \u5206\u7ec4\u914d\u7f6e"),Object(r.b)("li",{parentName:"ul"},"\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"li"},"Basic Auth\uff0cJwt\uff0cApiKey")," \u7b49\u591a\u79cd\u6743\u9650\u7075\u6d3b\u914d\u7f6e"),Object(r.b)("li",{parentName:"ul"},"\u652f\u6301\u63a7\u5236\u5668\u3001\u52a8\u4f5c\u65b9\u6cd5",Object(r.b)("strong",{parentName:"li"},"\u7248\u672c\u63a7\u5236"),"\u529f\u80fd"),Object(r.b)("li",{parentName:"ul"},"\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"li"},"GET\u3001HEAD")," \u8bf7\u6c42\u81ea\u52a8\u8f6c\u6362 ",Object(r.b)("inlineCode",{parentName:"li"},"\u7c7b\u7c7b\u578b\u53c2\u6570")),Object(r.b)("li",{parentName:"ul"},"\u652f\u6301\u751f\u6210 ",Object(r.b)("inlineCode",{parentName:"li"},"OAS3")," \u63a5\u53e3\u89c4\u8303")),Object(r.b)("h2",{id:"54-\u6ce8\u518c\u52a8\u6001-webapi-\u670d\u52a1"},"5.4 \u6ce8\u518c\u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"h2"},"WebAPI")," \u670d\u52a1"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{11} title="Fur.Web.Core\\FurWebCoreStartup.cs"',"{11}":!0,title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddControllers()\n .AddDynamicApiControllers();\n }\n }\n}\n")),Object(r.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},".AddDynamicApiControllers()")," \u5fc5\u987b\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"services.AddControllers()")," \u4e4b\u540e\u6ce8\u518c\u3002"))),Object(r.b)("h2",{id:"55-\u7b2c\u4e00\u4e2a\u4f8b\u5b50"},"5.5 \u7b2c\u4e00\u4e2a\u4f8b\u5b50"),Object(r.b)("p",null,"\u521b\u5efa\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"FurAppService")," \u7c7b\u7ee7\u627f ",Object(r.b)("inlineCode",{parentName:"p"},"IDynamicApiController")," \u63a5\u53e3 \u6216 \u8d34 ",Object(r.b)("inlineCode",{parentName:"p"},"[DynamicApiController]")," \u7279\u6027\uff0c\u5e76\u5728\u8fd9\u4e2a\u7c7b\u4e2d\u7f16\u5199\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"Get")," \u65b9\u6cd5\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("strong",{parentName:"li"},Object(r.b)("inlineCode",{parentName:"strong"},"IDynamicApiController")," \u65b9\u5f0f"))),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,7}","{1,5,7}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return $"Hello {nameof(Fur)}";\n }\n }\n}\n')),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("strong",{parentName:"li"},Object(r.b)("inlineCode",{parentName:"strong"},"[DynamicApiController]")," \u65b9\u5f0f"))),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,8}","{1,5,8}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [DynamicApiController]\n public class FurAppService\n {\n public string Get()\n {\n return $"Hello {nameof(Fur)}";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a5\u53e3\u5c31\u8fd9\u4e48\u751f\u6210\u4e86\u3002"),Object(r.b)("img",{src:Object(b.a)("img/dyglz.gif")}),Object(r.b)("h2",{id:"56-\u52a8\u6001-webapi-\u539f\u7406\u89e3\u6790"},"5.6 \u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"h2"},"WebAPI")," \u539f\u7406\u89e3\u6790"),Object(r.b)("h3",{id:"561-\u63a7\u5236\u5668\u7279\u6027\u63d0\u4f9b\u5668"},"5.6.1 \u63a7\u5236\u5668\u7279\u6027\u63d0\u4f9b\u5668"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4f1a\u5728\u5e94\u7528\u542f\u52a8\u65f6\u6ce8\u518c ",Object(r.b)("inlineCode",{parentName:"p"},"DynamicApiControllerFeatureProvider")," \u63a7\u5236\u5668\u7279\u6027\u63d0\u4f9b\u5668\uff0c\u8be5\u63d0\u4f9b\u5668\u7ee7\u627f\u81ea ",Object(r.b)("inlineCode",{parentName:"p"},"ControllerFeatureProvider")," \u7c7b\u3002"),Object(r.b)("p",null,"\u63a5\u7740\u91cd\u5199 ",Object(r.b)("inlineCode",{parentName:"p"},"bool IsController(TypeInfo typeInfo)")," \u65b9\u6cd5\uff0c\u7528\u6765\u6807\u8bc6\u63a7\u5236\u5668\u7c7b\u578b\u3002\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c",Object(r.b)("strong",{parentName:"p"},"\u7ee7\u627f\u81ea ",Object(r.b)("inlineCode",{parentName:"strong"},"ControllerBase")," \u7c7b\u6216 ",Object(r.b)("inlineCode",{parentName:"strong"},"IDynamicApiController")," \u63a5\u53e3\u6216 ",Object(r.b)("inlineCode",{parentName:"strong"},"[DynamicApiController]")," \u7279\u6027\u90fd\u4f1a\u88ab\u6807\u8bb0\u4e3a\u63a7\u5236\u5668\u7c7b\u578b\u3002")),Object(r.b)("h3",{id:"562-\u5e94\u7528\u6a21\u578b\u8f6c\u6362\u5668"},"5.6.2 \u5e94\u7528\u6a21\u578b\u8f6c\u6362\u5668"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u540c\u65f6\u5728\u5e94\u7528\u542f\u52a8\u65f6\u6ce8\u518c ",Object(r.b)("inlineCode",{parentName:"p"},"DynamicApiControllerApplicationModelConvention")," \u5e94\u7528\u6a21\u578b\u8f6c\u6362\u5668\uff0c\u8be5\u8f6c\u6362\u5668\u7ee7\u627f\u81ea ",Object(r.b)("inlineCode",{parentName:"p"},"IApplicationModelConvention")," \u63a5\u53e3\u3002"),Object(r.b)("p",null,"\u63a5\u7740\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"p"},"void Apply(ApplicationModel application)")," \u63a5\u53e3\u65b9\u6cd5\u3002\u5728\u8be5\u65b9\u6cd5\u4e2d\u914d\u7f6e\u63a7\u5236\u5668\u540d\u79f0\u3001\u8def\u7531\u3001\u5bfc\u51fa\u53ef\u89c1\u6027\u53ca\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u3001\u8def\u7531\u3001\u5bfc\u51fa\u53ef\u89c1\u6027\u7b49\u3002"),Object(r.b)("p",null,"\u5b9e\u9645\u4e0a\u8be5\u65b9\u6cd5\u505a\u7684\u5c31\u662f\u6309\u7167 ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("a",Object(a.a)({parentName:"strong"},{href:"#521-webapi-%E7%BA%A6%E5%AE%9A"}),"WebAPI \u7ea6\u5b9a"))," \u63d0\u524d\u5e2e\u6211\u4eec\u914d\u7f6e\u597d\u8def\u7531\u3001\u8bf7\u6c42\u8c13\u8bcd\u7b49\u4fe1\u606f\u3002\u907f\u514d\u4e86\u624b\u52a8\u914d\u7f6e\u7684\u540c\u65f6\u8fd8\u589e\u52a0\u4e86\u8bb8\u591a\u65b0\u7279\u6027\uff0c\u5982",Object(r.b)("strong",{parentName:"p"},"\u7248\u672c\u63a7\u5236\u3002")),Object(r.b)("h2",{id:"57-\u52a8\u6001-webapi-\u914d\u7f6e\u7ea6\u5b9a"},"5.7 \u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"h2"},"WebAPI")," \u914d\u7f6e\u7ea6\u5b9a"),Object(r.b)("h3",{id:"571-\u63a7\u5236\u5668\u9ed8\u8ba4\u7ea6\u5b9a"},"5.7.1 \u63a7\u5236\u5668\u9ed8\u8ba4\u7ea6\u5b9a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u751f\u6210\u63a7\u5236\u5668\u540d\u79f0\u9ed8\u8ba4\u53bb\u9664\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"AppServices\uff0cAppService\uff0cApiController\uff0cController\uff0cServices\uff0cService")," \u4f5c\u4e3a\u524d\u540e\u7f00\u7684\u5b57\u7b26\u4e32\u3002\u89c1\u7b2c\u4e00\u4e2a\u4f8b\u5b50\u4e2d\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"FurAppService -> Fur")," ",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u63a7\u5236\u5668\u540d\u79f0\u5e26 ",Object(r.b)("inlineCode",{parentName:"li"},"V[0-9_]")," \u7ed3\u5c3e\u7684\uff0c\u4f1a\u81ea\u52a8\u751f\u6210\u63a7\u5236\u5668\u7248\u672c\u53f7\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"li"},"FurAppServiceV2 -> Fur@2"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"FurAppServiceV1_1_0 -> Fur@1.1.0"),"\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u7248\u672c\u5206\u9694\u7b26\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u63a7\u5236\u540d\u79f0\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"\u9a86\u9a7c\u547d\u540d\uff08CamelCase\uff09")," \u4f1a\u81ea\u52a8\u5207\u5272\u6210\u591a\u4e2a\u5355\u8bcd ",Object(r.b)("inlineCode",{parentName:"li"},"-")," \u8fde\u63a5\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e"))),Object(r.b)("h3",{id:"572-\u52a8\u4f5c\u65b9\u6cd5\u9ed8\u8ba4\u7ea6\u5b9a"},"5.7.2 \u52a8\u4f5c\u65b9\u6cd5\u9ed8\u8ba4\u7ea6\u5b9a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u751f\u6210\u7684\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u9ed8\u8ba4\u53bb\u9664\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"Post/Add/Create/Insert/Submit\uff0cGetAll/GetList/Get/Find/Fetch/Query/Search\uff0cPut/Update\uff0cDelete/Remove/Clear\uff0cPatch")," \u5f00\u5934\u7684\u5b57\u7b26\u4e32\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u751f\u6210\u7684\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u9ed8\u8ba4\u53bb\u9664\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"Async")," \u4f5c\u4e3a\u524d\u540e\u7f00\u7684\u5b57\u7b26\u4e32\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u5e26 ",Object(r.b)("inlineCode",{parentName:"li"},"V[0-9_]")," \u7ed3\u5c3e\u7684\uff0c\u4f1a\u81ea\u52a8\u751f\u6210\u52a8\u4f5c\u65b9\u6cd5\u7248\u672c\u53f7\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"li"},"ChangePasswordV2 -> ChangePassword@2"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"ChangePasswordV1_1_0 -> ChangePassword@1.1.0"),"\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u7248\u672c\u5206\u9694\u7b26\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"\u9a86\u9a7c\u547d\u540d\uff08CamelCase\uff09")," \u4f1a\u81ea\u52a8\u5207\u5272\u6210\u591a\u4e2a\u5355\u8bcd ",Object(r.b)("inlineCode",{parentName:"li"},"-")," \u8fde\u63a5\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u52a8\u4f5c\u65b9\u6cd5\u53c2\u6570\u5c06\u81ea\u52a8\u8f6c\u4e3a\u5c0f\u5199\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e"))),Object(r.b)("h3",{id:"573-\u8bf7\u6c42\u8c13\u8bcd\u9ed8\u8ba4\u7ea6\u5b9a"},"5.7.3 \u8bf7\u6c42\u8c13\u8bcd\u9ed8\u8ba4\u7ea6\u5b9a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u52a8\u4f5c\u65b9\u6cd5\u540d",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"Post/Add/Create/Insert/Submit")," \u5f00\u5934\uff0c\u5219\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"li"},"[HttpPost]")," \u7279\u6027\u3002"),Object(r.b)("li",{parentName:"ul"},"\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"GetAll/GetList/Get/Find/Fetch/Query")," \u5f00\u5934\uff0c\u5219\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"li"},"[HttpGet]")," \u7279\u6027\u3002"),Object(r.b)("li",{parentName:"ul"},"\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"Put/Update")," \u5f00\u5934\uff0c\u5219\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"li"},"[HttpPut]")," \u7279\u6027\u3002"),Object(r.b)("li",{parentName:"ul"},"\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"Delete/Remove/Clear")," \u5f00\u5934\uff0c\u5219\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"li"},"[HttpDelete]")," \u7279\u6027\u3002"),Object(r.b)("li",{parentName:"ul"},"\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"Patch")," \u5f00\u5934\uff0c\u5219\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"li"},"[HttpPatch]")," \u7279\u6027"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")))),Object(r.b)("li",{parentName:"ul"},"\u5982\u679c\u4e0d\u5728\u4e0a\u9762\u7ea6\u5b9a\u4e2d\uff0c\u5219\u9ed8\u8ba4\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"li"},"[HttpPost]")," \u7279\u6027\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e"))),Object(r.b)("h3",{id:"574-\u8def\u7531\u5730\u5740\u9ed8\u8ba4\u7ea6\u5b9a"},"5.7.4 \u8def\u7531\u5730\u5740\u9ed8\u8ba4\u7ea6\u5b9a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u9ed8\u8ba4\u4ee5 ",Object(r.b)("inlineCode",{parentName:"li"},"api")," \u5f00\u5934\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u9ed8\u8ba4\u8f6c\u6362\u4e3a\u5c0f\u5199\u8def\u7531\u5730\u5740\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u751f\u6210\u63a7\u5236\u5668\u8def\u7531\u6a21\u677f\u683c\u5f0f\u4e3a\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"api/\u524d\u7f6e\u53c2\u6570\u5217\u8868/\u6a21\u5757\u540d\u6216\u9ed8\u8ba4\u533a\u57df\u540d/[controller@\u7248\u672c\u53f7]/\u540e\u7f6e\u53c2\u6570\u5217\u8868")),Object(r.b)("li",{parentName:"ul"},"\u751f\u6210\u52a8\u4f5c\u65b9\u6cd5\u8def\u7531\u6a21\u677f\u683c\u5f0f\u4e3a\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"\u524d\u7f6e\u53c2\u6570\u5217\u8868/\u6a21\u5757\u540d/[action@\u7248\u672c\u53f7]/\u540e\u7f6e\u53c2\u6570\u5217\u8868"))),Object(r.b)("h3",{id:"575-\u5176\u4ed6\u7ea6\u5b9a"},"5.7.5 \u5176\u4ed6\u7ea6\u5b9a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u9ed8\u8ba4\u4e0d\u5904\u7406 ",Object(r.b)("inlineCode",{parentName:"li"},"ControllerBase")," \u63a7\u5236\u5668\u7c7b\u578b\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},"\u9ed8\u8ba4\u4e0d\u5904\u7406 ",Object(r.b)("inlineCode",{parentName:"li"},"GET\uff0cHEAD")," \u8bf7\u6c42\u7684\u5f15\u7528\u7c7b\u578b\u53c2\u6570\u3002",Object(r.b)("strong",{parentName:"li"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e"))),Object(r.b)("h2",{id:"58-\u66f4\u591a\u4f8b\u5b50"},"5.8 \u66f4\u591a\u4f8b\u5b50"),Object(r.b)("h3",{id:"581-\u591a\u79cd\u8bf7\u6c42\u8c13\u8bcd\u65b9\u6cd5"},"5.8.1 \u591a\u79cd\u8bf7\u6c42\u8c13\u8bcd\u65b9\u6cd5"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,12,17,22,27}","{7,12,17,22,27}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return $"GET \u8bf7\u6c42";\n }\n\n public string Post()\n {\n return $"POST \u8bf7\u6c42";\n }\n\n public string Delete()\n {\n return $"DELETE \u8bf7\u6c42";\n }\n\n public string Put()\n {\n return $"PUT \u8bf7\u6c42";\n }\n\n public string Patch()\n {\n return $"PATCH \u8bf7\u6c42";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dgqqwc.png")}),Object(r.b)("h3",{id:"582-\u591a\u4e2a\u81ea\u5b9a\u4e49\u52a8\u4f5c\u65b9\u6cd5"},"5.8.2 \u591a\u4e2a\u81ea\u5b9a\u4e49\u52a8\u4f5c\u65b9\u6cd5"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,12,17}","{7,12,17}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string GetVersion()\n {\n return $"v1.0.0";\n }\n\n public string ChangeProfile()\n {\n return "\u4fee\u6539\u6210\u529f";\n }\n\n public string DeleteUser()\n {\n return "\u5220\u9664\u6210\u529f";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dzmc.png")}),Object(r.b)("h3",{id:"583-\u5e26\u53c2\u6570\u52a8\u4f5c\u65b9\u6cd5"},"5.8.3 \u5e26\u53c2\u6570\u52a8\u4f5c\u65b9\u6cd5"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,12,17}","{7,12,17}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string GetUser(int id)\n {\n return $"{id}";\n }\n\n public string GetUser(int id, string name)\n {\n return $"{id} {name}";\n }\n\n public TestDto Add(TestDto testDto)\n {\n return testDto;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dcsff.gif")}),Object(r.b)("h3",{id:"585-gethead-\u7c7b\u7c7b\u578b\u53c2\u6570"},"5.8.5 ",Object(r.b)("inlineCode",{parentName:"h3"},"GET/HEAD")," \u7c7b\u7c7b\u578b\u53c2\u6570"),Object(r.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u4f1a\u5c06 ",Object(r.b)("inlineCode",{parentName:"p"},"GET/HEAD")," \u8bf7\u6c42\u4e2d\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"\u7c7b\u7c7b\u578b\u53c2\u6570")," \u8bbe\u7f6e\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"[FromBody]")," \u7ed1\u5b9a\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7}","{7}":!0}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public TestDto GetTest(TestDto testDto)\n {\n return testDto;\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/getyycs.png")}),Object(r.b)("p",null,"\u4f46\u662f\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"GET\u3001HEAD")," \u8bf7\u6c42\u4e0d\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"p"},"From Body")," \u7ed1\u5b9a\u3002\u6240\u4ee5\u6211\u4eec\u9700\u8981\u8f6c\u6362\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"Query")," \u67e5\u8be2\u53c2\u6570\u3002"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u652f\u6301\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u914d\u7f6e\uff1a"),Object(r.b)(c.a,{defaultValue:"fromquery",values:[{label:"[FromQuery] \u7279\u6027",value:"fromquery"},{label:"\u914d\u7f6e DynamicApiControllerSettings",value:"DynamicApiControllerSettings"}],mdxType:"Tabs"},Object(r.b)(l.a,{value:"fromquery",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,8}","{2,8}":!0}),"using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public TestDto GetTest([FromQuery] TestDto testDto)\n {\n return testDto;\n }\n }\n}\n"))),Object(r.b)(l.a,{value:"DynamicApiControllerSettings",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:'{2-4} title="Fur.Web.Entry/appsettings.json"',"{2-4}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "DynamicApiControllerSettings": {\n "ModelToQuery": true\n }\n }\n}\n')))),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/modeltoquery.png")}),Object(r.b)("h3",{id:"586-\u81ea\u5b9a\u4e49\u53c2\u6570\u4f4d\u7f6e"},"5.8.6 \u81ea\u5b9a\u4e49\u53c2\u6570\u4f4d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u65b9\u4fbf\u7684\u81ea\u5b9a\u4e49\u53c2\u6570\u4f4d\u7f6e\u7684\u7279\u6027 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiSeat]"),"\uff0c\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiSeat]")," \u53ef\u914d\u7f6e\u53c2\u6570\u4f4d\u7f6e\uff0c\u652f\u6301\u4ee5\u4e0b\u56db\u79cd\u4f4d\u7f6e\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ApiSeats.ControllerStart"),"\uff1a\u63a7\u5236\u5668\u4e4b\u524d"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ApiSeats.ControllerEnd"),"\uff1a\u63a7\u5236\u5668\u4e4b\u540e"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ApiSeats.ActionStart"),"\uff1a\u52a8\u4f5c\u65b9\u6cd5\u4e4b\u524d"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ApiSeats.ActionEnd"),"\uff1a\u52a8\u4f5c\u65b9\u6cd5\u4e4b\u540e\u3002",Object(r.b)("strong",{parentName:"li"},"\u9ed8\u8ba4\u503c"))),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8-9,15-20}","{8-9,15-20}":!0}),'using Fur.DynamicApiController;\nusing System;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n // \u53c2\u6570\u9ed8\u8ba4\u4e3a ApiSeats.ActionEnd\n public string RouteSeat(int id, string name)\n {\n return "\u914d\u7f6e\u8def\u7531\u53c2\u6570\u4f4d\u7f6e";\n }\n\n public string RouteSeat(\n [ApiSeat(ApiSeats.ControllerStart)] int id, // \u63a7\u5236\u5668\u540d\u79f0\u4e4b\u524d\n [ApiSeat(ApiSeats.ControllerEnd)] string name, // \u63a7\u5236\u5668\u540d\u79f0\u4e4b\u540e\n [ApiSeat(ApiSeats.ControllerEnd)] int age, // \u63a7\u5236\u5668\u540d\u79f0\u4e4b\u540e\n [ApiSeat(ApiSeats.ActionStart)] decimal weight, // \u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u4e4b\u524d\n [ApiSeat(ApiSeats.ActionStart)] float height, // \u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u4e4b\u524d\n [ApiSeat(ApiSeats.ActionEnd)] DateTime birthday) // \u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u4e4b\u540e\uff08\u9ed8\u8ba4\u503c\uff09\n {\n return "\u914d\u7f6e\u8def\u7531\u53c2\u6570\u4f4d\u7f6e";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/cswz.png")}),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u6e29\u99a8\u63d0\u793a")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u591a\u4e2a ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"\u540c\u4f4d\u7f6e"))," \u914d\u7f6e\u7684\u53c2\u6570\u5c06\u6309\u7167 ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"\u5b9a\u4e49\u53c2\u6570\u987a\u5e8f"))," \u8fdb\u884c\u6392\u5e8f\u3002"))),Object(r.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"[ApiSeat]")," \u53ea\u80fd\u5e94\u7528\u4e8e\u8d34\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"[FromRoute]")," \u7279\u6027\u7684\u53c2\u6570\u6216 ",Object(r.b)("inlineCode",{parentName:"p"},"\u57fa\u5143\u7c7b\u578b\u3001\u503c\u7c7b\u578b\u3001\u53ef\u7a7a\u57fa\u5143\u7c7b\u578b\u548c\u53ef\u7a7a\u503c\u7c7b\u578b"),"\u3002"))),Object(r.b)("h3",{id:"587-\u81ea\u5b9a\u4e49\u8bf7\u6c42\u8c13\u8bcd"},"5.8.7 \u81ea\u5b9a\u4e49\u8bf7\u6c42\u8c13\u8bcd"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,8}","{2,8}":!0}),'using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [HttpPost]\n public string GetVersion()\n {\n return "1.0.0";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/zdywc.png")}),Object(r.b)("h3",{id:"588-\u652f\u6301\u591a\u4e2a\u8c13\u8bcd"},"5.8.8 \u652f\u6301\u591a\u4e2a\u8c13\u8bcd"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,8}","{2,8}":!0}),'using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [HttpPost, HttpGet, AcceptVerbs("PUT", "DELETE")]\n public string GetVersion()\n {\n return "1.0.0";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dgwc.png")}),Object(r.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5982\u679c\u52a8\u4f5c\u65b9\u6cd5\u4e2d\u542b\u6709 ",Object(r.b)("inlineCode",{parentName:"p"},"\u7c7b\u7c7b\u578b\u53c2\u6570"),"\uff0c\u4e14\u542b\u6709 ",Object(r.b)("inlineCode",{parentName:"p"},"POST/PUT/DELETE")," \u4efb\u610f\u8bf7\u6c42\u8c13\u8bcd\uff0c\u90a3\u4e48\u8be5\u53c2\u6570\u4f1a\u81ea\u52a8\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"p"},"[FromBody]")," \u53c2\u6570\uff0c\u5373\u4f7f\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"GET/HEAD")," \u8bf7\u6c42\u4e2d\u4e0d\u652f\u6301\u3002"))),Object(r.b)("h3",{id:"589-\u652f\u6301\u81ea\u5b9a\u4e49\u8def\u7531"},"5.8.9 \u652f\u6301\u81ea\u5b9a\u4e49\u8def\u7531"),Object(r.b)("p",null,"\u652f\u6301\u63a7\u5236\u5668\u548c\u52a8\u4f5c\u65b9\u6cd5\u81ea\u5b9a\u4e49\u8def\u7531\uff1a"),Object(r.b)(c.a,{defaultValue:"kzqrl",values:[{label:"\u81ea\u5b9a\u4e49\u63a7\u5236\u5668\u8def\u7531",value:"kzqrl"},{label:"\u81ea\u5b9a\u4e49\u52a8\u4f5c\u65b9\u6cd5\u8def\u7531",value:"dzffrl"},{label:"\u540c\u65f6\u81ea\u5b9a\u4e49\u8def\u7531",value:"allrl"},{label:"\u8c13\u8bcd\u81ea\u5b9a\u4e49\u8def\u7531",value:"vcrl"}],mdxType:"Tabs"},Object(r.b)(l.a,{value:"kzqrl",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,6}","{2,6}":!0}),'using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n [Route("customapi/mobile/[controller]")]\n public class FurAppService : IDynamicApiController\n {\n public string GetVersion()\n {\n return "1.0.0";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/kzqrl.png")})),Object(r.b)(l.a,{value:"dzffrl",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,8}","{2,8}":!0}),'using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [Route("customapi/[action]")]\n public string GetVersion()\n {\n return "1.0.0";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dzffrl.png")})),Object(r.b)(l.a,{value:"allrl",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,6,9}","{2,6,9}":!0}),'using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n [Route("customapi/mobile/[controller]")]\n public class FurAppService : IDynamicApiController\n {\n [Route("get/[action]")]\n public string GetVersion()\n {\n return "1.0.0";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/allrl.png")})),Object(r.b)(l.a,{value:"vcrl",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{9}","{9}":!0}),'using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n [Route("api/[controller]")]\n public class FurAppService : IDynamicApiController\n {\n [HttpGet("get/[action]")]\n public string GetVersion()\n {\n return "1.0.0";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/wcrl.png")}))),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u5c0f\u63d0\u793a")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u52a8\u6001\u65b9\u6cd5\u81ea\u5b9a\u4e49\u8def\u7531\u5982\u679c\u4ee5 ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"/"))," \u5f00\u5934\uff0c\u5219\u4e0d\u4f1a\u5408\u5e76\u63a7\u5236\u5668\u8def\u7531\u3002"))),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u63a8\u8350\u914d\u7f6e")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u81ea\u5b9a\u4e49\u8def\u7531\u5982\u679c\u9700\u8981\u7528\u5230 ",Object(r.b)("strong",{parentName:"p"},"\u63a7\u5236\u5668/\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0"),"\uff0c\u63a8\u8350\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"[controller]")," \u6216 ",Object(r.b)("inlineCode",{parentName:"p"},"[action]")," \u5360\u4f4d\u7b26\uff0c\u56e0\u4e3a\u8be5\u5360\u4f4d\u7b26\u5df2\u7ecf\u81ea\u52a8\u5904\u7406\u4e86 ",Object(r.b)("strong",{parentName:"p"},"\u524d\u540e\u7f00\u3001\u7248\u672c\u53f7\u3001\u6a21\u5757\u540d\u79f0"),"\u7b49\u3002"))),Object(r.b)("h3",{id:"5810-\u591a\u8def\u7531\u968f\u610f\u7ec4\u5408"},"5.8.10 \u591a\u8def\u7531\u968f\u610f\u7ec4\u5408"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u7684\u5404\u79cd\u8def\u7531\u7ec4\u5408\u65b9\u5f0f\uff0c\u652f\u6301\u4e00\u5bf9\u591a\uff0c\u591a\u5bf9\u591a\u8def\u7531\u7ec4\u5408\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{6-8,11-14}","{6-8,11-14}":!0}),'using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n [Route("api/[controller]")]\n [Route("api/[controller]/second")]\n [Route("api/[controller]/three")]\n public class FurAppService : IDynamicApiController\n {\n [HttpGet]\n [HttpGet("get/[action]")]\n [HttpPost]\n [HttpPost("post/cus-version")]\n public string GetVersion()\n {\n return "1.0.0";\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dlrzh.gif")}),Object(r.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u52a8\u4f5c\u65b9\u6cd5\u4e0d\u80fd\u540c\u65f6\u8d34 ",Object(r.b)("inlineCode",{parentName:"p"},"[Route]")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"[HttpMethod]")," \u7279\u6027\uff0c\u53ea\u80fd\u4e8c\u53d6\u4e00\u3002"))),Object(r.b)("h3",{id:"5811-\u652f\u6301\u7248\u672c\u63a7\u5236"},"5.8.11 \u652f\u6301\u7248\u672c\u63a7\u5236"),Object(r.b)(c.a,{defaultValue:"kzqbb",values:[{label:"\u63a7\u5236\u5668\u7248\u672c",value:"kzqbb"},{label:"\u52a8\u4f5c\u65b9\u6cd5\u7248\u672c",value:"dzffbb"}],mdxType:"Tabs"},Object(r.b)(l.a,{value:"kzqbb",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,13,21}","{5,13,21}":!0}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppServiceV1 : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n }\n\n public class FurAppServiceV1_2 : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n }\n\n public class FurAppServiceV1_2_1 : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/kzqbb.png")})),Object(r.b)(l.a,{value:"dzffbb",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,12,16}","{7,12,16}":!0}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public string GetV1()\n {\n return nameof(Fur);\n }\n public string GetV2_1()\n {\n return nameof(Fur);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dzffbb.png")}))),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7248\u672c\u751f\u6210\u539f\u7406")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"V[0-9_]"))," \u7ed3\u5c3e\u7684\u547d\u540d\u81ea\u52a8\u89e3\u6790\u6210\u7248\u672c\u53f7\uff0c\u5982 ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"FurAppServiceV2 -> Fur@2")),"\u3002"))),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u7248\u672c\u590d\u5199")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u9664\u4e86\u901a\u8fc7\u7279\u5b9a\u540e\u7f00\u65b9\u5f0f\u4ee5\u5916\uff0c\u7248\u672c\u8fd8\u76f4\u63a5\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiDescriptionSettings]")," \u8fdb\u884c\u590d\u5199\u3002\u5982\uff1a"),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,2}","{1,2}":!0}),'[ApiDescriptionSettings(Version = "4.0")]\npublic string GetV1()\n{\n return nameof(Fur);\n}\n')),Object(r.b)("p",{parentName:"div"},"\u8fd9\u65f6\uff0c\u751f\u6210\u7248\u672c\u5c06\u91c7\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"4.0")," \u66ff\u4ee3 ",Object(r.b)("inlineCode",{parentName:"p"},"1")))),Object(r.b)("h3",{id:"5812-\u4e0d\u516c\u5f00\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5"},"5.8.12 \u4e0d\u516c\u5f00\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5"),Object(r.b)("p",null,"\u6709\u4e9b\u65f6\u5019\uff0c\u6211\u4eec\u65e0\u9700\u5bfc\u51fa\u67d0\u4e2a\u52a8\u4f5c\u65b9\u6cd5\u6216\u63a7\u5236\u5668\uff0c\u53ea\u9700\u8981\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiDescriptionSettings(false)]")," \u6216 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiExplorerSettings(IgnoreApi = true)]"),"\u5373\u53ef\u3002"),Object(r.b)("p",null,"\u53e6\u5916\u52a8\u4f5c\u65b9\u6cd5\u8fd8\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"p"},"[NonAction]")," \u6807\u8bb0\u3002"),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u63a8\u8350\u4f7f\u7528")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u63a8\u8350\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5\u8bbe\u7f6e\u4e0d\u5bfc\u51fa\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiDescriptionSettings(false)]")," \u7279\u6027\u3002\u8be5\u7279\u6027\u9ed8\u8ba4\u7ee7\u627f\u81ea ",Object(r.b)("inlineCode",{parentName:"p"},"ApiExplorerSettingsAttribute")," \u7c7b\u3002"))),Object(r.b)("h2",{id:"59-apidescriptionsettings"},"5.9 ",Object(r.b)("inlineCode",{parentName:"h2"},"[ApiDescriptionSettings]")),Object(r.b)("p",null,"\u9664\u4e86\u4e0a\u8ff0 ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u63d0\u4f9b\u7684\u914d\u7f6e\u5916\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u8fd8\u63d0\u4f9b\u4e86\u975e\u5e38\u5f3a\u5927\u4e14\u7075\u6d3b\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiDescriptionSettings]")," \u7279\u6027\u3002"),Object(r.b)("h3",{id:"591-\u5185\u7f6e\u914d\u7f6e"},"5.9.1 \u5185\u7f6e\u914d\u7f6e"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Name"),"\uff1a\u81ea\u5b9a\u4e49\u63a7\u5236\u5668/\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"null")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"KeepName"),"\uff1a\u662f\u5426\u4fdd\u6301\u539f\u6709\u540d\u79f0\u4e0d\u5904\u7406\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"false")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"SplitCamelCase"),"\uff1a\u5207\u5272\u9a86\u9a7c\u547d\u540d\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"true")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"KeepVerb"),"\uff1a\u662f\u5426\u4fdd\u7559\u52a8\u4f5c\u65b9\u6cd5\u8bf7\u6c42\u8c13\u8bcd\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"false")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Enabled"),"\uff1a\u662f\u5426\u5bfc\u51fa\u63a5\u53e3\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"true")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Module"),"\uff1a\u6a21\u5757\u540d\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"null")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Version"),"\uff1a\u7248\u672c\u53f7\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"null")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Groups"),"\uff1a\u63a5\u53e3\u5206\u7ec4\uff0c\u53ef\u7ed3\u5408 ",Object(r.b)("inlineCode",{parentName:"li"},"Swagger")," \u4e00\u8d77\u4f7f\u7528\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string[]"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"null")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Tags"),"\uff1a\u63a5\u53e3\u6807\u7b7e\uff0c\u53ef\u7ed3\u5408 ",Object(r.b)("inlineCode",{parentName:"li"},"Swagger")," \u4e00\u8d77\u4f7f\u7528\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string[]"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"null")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"AuthPolicies"),"\uff1a\u6388\u6743\u7b56\u7565\uff0c\u53ef\u7ed3\u5408 ",Object(r.b)("inlineCode",{parentName:"li"},"\u6388\u6743\uff0cJWT")," \u4e00\u8d77\u4f7f\u7528\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string[]"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"null"))),Object(r.b)("h3",{id:"592-name-\u914d\u7f6e"},"5.9.2 ",Object(r.b)("inlineCode",{parentName:"h3"},"Name")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Name")," \u53c2\u6570\u53ef\u4ee5\u8986\u76d6\u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u81ea\u52a8\u751f\u6210\u7684\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u3002\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,8}","{5,8}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(Name = "MyFur")]\n public class FurAppService : IDynamicApiController\n {\n [ApiDescriptionSettings(Name = "MyGet")]\n public string Get()\n {\n return nameof(Fur);\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/namepz.png")}),Object(r.b)("h3",{id:"593-keepname-\u914d\u7f6e"},"5.9.3 ",Object(r.b)("inlineCode",{parentName:"h3"},"KeepName")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"KeepName")," \u53c2\u6570\u53ef\u4ee5\u4fdd\u7559\u539f\u6709\u7684\u63a7\u5236\u5668\u6216\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u3002\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,8}","{5,8}":!0}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(KeepName = true)]\n public class FurAppService : IDynamicApiController\n {\n [ApiDescriptionSettings(KeepName = true)]\n public string Get()\n {\n return nameof(Fur);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/keepnamepz.png")}),Object(r.b)("h3",{id:"594-splitcamelcase-\u914d\u7f6e"},"5.9.4 ",Object(r.b)("inlineCode",{parentName:"h3"},"SplitCamelCase")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"SplitCamelCase")," \u53c2\u6570\u9ed8\u8ba4\u5c06\u9a86\u9a7c\u547d\u540d\u5207\u5272\u6210\u591a\u4e2a\u5355\u8bcd\u5e76\u901a\u8fc7\u6307\u5b9a ",Object(r.b)("inlineCode",{parentName:"p"},"\u5360\u4f4d\u7b26")," \u8fde\u63a5\u8d77\u6765\u3002\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"p"},"\u5360\u4f4d\u7b26")," \u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"-"),"\u3002\u9ed8\u8ba4\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"true"),"\u3002\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,8}","{5,8}":!0}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(SplitCamelCase = false)]\n public class MyFurAppService : IDynamicApiController\n {\n [ApiDescriptionSettings(SplitCamelCase = true)]\n public string ChangeUserName()\n {\n return nameof(Fur);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/splitnamepz.png")}),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"KeepName")," \u4f18\u5148\u7ea7\u9ad8\u4e8e ",Object(r.b)("inlineCode",{parentName:"p"},"SplitCamelCase"),"\uff0c\u4e5f\u5c31\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"KeepName")," \u8bbe\u7f6e\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"true"),"\uff0c\u5219\u4e0d\u4f1a\u5904\u7406 ",Object(r.b)("inlineCode",{parentName:"p"},"SplitCamelCase")," \u53c2\u6570\u3002"))),Object(r.b)("h3",{id:"595-keepverb-\u914d\u7f6e"},"5.9.5 ",Object(r.b)("inlineCode",{parentName:"h3"},"KeepVerb")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"KeepVerb")," \u53c2\u6570\u4f5c\u7528\u4e8e\u52a8\u4f5c\u65b9\u6cd5\uff0c\u6807\u8bc6\u662f\u5426\u4fdd\u7559\u52a8\u4f5c\u8c13\u8bcd\u3002\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7}","{7}":!0}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [ApiDescriptionSettings(KeepVerb = true)]\n public string GetVersion()\n {\n return nameof(Fur);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/keepverbpz.png")}),Object(r.b)("h3",{id:"596-enabled-\u914d\u7f6e"},"5.9.6 ",Object(r.b)("inlineCode",{parentName:"h3"},"Enabled")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Enabled")," \u53c2\u6570\u914d\u7f6e\u63a5\u53e3\u662f\u5426\u5bfc\u51fa\u3002\u901a\u5e38\u7528\u4e8e\u52a8\u4f5c\u65b9\u6cd5\uff0c\u5982\u679c\u7528\u4e8e\u63a7\u5236\u5668\u5b9e\u9645\u4f5c\u7528\u4e0d\u5927\u3002"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{12}","{12}":!0}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string GetVersion()\n {\n return nameof(Fur);\n }\n\n [ApiDescriptionSettings(false)]\n public string NoExport()\n {\n return nameof(Fur);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/enablepz.png")}),Object(r.b)("h3",{id:"597-module-\u914d\u7f6e"},"5.9.7 ",Object(r.b)("inlineCode",{parentName:"h3"},"Module")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Module")," \u53c2\u6570\u53ef\u4ee5\u914d\u7f6e\u8def\u7531\u5206\u79bb\uff0c\u7c7b\u4f3c\u4e8e ",Object(r.b)("inlineCode",{parentName:"p"},"Mvc \u533a\u57df")," \u7684\u4f5c\u7528\u3002"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,8}","{5,8}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(Module = "mobile")]\n public class FurAppService : IDynamicApiController\n {\n [ApiDescriptionSettings(Module = "user")]\n public string GetVersion()\n {\n return nameof(Fur);\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/modulepz.png")}),Object(r.b)("h3",{id:"598-version-\u914d\u7f6e"},"5.9.8 ",Object(r.b)("inlineCode",{parentName:"h3"},"Version")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Version")," \u53c2\u6570\u53ef\u4ee5\u914d\u7f6e\u63a5\u53e3\u7248\u672c\uff0c\u540c\u65f6\u53c8\u53ef\u4ee5\u590d\u5199\u7279\u6b8a\u7248\u672c\u547d\u540d\u914d\u7f6e\u3002\u9ed8\u8ba4\u7248\u672c\u53f7\u5206\u9694\u7b26\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"@"),"\u3002\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,9-10}","{5,9-10}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(Version = "1.0")]\n public class FurAppService : IDynamicApiController\n {\n // V2.0.0 \u88ab\u590d\u5199\u6210 V2.1.1\n [ApiDescriptionSettings(Version = "2.1.1")]\n public string GetVersionV2_0_0()\n {\n return nameof(Fur);\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/versionpz.png")}),Object(r.b)("h3",{id:"599-groups-\u914d\u7f6e"},"5.9.9 ",Object(r.b)("inlineCode",{parentName:"h3"},"Groups")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Groups")," \u914d\u7f6e\u4e3b\u8981\u7528\u4e8e\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u5206\u7ec4\u4fe1\u606f\u3002"),Object(r.b)("p",null,"\u901a\u8fc7\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"Groups")," \u53c2\u6570\u53ef\u4ee5\u5c06",Object(r.b)("inlineCode",{parentName:"p"},"\u63a7\u5236\u5668\u548c\u52a8\u4f5c\u65b9\u6cd5")," \u8fdb\u884c\u5f52\u7c7b\u548c\u591a\u4e2a\u5206\u7ec4\u76f4\u63a5\u5171\u4eab\u3002\u53ef\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiDescriptionSettings(params Groups)]")," \u6784\u9020\u51fd\u6570\u4f20\u5165\u6216\u6307\u5b9a ",Object(r.b)("inlineCode",{parentName:"p"},"Groups")," \u53c2\u6570\u914d\u7f6e\u63a5\u53e3\u662f\u5426\u5bfc\u51fa\u3002\u901a\u5e38\u7528\u4e8e\u52a8\u4f5c\u65b9\u6cd5\uff0c\u5982\u679c\u7528\u4e8e\u63a7\u5236\u5668\u5b9e\u9645\u4f5c\u7528\u4e0d\u5927\u3002"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,13}","{5,13}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings("Default", "Common")]\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n [ApiDescriptionSettings("Custom")]\n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/dfz.gif")}),Object(r.b)("h3",{id:"5910-tag-\u914d\u7f6e"},"5.9.10 ",Object(r.b)("inlineCode",{parentName:"h3"},"Tag")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Tag")," \u914d\u7f6e\u4e3b\u8981\u7528\u4e8e\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u6807\u7b7e\u5206\u7ec4\u4fe1\u606f\u53ca\u5408\u5e76\u6807\u7b7e\u3002\u4e5f\u5c31\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"\u7ec4\u4e2d\u7ec4"),":"),Object(r.b)(c.a,{defaultValue:"tag1",values:[{label:"\u6807\u7b7e\u547d\u540d",value:"tag1"},{label:"\u5408\u5e76\u6807\u7b7e",value:"tag2"}],mdxType:"Tabs"},Object(r.b)(l.a,{value:"tag1",mdxType:"TabItem"},Object(r.b)("h4",{id:"\u672a\u8d34\u6807\u7b7e\u4e4b\u524d"},"\u672a\u8d34\u6807\u7b7e\u4e4b\u524d"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n\n public class TestAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n}\n")),Object(r.b)("h4",{id:"\u8d34\u6807\u7b7e\u4e4b\u540e"},"\u8d34\u6807\u7b7e\u4e4b\u540e"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,19}","{5,19}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(Tag = "\u5206\u7ec4\u4e00")]\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n\n [ApiDescriptionSettings(Tag = "\u5206\u7ec4\u4e8c")]\n public class TestAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/tag1.png")})),Object(r.b)(l.a,{value:"tag2",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,19}","{5,19}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(Tag = "\u5408\u5e76\u6240\u6709\u6807\u7b7e")]\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n\n [ApiDescriptionSettings(Tag = "\u5408\u5e76\u6240\u6709\u6807\u7b7e")]\n public class TestAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(b.a)("img/tag2.png")}))),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5982\u679c ",Object(r.b)("inlineCode",{parentName:"p"},"Tag")," \u540d\u5b57\u4e00\u6837\uff0c\u5219\u4f1a\u81ea\u52a8\u5408\u5e76\uff0c\u5426\u5219\u53ea\u662f\u547d\u540d\u3002"))),Object(r.b)("h2",{id:"510-dynamicapicontrollersettings-\u914d\u7f6e"},"5.10 ",Object(r.b)("inlineCode",{parentName:"h2"},"DynamicApiControllerSettings")," \u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u8fd8\u63d0\u4f9b\u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a5\u53e3\u4e00\u4e9b\u5168\u5c40\u914d\u7f6e\u9009\u9879\uff0c\u5982\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DefaultRoutePrefix"),"\uff1a\u9ed8\u8ba4\u8def\u7531\u524d\u7f00\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"api")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DefaultHttpMethod"),"\uff1a\u9ed8\u8ba4\u8bf7\u6c42\u8c13\u8bcd\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"POST")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DefaultModule"),"\uff1a\u9ed8\u8ba4\u6a21\u5757\u540d\u79f0\uff08\u533a\u57df\uff09\uff0c\u53ef\u7528\u4f5c\u63a5\u53e3\u7248\u672c\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"v1")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"LowercaseRoute"),"\uff1a\u5c0f\u5199\u8def\u7531\u683c\u5f0f\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"true")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"KeepVerb"),"\uff1a\u662f\u5426\u4fdd\u7559\u52a8\u4f5c\u8c13\u8bcd\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"false")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"CamelCaseSeparator"),"\uff1a\u9a86\u9a7c\u547d\u540d\u5206\u9694\u7b26\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"-")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"VersionSeparator"),"\uff1a\u7248\u672c\u5206\u9694\u7b26\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"@")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ModelToQuery"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"GET/HEAD")," \u8bf7\u6c42\u5c06 ",Object(r.b)("inlineCode",{parentName:"li"},"\u7c7b\u7c7b\u578b\u53c2\u6570\u8f6c\u67e5\u8be2\u53c2\u6570"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"false")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"SupportedMvcController"),"\uff1a\u662f\u5426\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"li"},"Mvc Controller")," \u52a8\u6001\u914d\u7f6e\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"false")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"AbandonControllerAffixes"),"\uff1a\u9ed8\u8ba4\u53bb\u9664\u63a7\u5236\u5668\u540d\u79f0\u524d\u540e\u7f00\u5217\u8868\u540d\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string[]"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"AppServices")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"AppService")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ApiController")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Controller")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Services")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Service")))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"AbandonActionAffixes"),"\uff1a\u9ed8\u8ba4\u53bb\u9664\u52a8\u4f5c\u65b9\u6cd5\u540d\u79f0\u524d\u540e\u7f00\u5217\u8868\u540d\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string[]"),"\uff0c\u9ed8\u8ba4\uff1a",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Async"))))),Object(r.b)("h3",{id:"5101-\u652f\u6301-mvc-\u63a7\u5236\u5668-\u52a8\u6001\u914d\u7f6e"},"5.10.1 \u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"h3"},"Mvc \u63a7\u5236\u5668")," \u52a8\u6001\u914d\u7f6e"),Object(r.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u63a5\u53e3\u4e0d\u5bf9 ",Object(r.b)("inlineCode",{parentName:"p"},"ControllerBase")," \u7c7b\u578b\u8fdb\u884c\u4efb\u4f55\u5904\u7406\u3002\u5f53\u7136\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u624b\u52a8\u542f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"ControllerBase")," \u652f\u6301\u3002"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:'{2-4} title="Fur.Web.Entry/appsettings.json"',"{2-4}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "DynamicApiControllerSettings": {\n "SupportedMvcController": true\n }\n }\n}\n')),Object(r.b)("p",null,"\u8bbe\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"SupportedMvcController: true")," \u540e\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Mvc ControllerBase")," \u7c7b\u578b\u4e5f\u80fd\u548c\u52a8\u6001 ",Object(r.b)("inlineCode",{parentName:"p"},"WebAPI")," \u4e00\u6837\u7684\u7075\u6d3b\u4e86\u3002\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5}","{5}":!0}),"using Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n public class MvcController : ControllerBase\n {\n public string Get()\n {\n return nameof(Fur);\n }\n }\n}\n\n")),Object(r.b)("div",{className:"admonition admonition-warning alert alert--danger"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"})))),"\u6ce8\u610f\u4e8b\u9879")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u542f\u7528\u8be5\u914d\u7f6e\u540e\uff0c\u5982\u679c ",Object(r.b)("inlineCode",{parentName:"p"},"Mvc \u63a7\u5236\u5668")," \u6ca1\u6709\u4efb\u4f55 ",Object(r.b)("inlineCode",{parentName:"p"},"[Route]")," \u7279\u6027\uff0c\u4f46\u662f\u8d34\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiController]")," \u7279\u6027\u5c06\u4f1a\u62a5\u9519\u3002\u539f\u56e0\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiController]")," \u7279\u6027\u5185\u90e8\u505a\u4e86\u8def\u7531\u7279\u6027\u68c0\u6d4b\u3002\u6240\u4ee5\u5efa\u8bae\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"[ApiDataValidation]")," \u4ee3\u66ff\u3002"),Object(r.b)("p",{parentName:"div"},"\u67e5\u770b ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/dotnet/aspnetcore/blob/c565386a3ed135560bc2e9017aa54a950b4e35dd/src/Mvc/Mvc.Core/src/ApplicationModels/ApiBehaviorApplicationModelProvider.cs#L90"}),"ASP.NET Core - ApiBehaviorApplicationModelProvider \u6e90\u7801")))),Object(r.b)("h2",{id:"511-\u53cd\u9988\u4e0e\u5efa\u8bae"},"5.11 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}u.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/17256d0f.0dd677ec.js b/handbook/build/17256d0f.0dd677ec.js deleted file mode 100644 index d8c0c0da374..00000000000 --- a/handbook/build/17256d0f.0dd677ec.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{142:function(e,t,n){"use strict";n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return u}));var a=n(0),i=n.n(a);function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e){for(var t=1;t=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var o=i.a.createContext({}),p=function(e){var t=i.a.useContext(o),n=t;return e&&(n="function"==typeof e?e(t):b(b({},t),e)),n},s=function(e){var t=p(e.components);return i.a.createElement(o.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return i.a.createElement(i.a.Fragment,{},t)}},m=i.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,l=e.originalType,r=e.parentName,o=c(e,["components","mdxType","originalType","parentName"]),s=p(n),m=a,u=s["".concat(r,".").concat(m)]||s[m]||d[m]||l;return n?i.a.createElement(u,b(b({ref:t},o),{},{components:n})):i.a.createElement(u,b({ref:t},o))}));function u(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var l=n.length,r=new Array(l);r[0]=m;var b={};for(var c in t)hasOwnProperty.call(t,c)&&(b[c]=t[c]);b.originalType=e,b.mdxType="string"==typeof e?e:a,r[1]=b;for(var o=2;oMvc \u7279\u6027\u65b9\u5f0f",id:"832-mvc-\u7279\u6027\u65b9\u5f0f",children:[]}]},{value:"8.4 DataValidation \u9a8c\u8bc1 \ud83e\udd17",id:"84-datavalidation-\u9a8c\u8bc1-",children:[{value:"8.4.1 DataValidation \u4f18\u70b9",id:"841-datavalidation-\u4f18\u70b9",children:[]}]},{value:"8.5 DataValidation \u4f7f\u7528",id:"85-datavalidation-\u4f7f\u7528",children:[{value:"8.5.1 \u6ce8\u518c\u9a8c\u8bc1\u670d\u52a1",id:"851-\u6ce8\u518c\u9a8c\u8bc1\u670d\u52a1",children:[]},{value:"8.5.2 \u517c\u5bb9 Mvc \u7279\u6027\u9a8c\u8bc1",id:"852-\u517c\u5bb9-mvc-\u7279\u6027\u9a8c\u8bc1",children:[]},{value:"8.5.3 \u517c\u5bb9 Mvc \u590d\u6742\u9a8c\u8bc1",id:"853-\u517c\u5bb9-mvc-\u590d\u6742\u9a8c\u8bc1",children:[]}]},{value:"8.6 \u624b\u52a8\u9a8c\u8bc1",id:"86-\u624b\u52a8\u9a8c\u8bc1",children:[{value:"8.7.1 \u9a8c\u8bc1\u6a21\u578b",id:"871-\u9a8c\u8bc1\u6a21\u578b",children:[]},{value:"8.7.2 ValidationTypes \u5e38\u89c1\u9a8c\u8bc1",id:"872-validationtypes-\u5e38\u89c1\u9a8c\u8bc1",children:[]},{value:"8.7.3 [DataValidation] \u7279\u6027",id:"873-datavalidation-\u7279\u6027",children:[]}]},{value:"8.7 [NonValidation] \u8df3\u8fc7\u9a8c\u8bc1",id:"87-nonvalidation-\u8df3\u8fc7\u9a8c\u8bc1",children:[]},{value:"8.8 \u9ad8\u7ea7\u81ea\u5b9a\u4e49\u64cd\u4f5c",id:"88-\u9ad8\u7ea7\u81ea\u5b9a\u4e49\u64cd\u4f5c",children:[{value:"8.8.1 \u81ea\u5b9a\u4e49 ValidationTypes \u7c7b\u578b",id:"881-\u81ea\u5b9a\u4e49-validationtypes-\u7c7b\u578b",children:[]},{value:"8.8.2 \u81ea\u5b9a\u4e49 ValidationTypes \u5931\u8d25\u6d88\u606f",id:"882-\u81ea\u5b9a\u4e49-validationtypes-\u5931\u8d25\u6d88\u606f",children:[]}]},{value:"8.9 \u6a21\u578b\u9a8c\u8bc1\u8303\u56f4",id:"89-\u6a21\u578b\u9a8c\u8bc1\u8303\u56f4",children:[{value:"8.9.1 \u5168\u5c40\u9a8c\u8bc1",id:"891-\u5168\u5c40\u9a8c\u8bc1",children:[]},{value:"8.9.2 [NonValidation] \u8df3\u8fc7\u9a8c\u8bc1",id:"892-nonvalidation-\u8df3\u8fc7\u9a8c\u8bc1",children:[]},{value:"8.9.3 [TypeFilter(typeof(DataValidationFilter))] \u5c40\u90e8\u9a8c\u8bc1",id:"893-typefiltertypeofdatavalidationfilter-\u5c40\u90e8\u9a8c\u8bc1",children:[]},{value:"8.9.4 [ApiController] \u63a7\u5236\u5668\u8303\u56f4\u9a8c\u8bc1",id:"894-apicontroller-\u63a7\u5236\u5668\u8303\u56f4\u9a8c\u8bc1",children:[]}]},{value:"8.10 MiniProfiler \u67e5\u770b",id:"810-miniprofiler-\u67e5\u770b",children:[]},{value:"8.10 \u591a\u8bed\u8a00\u652f\u6301",id:"810-\u591a\u8bed\u8a00\u652f\u6301",children:[]},{value:"8.11 \u9a8c\u8bc1\u6a21\u578b\u63d0\u4f9b\u5668",id:"811-\u9a8c\u8bc1\u6a21\u578b\u63d0\u4f9b\u5668",children:[]},{value:"8.12 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"812-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],d={rightToc:s};function m(e){var t=e.components,n=Object(i.a)(e,["components"]);return Object(l.b)("wrapper",Object(a.a)({},d,n,{components:t,mdxType:"MDXLayout"}),Object(l.b)("h2",{id:"81-\u5173\u4e8e\u6570\u636e\u6821\u9a8c"},"8.1 \u5173\u4e8e\u6570\u636e\u6821\u9a8c"),Object(l.b)("p",null,"\u6570\u636e\u6821\u9a8c\u5b57\u9762\u4e0a\u7684\u610f\u601d\u5c31\u662f\u5bf9\u4f7f\u7528\u8005\u63d0\u4ea4\u8fc7\u6765\u7684\u6570\u636e\u8fdb\u884c\u5408\u6cd5\u6027\u9a8c\u8bc1\u3002\u5728\u4e00\u5957\u5b8c\u5584\u7684\u5e94\u7528\u7cfb\u7edf\u4e2d\uff0c\u6570\u636e\u6709\u6548\u6027\u6821\u9a8c\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u4e1a\u52a1\u5904\u7406\u7b2c\u4e00\u9053\u5173\u5361\u3002"),Object(l.b)("h2",{id:"82-\u6570\u636e\u6821\u9a8c\u7684\u597d\u5904"},"8.2 \u6570\u636e\u6821\u9a8c\u7684\u597d\u5904"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u8fc7\u6ee4\u4e0d\u5b89\u5168\u6570\u636e\uff0c\u63d0\u9ad8\u7cfb\u7edf\u7684\u5b89\u5168\u6027"),Object(l.b)("li",{parentName:"ul"},"\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u4e1a\u52a1\u5f02\u5e38\u5904\u7406\uff0c\u63d0\u9ad8\u7cfb\u7edf\u7684\u54cd\u5e94\u901f\u5ea6"),Object(l.b)("li",{parentName:"ul"},"\u5927\u5927\u63d0\u9ad8\u7cfb\u7edf\u7a33\u5b9a\u6027"),Object(l.b)("li",{parentName:"ul"},"\u5927\u6570\u636e\u5e76\u53d1\u65f6\u8d77\u7740\u4e00\u5b9a\u7684\u7f13\u51b2\u4f5c\u7528")),Object(l.b)("h2",{id:"83-\u6570\u636e\u6821\u9a8c\u65b9\u5f0f"},"8.3 \u6570\u636e\u6821\u9a8c\u65b9\u5f0f"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u4f20\u7edf\u65b9\u5f0f\uff0c\u5728\u4e1a\u52a1\u4ee3\u7801\u4e4b\u524d\u624b\u52a8\u9a8c\u8bc1"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Mvc")," \u7279\u6027\u65b9\u5f0f\uff0c",Object(l.b)("inlineCode",{parentName:"li"},"Mvc")," \u5185\u7f6e\u7684 ",Object(l.b)("inlineCode",{parentName:"li"},"DataAnnotations")," \u65b9\u5f0f"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"\u63a8\u8350\u65b9\u5f0f"),"\uff0c",Object(l.b)("inlineCode",{parentName:"li"},"Fur")," \u6846\u67b6\u5185\u7f6e\u7684 ",Object(l.b)("inlineCode",{parentName:"li"},"DataValidation")," \u9a8c\u8bc1"),Object(l.b)("li",{parentName:"ul"},"\u5176\u4ed6\u65b9\u5f0f\uff0c\u4f7f\u7528\u7b2c\u4e09\u65b9\u9a8c\u8bc1\u5e93\uff0c\u5982 ",Object(l.b)("inlineCode",{parentName:"li"},"FluentValidation"))),Object(l.b)("h3",{id:"831-\u4f20\u7edf\u65b9\u5f0f"},"8.3.1 \u4f20\u7edf\u65b9\u5f0f"),Object(l.b)("p",null,"\u5728\u5f88\u591a\u8001\u9879\u76ee\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u770b\u5230\u8fd9\u6837\u7684\u4ee3\u7801\uff1a"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{4,9,14}","{4,9,14}":!0}),'public bool Insert(Person person)\n{\n // \u9a8c\u8bc1\u53c2\u6570\n if(string.IsNullOrEmty(person.Name))\n {\n throw new System.Exception("\u540d\u5b57\u4e0d\u80fd\u4e3a\u7a7a");\n }\n\n if(person.Age < 18)\n {\n throw new System.Exception("\u5e74\u9f84\u4e0d\u80fd\u5c0f\u4e8e 18 \u5c81");\n }\n\n if(!person.Password.Equals(person.ConfirmPassword)\n {\n throw new System.Exception("\u4e24\u6b21\u5bc6\u7801\u4e0d\u4e00\u81f4");\n }\n\n // \u4e1a\u52a1\u4ee3\u7801\n _repository.Insert(person.Adapt());\n\n // ...\n}\n')),Object(l.b)("p",null,"\u4ece\u4e0a\u9762\u7684\u4ee3\u7801\u770b\u8d77\u6765\uff0c\u4f3c\u4e4e\u6ca1\u6709\u4ec0\u4e48\u4e0d\u59a5\uff0c\u4f46\u662f\u4ece\u4e00\u4e2a\u7a0b\u5e8f\u53ef\u7ef4\u62a4\u6027\u6765\u8bf4\uff0c\u8fd9\u662f\u4e00\u4e2a\u7cdf\u7cd5\u7684\u4ee3\u7801\uff0c\u56e0\u4e3a\u8be5\u4e1a\u52a1\u4ee3\u7801\u4e2d",Object(l.b)("strong",{parentName:"p"},"\u5305\u542b\u4e86\u592a\u591a\u4e0e\u4e1a\u52a1\u65e0\u5173\u7684\u6570\u636e\u9a8c\u8bc1"),"\u3002"),Object(l.b)("p",null,"\u8bd5\u60f3\u4e00\u4e0b\uff0c\u5982\u679c\u8fd9\u4e2a ",Object(l.b)("inlineCode",{parentName:"p"},"Person")," \u6709 \u51e0\u5341\u4e2a\u53c2\u6570\u90fd\u9700\u8981\u9a8c\u8bc1\u5462\uff1f\u53ef\u60f3\u800c\u77e5\uff0c\u8fd9\u662f\u4e00\u4e2a\u5e9e\u5927\u7684\u4e1a\u52a1\u4ee3\u7801\u3002"),Object(l.b)("p",null,"\u518d\u8005\uff0c\u5982\u679c\u5176\u4ed6\u5730\u65b9\u4e5f\u9700\u8981\u7528\u5230\u8fd9\u4e2a ",Object(l.b)("inlineCode",{parentName:"p"},"Person")," \u7c7b\u9a8c\u8bc1\u5462\uff1f\u90a3\u4ee3\u7801\u597d\u6bd4\u8001\u9f20\u5543\u8fc7\u7684\u9762\u5305\u5c51\u4e00\u6837\uff0c\u5230\u5904\u90fd\u662f\u3002"),Object(l.b)("p",null,"\u5982\u6b64\u5f97\u77e5\uff0c\u8fd9\u6837\u7684\u65b9\u5f0f\u662f\u6781\u5176\u4e0d\u63a8\u8350\u7684\uff0c",Object(l.b)("strong",{parentName:"p"},"\u4e0d\u4f46\u6c61\u67d3\u4e86\u4e1a\u52a1\u4ee3\u7801\uff0c\u4e5f\u7834\u574f\u4e86\u4e1a\u52a1\u804c\u8d23\u5355\u4e00\u6027\u539f\u7406\uff0c\u4e5f\u8ba9\u9a8c\u8bc1\u903b\u8f91\u65e0\u6cd5\u5b9e\u73b0\u901a\u7528\uff0c\u540e\u7eed\u7ef4\u62a4\u96be\u5ea6\u5927\u5927\u5347\u7ea7"),"\u3002"),Object(l.b)("h3",{id:"832-mvc-\u7279\u6027\u65b9\u5f0f"},"8.3.2 ",Object(l.b)("inlineCode",{parentName:"h3"},"Mvc")," \u7279\u6027\u65b9\u5f0f"),Object(l.b)("p",null,"\u5728 ",Object(l.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u4e2d\uff0c\u5fae\u8f6f\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u5168\u65b0\u7684 ",Object(l.b)("inlineCode",{parentName:"p"},"\u7279\u6027")," \u9a8c\u8bc1\u65b9\u5f0f\uff0c\u53ef\u901a\u8fc7\u5bf9\u5bf9\u8c61\u8d34\u7279\u6027\u5b9e\u73b0\u6570\u636e\u9a8c\u8bc1\u3002\u8fd9\u79cd\u65b9\u5f0f\u6709\u6548\u7684\u5c06\u6570\u636e\u6821\u9a8c\u548c\u4e1a\u52a1\u4ee3\u7801\u5265\u79bb\u5f00\u6765\uff0c\u800c\u4e14\u5bb9\u6613\u4f7f\u7528\u548c\u62d3\u5c55\u3002"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"\u5728\u6a21\u578b\u4e2d\u9a8c\u8bc1"))),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,7-8,11-12}","{1,7-8,11-12}":!0}),"using System.ComponentModel.DataAnnotations;\n\nnamespace Hoa.Application.Authorization.Dtos\n{\n public class SignInInput\n {\n [Required] // \u5fc5\u586b\u9a8c\u8bc1\n [MinLength(4)] // \u6700\u5c0f\u957f\u5ea6\u9a8c\u8bc1\n public string Account { get; set; }\n\n [Required] // \u5fc5\u586b\u9a8c\u8bc1\n [MaxLength(32)] // \u6700\u5927\u957f\u5ea6\u9a8c\u8bc1\n public string Password { get; set; }\n }\n}\n")),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"\u5728\u53c2\u6570\u4e2d\u9a8c\u8bc1"))),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2-3,8-9,12-13}","{2-3,8-9,12-13}":!0}),'public void CheckMethodParameterValid(\n [Required] // \u5fc5\u586b\u9a8c\u8bc1\n [MinLength(4)] // \u6700\u5c0f\u957f\u5ea6\u9a8c\u8bc1\n string name,\n\n int age,\n\n [Required] // \u5fc5\u586b\u9a8c\u8bc1\n [RegularExpression("[a-zA-Z0-9_]{8,30}") // \u6b63\u5219\u8868\u8fbe\u5f0f\u9a8c\u8bc1\n string password,\n\n [Required] // \u5fc5\u586b\u9a8c\u8bc1\n [RegularExpression("[a-zA-Z0-9_]{8,30}") // \u6b63\u5219\u8868\u8fbe\u5f0f\u9a8c\u8bc1\n string confirmPassword\n)\n{\n // TODO\n}\n')),Object(l.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5c0f\u63d0\u9192")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"\u5982\u679c\u51fd\u6570\u7684\u53c2\u6570\u5927\u4e8e\u6216\u7b49\u4e8e 3 \u4e2a\uff0c\u5efa\u8bae\u62bd\u79bb\u51fa\u6a21\u578b\u7c7b\uff0c\u4e5f\u5c31\u662f\u4e0d\u5efa\u8bae\u4e0a\u9762\u7684\u65b9\u5f0f\u3002"))),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"\u81ea\u5b9a\u4e49\u7279\u6027\u9a8c\u8bc1"))),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,13-24}","{1,13-24}":!0}),'public class ClassicMovieAttribute : ValidationAttribute\n{\n public ClassicMovieAttribute(int year)\n {\n Year = year;\n }\n\n public int Year { get; }\n\n public string GetErrorMessage() =>\n $"Classic movies must have a release year no later than {Year}.";\n\n protected override ValidationResult IsValid(object value, ValidationContext validationContext)\n {\n var movie = (Movie)validationContext.ObjectInstance;\n var releaseYear = ((DateTime)value).Year;\n\n if (movie.Genre == Genre.Classic && releaseYear > Year)\n {\n return new ValidationResult(GetErrorMessage());\n }\n\n return ValidationResult.Success;\n }\n}\n')),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},Object(l.b)("inlineCode",{parentName:"strong"},"IValidatableObject")," \u590d\u6742\u9a8c\u8bc1"))),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,3,10-19}","{1,3,10-19}":!0}),'using System.Collections.Generic;\n\npublic class DtoModel : IValidatableObject\n{\n [Required]\n [StringLength(100)]\n public string Title { get; set; }\n\n // \u4f60\u7684\u9a8c\u8bc1\u903b\u8f91\n public IEnumerable Validate(ValidationContext validationContext)\n {\n if (\u4f60\u7684\u903b\u8f91\u4ee3\u7801)\n {\n yield return new ValidationResult(\n "\u9519\u8bef\u6d88\u606f"\n ,new[] { nameof(Title) } // \u9a8c\u8bc1\u5931\u8d25\u7684\u5c5e\u6027\n );\n }\n }\n}\n')),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"Mvc")," \u7279\u6027\u65b9\u5f0f\u6781\u5927\u7684\u5c06\u4e1a\u52a1\u903b\u8f91\u548c\u9a8c\u8bc1\u8fdb\u884c\u4e86\u5265\u79bb\u548c\u89e3\u8026\uff0c\u800c\u4e14\u8fd8\u80fd\u5b9e\u73b0\u81ea\u5b9a\u4e49\u590d\u6742\u9a8c\u8bc1\u3002"),Object(l.b)("p",null,Object(l.b)("strong",{parentName:"p"},"\u4f46\u662f ",Object(l.b)("inlineCode",{parentName:"strong"},"Mvc")," \u7279\u6027\u9a8c\u8bc1\u65b9\u5f0f\u6709\u51e0\u4e2a\u660e\u663e\u7684\u7f3a\u70b9"),"\uff1a"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u53ea\u80fd\u5728 ",Object(l.b)("inlineCode",{parentName:"li"},"\u63a7\u5236\u5668")," \u4e2d\u7684 ",Object(l.b)("inlineCode",{parentName:"li"},"Action"),"\uff08\u52a8\u4f5c\u65b9\u6cd5\uff09\u4e2d\u4f7f\u7528"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"\u65e0\u6cd5\u5728\u4efb\u610f\u7c7b\u3001\u4efb\u610f\u65b9\u6cd5\u4e2d\u4f7f\u7528")),Object(l.b)("li",{parentName:"ul"},"\u5185\u7f6e\u7684\u9a8c\u8bc1\u7c7b\u578b\u975e\u5e38\u6709\u9650\uff0c\u4e14\u4e0d\u6613\u62d3\u5c55"),Object(l.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\u9a8c\u8bc1\u6d88\u606f\u540e\u671f\u914d\u7f6e")),Object(l.b)("p",null,"\u6240\u4ee5\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u4e86\u65b0\u7684\u9a8c\u8bc1\u5f15\u64ce ",Object(l.b)("inlineCode",{parentName:"p"},"DataValidation"),"\uff0c\u5728\u5b8c\u5168\u517c\u5bb9 ",Object(l.b)("inlineCode",{parentName:"p"},"Mvc")," \u5185\u7f6e\u9a8c\u8bc1\u7684\u540c\u65f6\u63d0\u4f9b\u4e86\u5927\u91cf\u5e38\u89c1\u9a8c\u8bc1\u3001\u590d\u6742\u9a8c\u8bc1\u3001\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u7b49\u80fd\u529b\u3002"),Object(l.b)("h2",{id:"84-datavalidation-\u9a8c\u8bc1-"},"8.4 ",Object(l.b)("inlineCode",{parentName:"h2"},"DataValidation")," \u9a8c\u8bc1 \ud83e\udd17"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"DataValidation")," \u662f ",Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u5168\u65b0\u7684\u9a8c\u8bc1\u65b9\u5f0f\uff0c\u5b8c\u5168\u517c\u5bb9 ",Object(l.b)("inlineCode",{parentName:"p"},"Mvc")," \u5185\u7f6e\u9a8c\u8bc1\uff0c\u5e76\u4e14\u8d4b\u4e88\u4e86\u8d85\u80fd\u3002"),Object(l.b)("h3",{id:"841-datavalidation-\u4f18\u70b9"},"8.4.1 ",Object(l.b)("inlineCode",{parentName:"h3"},"DataValidation")," \u4f18\u70b9"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"\u5b8c\u5168\u517c\u5bb9 ",Object(l.b)("inlineCode",{parentName:"strong"},"Mvc")," \u5185\u7f6e\u9a8c\u8bc1\u5f15\u64ce")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"\u5185\u7f6e\u5e38\u89c1\u9a8c\u8bc1\u7c7b\u578b\u53ca\u53ef\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u7c7b\u578b\u529f\u80fd")),Object(l.b)("li",{parentName:"ul"},"\u63d0\u4f9b\u5168\u5c40\u5bf9\u8c61\u62d3\u5c55\u9a8c\u8bc1\u65b9\u5f0f"),Object(l.b)("li",{parentName:"ul"},"\u652f\u6301\u9a8c\u8bc1\u6d88\u606f\u540e\u671f\u914d\u7f6e\uff0c\u652f\u6301\u5b9e\u65f6\u66f4\u65b0"),Object(l.b)("li",{parentName:"ul"},"\u652f\u6301\u5728\u4efb\u4f55\u7c7b\uff0c\u4efb\u4f55\u65b9\u6cd5\u3001\u4efb\u4f55\u4f4d\u7f6e\u5b9e\u73b0\u624b\u52a8\u9a8c\u8bc1\u3001\u7279\u6027\u65b9\u5f0f\u9a8c\u8bc1\u7b49"),Object(l.b)("li",{parentName:"ul"},"\u652f\u6301\u8bbe\u7f6e\u9a8c\u8bc1\u7ed3\u679c\u6a21\u578b")),Object(l.b)("h2",{id:"85-datavalidation-\u4f7f\u7528"},"8.5 ",Object(l.b)("inlineCode",{parentName:"h2"},"DataValidation")," \u4f7f\u7528"),Object(l.b)("h3",{id:"851-\u6ce8\u518c\u9a8c\u8bc1\u670d\u52a1"},"8.5.1 \u6ce8\u518c\u9a8c\u8bc1\u670d\u52a1"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{11} title="Fur.Web.Core\\FurWebCoreStartup.cs"',"{11}":!0,title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddControllers()\n .AddDataValidation();\n }\n }\n}\n")),Object(l.b)("div",{className:"admonition admonition-important alert alert--info"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},Object(l.b)("inlineCode",{parentName:"p"},".AddDataValidation()")," \u9700\u5728 ",Object(l.b)("inlineCode",{parentName:"p"},"services.AddControllers()")," \u4e4b\u540e\u6ce8\u518c\u3002"))),Object(l.b)("h3",{id:"852-\u517c\u5bb9-mvc-\u7279\u6027\u9a8c\u8bc1"},"8.5.2 \u517c\u5bb9 ",Object(l.b)("inlineCode",{parentName:"h3"},"Mvc")," \u7279\u6027\u9a8c\u8bc1"),Object(l.b)(b.a,{defaultValue:"testdto",values:[{label:"TestDto",value:"testdto"},{label:"FurAppService",value:"furAppService"}],mdxType:"Tabs"},Object(l.b)(c.a,{value:"testdto",mdxType:"TabItem"},Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,7,10}","{1,7,10}":!0}),'using System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Application\n{\n public class TestDto\n {\n [Range(10, 20, ErrorMessage = "Id \u53ea\u80fd\u5728 10-20 \u533a\u95f4\u53d6\u503c")]\n public int Id { get; set; }\n\n [Required(ErrorMessage = "\u5fc5\u586b"), MinLength(3, ErrorMessage = "\u5b57\u7b26\u4e32\u957f\u5ea6\u4e0d\u80fd\u5c11\u4e8e3\u4f4d")]\n public string Name { get; set; }\n }\n}\n'))),Object(l.b)(c.a,{value:"furAppService",mdxType:"TabItem"},Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{12,22}","{12,22}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n /// \n /// \u503c\u7c7b\u578b\u9a8c\u8bc1\n /// \n /// \n /// \n public int Get(int id)\n {\n return id;\n }\n\n /// \n /// \u5bf9\u8c61\u7c7b\u578b\u9a8c\u8bc1\n /// \n /// \n /// \n public TestDto Post(TestDto testDto)\n {\n return testDto;\n }\n }\n}\n')))),Object(l.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(l.b)("img",{src:Object(r.a)("img/sjyz1.gif")}),Object(l.b)("h3",{id:"853-\u517c\u5bb9-mvc-\u590d\u6742\u9a8c\u8bc1"},"8.5.3 \u517c\u5bb9 ",Object(l.b)("inlineCode",{parentName:"h3"},"Mvc")," \u590d\u6742\u9a8c\u8bc1"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,6,14-22}","{2,6,14-22}":!0}),'using System.Collections.Generic;\nusing System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Application\n{\n public class TestDto : IValidatableObject\n {\n [Range(10, 20, ErrorMessage = "Id \u53ea\u80fd\u5728 10-20 \u533a\u95f4\u53d6\u503c")]\n public int Id { get; set; }\n\n [Required(ErrorMessage = "\u5fc5\u586b"), MinLength(3, ErrorMessage = "\u5b57\u7b26\u4e32\u957f\u5ea6\u4e0d\u80fd\u5c11\u4e8e3\u4f4d")]\n public string Name { get; set; }\n\n public IEnumerable Validate(ValidationContext validationContext)\n {\n if (Name.StartsWith("Fur"))\n {\n yield return new ValidationResult(\n "\u4e0d\u80fd\u4ee5 Fur \u5f00\u5934"\n , new[] { nameof(Name) }\n );\n }\n }\n }\n}\n')),Object(l.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(l.b)("img",{src:Object(r.a)("img/sjyz2.gif")}),Object(l.b)("h2",{id:"86-\u624b\u52a8\u9a8c\u8bc1"},"8.6 \u624b\u52a8\u9a8c\u8bc1"),Object(l.b)("h3",{id:"871-\u9a8c\u8bc1\u6a21\u578b"},"8.7.1 \u9a8c\u8bc1\u6a21\u578b"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,11}","{1,11}":!0}),"using Fur.DataValidation;\nusing Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [NonValidation] // \u8df3\u8fc7\u5168\u5c40\u9a8c\u8bc1\n public DataValidationResult Post(TestDto testDto)\n {\n return testDto.TryValidate();\n }\n }\n}\n")),Object(l.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(l.b)("img",{src:Object(r.a)("img/sjyz3.gif")}),Object(l.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"note")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"\u652f\u6301 ",Object(l.b)("strong",{parentName:"p"},Object(l.b)("inlineCode",{parentName:"strong"},"Mvc"))," \u5185\u7f6e\u7684\u7279\u6027\u9a8c\u8bc1\u3001\u5c5e\u6027\u9a8c\u8bc1\u53ca\u590d\u6742\u7684 ",Object(l.b)("strong",{parentName:"p"},Object(l.b)("inlineCode",{parentName:"strong"},"IValidatableObject"))," \u9a8c\u8bc1\u3002"))),Object(l.b)("h3",{id:"872-validationtypes-\u5e38\u89c1\u9a8c\u8bc1"},"8.7.2 ",Object(l.b)("inlineCode",{parentName:"h3"},"ValidationTypes")," \u5e38\u89c1\u9a8c\u8bc1"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u5185\u7f6e\u4e86\u5f88\u591a\u5e38\u7528\u7c7b\u578b\u7684\u6570\u636e\u9a8c\u8bc1\uff0c\u5305\u62ec\uff1a"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Required"),"\uff1a\u975e\u7a7a\u3001\u975e Null \u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Numeric"),"\uff1a\u6570\u503c\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PositiveNumber"),"\uff1a\u6b63\u6570\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"NegativeNumber"),"\uff1a\u8d1f\u6570\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Integer"),"\uff1a\u6574\u6570\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Money"),"\uff1a\u91d1\u94b1\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Date"),"\uff1a\u65e5\u671f\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Time"),"\uff1a\u65f6\u95f4\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"IDCard"),"\uff1a\u8eab\u4efd\u8bc1\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PostCode"),"\uff1a\u90ae\u7f16\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PhoneNumber"),"\uff1a\u624b\u673a\u53f7\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Telephone"),"\uff1a\u56fa\u8bdd\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PhoneOrTelNumber"),"\uff1a\u624b\u673a\u6216\u56fa\u8bdd\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"EmailAddress"),"\uff1a\u90ae\u4ef6\u5730\u5740\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Url"),"\uff1a\u7f51\u5740\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Color"),"\uff1a\u989c\u8272\u503c\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Chinese"),"\uff1a\u4e2d\u6587\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"IPv4"),"\uff1aIPv4 \u5730\u5740\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"IPv6"),"\uff1aIPv6 \u5730\u5740\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Age"),"\uff1a\u5e74\u9f84\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"ChineseName"),"\uff1a\u4e2d\u6587\u540d\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"EnglishName"),"\uff1a\u82f1\u6587\u540d\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Capital"),"\uff1a\u7eaf\u5927\u5199\u82f1\u6587\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Lowercase"),"\uff1a\u7eaf\u5c0f\u5199\u82f1\u6587\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Ascii"),"\uff1aAscii \u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Md5"),"\uff1aMd5 \u5b57\u7b26\u4e32\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Zip"),"\uff1a\u538b\u7f29\u5305\u683c\u5f0f\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Image"),"\uff1a\u56fe\u7247\u683c\u5f0f\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Document"),"\uff1a\u6587\u6863\u683c\u5f0f\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"MP3"),"\uff1aMp3 \u683c\u5f0f\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Flash"),"\uff1aFlash \u683c\u5f0f\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Video"),"\uff1a\u89c6\u9891\u6587\u4ef6\u683c\u5f0f\u7c7b\u578b")),Object(l.b)("p",null,Object(l.b)("strong",{parentName:"p"},"\u4f7f\u7528\u793a\u4f8b")),Object(l.b)(b.a,{defaultValue:"dglx",values:[{label:"\u5355\u4e2a\u7c7b\u578b\u9a8c\u8bc1",value:"dglx"},{label:"\u591a\u4e2a\u7ec4\u5408\u7c7b\u578b\u9a8c\u8bc1",value:"zhlx"}],mdxType:"Tabs"},Object(l.b)(c.a,{value:"dglx",mdxType:"TabItem"},Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// \u9a8c\u8bc1\u5fc5\u586b\n"".TryValidate(ValidationTypes.Required); // => false\n\n// \u9a8c\u8bc1\u4e2d\u6587\n"\u6211\u53eb MonK".TryValidate(ValidationTypes.Chinese); // => false\n\n// \u9a8c\u8bc1\u6570\u503c\n2.TryValidate(ValidationTypes.Numeric); // => true\n\n// \u9a8c\u8bc1\u6574\u6570\ntrue.TryValidate(ValidationTypes.Integer); // => false\n\n// \u9a8c\u8bc1\u90ae\u7bb1\n"monksoul@outlook.com".TryValidate(ValidationTypes.EmailAddress); // => true\n\n// \u9a8c\u8bc1\u8d1f\u6570\n2.0m.TryValidate(ValidationTypes.NegativeNumber); // => false\n\n// \u81ea\u5b9a\u4e49\u6b63\u5219\u8868\u8fbe\u5f0f\u9a8c\u8bc1\n"Fur".TryValidate("/^Fur$"); // => true\n'))),Object(l.b)(c.a,{value:"zhlx",mdxType:"TabItem"},Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// \u9a8c\u8bc1\u6570\u503c\u7c7b\u578b\u4e14\u662f\u6574\u6570\n"20".TryValidate(ValidationTypes.Numeric, ValidationTypes.Integer); // => true\n\n// \u9a8c\u8bc1\u65f6\u65e5\u671f\u6216\u65f6\u95f4\u683c\u5f0f\n"2020-05-20".TryValidate(ValidationOptions.AtLeastOne, ValidationTypes.Date, ValidationTypes.Time); // => true\n"23:45:20".TryValidate(ValidationOptions.AtLeastOne, ValidationTypes.Date, ValidationTypes.Time); // => true\n\n')))),Object(l.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"\u53ef\u901a\u8fc7\u8bbe\u7f6e ",Object(l.b)("inlineCode",{parentName:"p"},"TryValidate([ValidationOptions], params object[] validationTypes)")," \u65b9\u6cd5\u7684 ",Object(l.b)("inlineCode",{parentName:"p"},"ValidationOptions")," \u53c2\u6570\u914d\u7f6e\u9a8c\u8bc1\u903b\u8f91\uff0c\u5982\uff1a",Object(l.b)("strong",{parentName:"p"},Object(l.b)("inlineCode",{parentName:"strong"},"\u540c\u65f6\u6210\u7acb"))," \u6216 ",Object(l.b)("strong",{parentName:"p"},Object(l.b)("inlineCode",{parentName:"strong"},"\u53ea\u8981\u4e00\u4e2a\u6210\u7acb"))," \u5373\u53ef\u9a8c\u8bc1\u901a\u8fc7"))),Object(l.b)("h3",{id:"873-datavalidation-\u7279\u6027"},"8.7.3 ",Object(l.b)("inlineCode",{parentName:"h3"},"[DataValidation]")," \u7279\u6027"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u8fd8\u63d0\u4f9b\u4e86 ",Object(l.b)("inlineCode",{parentName:"p"},"[DataValidation]")," \u7279\u6027\u65b9\u4fbf\u5728\u6a21\u578b\u53c2\u6570\u4e2d\u4f7f\u7528 ",Object(l.b)("inlineCode",{parentName:"p"},"ValidationTypes")," \u5e38\u89c1\u9a8c\u8bc1\u6216\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u3002"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,7,10,14,17,20}","{1,7,10,14,17,20}":!0}),'using Fur.DataValidation;\n\nnamespace Fur.Application\n{\n public class TestDto\n {\n [DataValidation(ValidationTypes.Integer)]\n public int Id { get; set; }\n\n [DataValidation(ValidationTypes.Numeric, ValidationTypes.Integer)]\n public int Cost { get; set; }\n\n [DataValidation(ValidationOptions.AtLeastOne, ValidationTypes.Chinese, ValidationTypes.Date)]\n public string Name { get; set; }\n\n // \u53ef\u4ee5\u548cMvc\u7279\u6027\u5171\u5b58\n [Required, DataValidation(ValidationTypes.Age)]\n public int Age { get; set; }\n\n [DataValidation(ValidationTypes.IDCard, ErrorMessage = "\u81ea\u5b9a\u4e49\u8eab\u4efd\u8bc1\u63d0\u793a\u6d88\u606f")]\n public string IDCard { get; set; }\n }\n}\n')),Object(l.b)("h2",{id:"87-nonvalidation-\u8df3\u8fc7\u9a8c\u8bc1"},"8.7 ",Object(l.b)("inlineCode",{parentName:"h2"},"[NonValidation]")," \u8df3\u8fc7\u9a8c\u8bc1"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u5bf9\u8c61\u6a21\u578b\u8df3\u8fc7\u9a8c\u8bc1\u7279\u6027 ",Object(l.b)("inlineCode",{parentName:"p"},"[NonValidation]"),"\uff0c\u652f\u6301\u5728 ",Object(l.b)("inlineCode",{parentName:"p"},"\u63a7\u5236\u5668"),"\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"\u52a8\u4f5c\u65b9\u6cd5"),"\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"\u7c7b")," \u4e2d\u4f7f\u7528\u3002"),Object(l.b)("p",null,"\u4e00\u65e6\u8d34\u4e86\u6b64\u7279\u6027\uff0c\u90a3\u4e48\u5c06\u4e0d\u4f1a\u6267\u884c\u9a8c\u8bc1\u64cd\u4f5c\u3002"),Object(l.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"note")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},Object(l.b)("strong",{parentName:"p"},Object(l.b)("inlineCode",{parentName:"strong"},"[NonValidation]"))," \u53ea\u5bf9\u5bf9\u8c61\u7c7b\u578b\u6709\u6548\uff0c\u503c\u7c7b\u578b\u65e0\u6548\u3002"))),Object(l.b)("h2",{id:"88-\u9ad8\u7ea7\u81ea\u5b9a\u4e49\u64cd\u4f5c"},"8.8 \u9ad8\u7ea7\u81ea\u5b9a\u4e49\u64cd\u4f5c"),Object(l.b)("h3",{id:"881-\u81ea\u5b9a\u4e49-validationtypes-\u7c7b\u578b"},"8.8.1 \u81ea\u5b9a\u4e49 ",Object(l.b)("inlineCode",{parentName:"h3"},"ValidationTypes")," \u7c7b\u578b"),Object(l.b)("p",null,"\u9664\u4e86 ",Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u5185\u7f6e\u7684\u9a8c\u8bc1\u7c7b\u578b\u4ee5\u5916\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u8fd8\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u7684\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u7c7b\u578b\u673a\u5236\u3002"),Object(l.b)("p",null,"\u5b9e\u73b0\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u7c7b\u578b\u5fc5\u987b\u9075\u5faa\u4ee5\u4e0b\u914d\u7f6e\uff1a"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u9a8c\u8bc1\u7c7b\u578b\u5fc5\u987b\u65f6\u516c\u5f00\u4e14\u65f6 ",Object(l.b)("inlineCode",{parentName:"li"},"Enum")," \u679a\u4e3e\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},"\u679a\u4e3e\u7c7b\u578b\u5fc5\u987b\u8d34\u6709 ",Object(l.b)("inlineCode",{parentName:"li"},"[ValidationType]")," \u7279\u6027"),Object(l.b)("li",{parentName:"ul"},"\u679a\u4e3e\u4e2d\u6bcf\u4e00\u9879\u5fc5\u987b\u8d34\u6709 ",Object(l.b)("inlineCode",{parentName:"li"},"[ValidationItemMetadata]")," \u7279\u6027")),Object(l.b)("p",null,Object(l.b)("strong",{parentName:"p"},"\u5982"),"\uff1a"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,6,12,18}","{1,6,12,18}":!0}),'using Fur.DataValidation;\nusing System.Text.RegularExpressions;\n\nnamespace Fur.Application\n{\n [ValidationType]\n public enum MyValidationTypes\n {\n /// \n /// \u5f3a\u5bc6\u7801\u7c7b\u578b\n /// \n [ValidationItemMetadata(@"^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$", "\u5fc5\u987b\u987b\u5305\u542b\u5927\u5c0f\u5199\u5b57\u6bcd\u548c\u6570\u5b57\u7684\u7ec4\u5408\uff0c\u4e0d\u80fd\u4f7f\u7528\u7279\u6b8a\u5b57\u7b26\uff0c\u957f\u5ea6\u57288-10\u4e4b\u95f4")]\n StrongPassword,\n\n /// \n /// \u4ee5 Fur \u5b57\u7b26\u4e32\u5f00\u5934\uff0c\u5ffd\u7565\u5927\u5c0f\u5199\n /// \n [ValidationItemMetadata(@"^(fur).*", "\u9ed8\u8ba4\u63d0\u793a\uff1a\u5fc5\u987b\u4ee5Fur\u5b57\u7b26\u4e32\u5f00\u5934\uff0c\u5ffd\u7565\u5927\u5c0f\u5199", RegexOptions.IgnoreCase)]\n StartWithFurString\n }\n}\n\n')),Object(l.b)("p",null,Object(l.b)("strong",{parentName:"p"},"\u4f7f\u7528")),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u624b\u52a8\u4f7f\u7528")),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'"q1w2e3".TryValidate(MyValidationTypes.StrongPassword); // => false\n\n"furos".TryValidate(MyValidationTypes.StartWithFurString); // => true\n')),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"[DataValidation]")," \u4e2d\u4f7f\u7528")),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"[DataValidation(MyValidationTypes.StrongPassword)]\npublic string Password { get; set; }\n")),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u591a\u4e2a\u81ea\u5b9a\u4e49\u7c7b\u578b\u6df7\u7528")),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'"Q1w2e3r4t5!*".TryValidate(MyValidationTypes.StrongPassword, ValidationTypes.Required); // => true\n')),Object(l.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"\u81ea\u5b9a\u4e49\u7684\u9a8c\u8bc1\u7c7b\u578b\u4e5f\u8981\u4fdd\u8bc1\u540d\u79f0\u5168\u5c40\u552f\u4e00\uff0c\u4e5f\u5c31\u662f\u591a\u4e2a\u9a8c\u8bc1\u7c7b\u578b\u4e0d\u80fd\u51fa\u73b0\u4e00\u6837\u7684\u540d\u5b57\u3002"))),Object(l.b)("h3",{id:"882-\u81ea\u5b9a\u4e49-validationtypes-\u5931\u8d25\u6d88\u606f"},"8.8.2 \u81ea\u5b9a\u4e49 ",Object(l.b)("inlineCode",{parentName:"h3"},"ValidationTypes")," \u5931\u8d25\u6d88\u606f"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u5185\u7f6e\u7684 ",Object(l.b)("inlineCode",{parentName:"p"},"ValidationTypes")," \u5df2\u6709\u9ed8\u8ba4\u7684\u5931\u8d25\u6d88\u606f\uff1a"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Required"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is required.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Numeric"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a numeric type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PositiveNumber"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a positive number type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"NegativeNumber"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a negative number type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Integer"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a integer type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Money"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a money type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Date"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a date type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Time"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a time type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"IDCard"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a idcard type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PostCode"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a postcode type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PhoneNumber"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a phone number type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Telephone"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a telephone type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PhoneOrTelNumber"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a phone number or telephone type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"EmailAddress"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a email address type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Url"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a url address type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Color"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a color type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Chinese"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a chinese type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"IPv4"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a IPv4 type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"IPv6"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a IPv6 type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Age"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a age type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"ChineseName"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a chinese name type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"EnglishName"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a english name type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Capital"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a capital type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Lowercase"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a lowercase type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Ascii"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a ascii type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Md5"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a md5 type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Zip"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a zip type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Image"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a image type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Document"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a document type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"MP3"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a mp3 type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Flash"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a flash type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Video"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a video type."))),Object(l.b)("p",null,"\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u7ee7\u627f ",Object(l.b)("inlineCode",{parentName:"p"},"IValidationMessageTypeProvider")," \u9a8c\u8bc1\u6d88\u606f\u63d0\u4f9b\u5668\u7c7b\u578b\uff0c\u6216\u901a\u8fc7 ",Object(l.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u914d\u7f6e\u3002"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},Object(l.b)("inlineCode",{parentName:"strong"},"[ValidationMessageType]"))," \u65b9\u5f0f")),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,9,12,15,19,22}","{5,9,12,15,19,22}":!0}),'using Fur.DataValidation;\n\nnamespace Fur.Application\n{\n [ValidationMessageType]\n public enum MyValidationMessageType\n {\n // \u4fee\u6539\u5185\u7f6e\u9a8c\u8bc1\u7c7b\u578b\u9a8c\u8bc1\u5931\u8d25\u6d88\u606f\n [ValidationMessage("\u503c\u4e0d\u80fd\u4e3a\u7a7a\u6216Null")]\n Required,\n\n [ValidationMessage("\u5fc5\u987b\u662f\u6570\u503c\u7c7b\u578b")]\n Numeric,\n\n [ValidationMessage("\u5fc5\u987b\u662f\u6b63\u6570")]\n PositiveNumber,\n\n // \u4fee\u6539\u81ea\u5b9a\u4e49\u7c7b\u578b\u9a8c\u8bc1\u5931\u8d25\u6d88\u606f\n [ValidationMessage("\u5bc6\u7801\u592a\u7b80\u5355\u4e86")]\n StrongPassword,\n\n [ValidationMessage("\u5fc5\u987b\u4ee5 Fur \u5f00\u5934")]\n StartWithFurString\n }\n}\n')),Object(l.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"\u9664\u4e86\u8d34 ",Object(l.b)("inlineCode",{parentName:"p"},"[ValidationMessageType]")," \u7279\u6027\u5916\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u8fd8\u63d0\u4f9b\u4e86 ",Object(l.b)("inlineCode",{parentName:"p"},"IValidationMessageTypeProvider")," \u65b9\u5f0f\u67e5\u627e\u9a8c\u8bc1\u6d88\u606f\u7c7b\u578b\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(l.b)("pre",{parentName:"div"},Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,6,8-12}","{1,6,8-12}":!0}),"using Fur.DataValidation;\nusing System;\n\nnamespace Fur.Application\n{\n public class MyValidationTypeMessageProvider : IValidationMessageTypeProvider\n {\n public Type[] Definitions => new[]\n {\n typeof(MyValidationMessageType),\n typeof(MyValidationMessageType2)\n };\n }\n}\n")),Object(l.b)("p",{parentName:"div"},"\u6ce8\u518c\u9a8c\u8bc1\u6d88\u606f\u63d0\u4f9b\u5668"),Object(l.b)("pre",{parentName:"div"},Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{11} title="Fur.Web.Core\\FurWebCoreStartup.cs"',"{11}":!0,title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddControllers()\n .AddDataValidation();\n }\n }\n}\n")))),Object(l.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(l.b)("img",{src:Object(r.a)("img/sjyz4.png")}),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},Object(l.b)("inlineCode",{parentName:"strong"},"appsettings.json")," \u65b9\u5f0f"))),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:'{2-11} title="Fur.Web.Entry/appsettings.json"',"{2-11}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "ValidationTypeMessageSettings": {\n "Definitions": [\n ["Required", "\u503c\u4e0d\u80fd\u4e3a\u7a7a\u6216Null"],\n ["Numeric", "\u5fc5\u987b\u662f\u6570\u503c\u7c7b\u578b"],\n\n ["StrongPassword", "\u5bc6\u7801\u592a\u7b80\u5355\u4e86!!!"]\n ]\n }\n }\n}\n')),Object(l.b)("div",{className:"admonition admonition-important alert alert--info"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"important")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},Object(l.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u4e2d\u76f8\u540c\u7684 ",Object(l.b)("inlineCode",{parentName:"p"},"Key")," \u6216\u8986\u76d6 ",Object(l.b)("inlineCode",{parentName:"p"},"IValidationMessageTypeProvider")," \u63d0\u4f9b\u76f8\u540c ",Object(l.b)("inlineCode",{parentName:"p"},"Key")," \u7684\u503c\u3002"))),Object(l.b)("h4",{id:"\u9519\u8bef\u6d88\u606f\u67e5\u627e\u4f18\u5148\u7ea7"},"\u9519\u8bef\u6d88\u606f\u67e5\u627e\u4f18\u5148\u7ea7"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"DefaultErrorMessage")," -> ",Object(l.b)("inlineCode",{parentName:"p"},"IValidationMessageTypeProvider")," -> ",Object(l.b)("inlineCode",{parentName:"p"},"appsettings.json")," (",Object(l.b)("strong",{parentName:"p"},"\u4f4e -> \u9ad8"),")"),Object(l.b)("h2",{id:"89-\u6a21\u578b\u9a8c\u8bc1\u8303\u56f4"},"8.9 \u6a21\u578b\u9a8c\u8bc1\u8303\u56f4"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u591a\u79cd\u6a21\u578b\u9a8c\u8bc1\u8303\u56f4\u8bbe\u7f6e\uff1a"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u5168\u5c40\u9a8c\u8bc1\uff08\u9ed8\u8ba4\uff09"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"[NonValidation]")," \u8df3\u8fc7\u9a8c\u8bc1"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"[TypeFilter(typeof(DataValidationFilter))]")," \u5c40\u90e8\u9a8c\u8bc1"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"[ApiController]")," \u63a7\u5236\u5668\u8303\u56f4\u9a8c\u8bc1")),Object(l.b)("h3",{id:"891-\u5168\u5c40\u9a8c\u8bc1"},"8.9.1 \u5168\u5c40\u9a8c\u8bc1"),Object(l.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u901a\u8fc7 ",Object(l.b)("inlineCode",{parentName:"p"},".AddDataValidation()")," \u6ce8\u518c\u6570\u636e\u9a8c\u8bc1\u670d\u52a1\u5df2\u7ecf\u542f\u7528\u4e86\u5168\u5c40\u9a8c\u8bc1\uff0c\u5982\u82e5\u4e0d\u60f3\u542f\u7528\u5168\u5c40\u9a8c\u8bc1\uff0c\u5219\u4f20\u5165 ",Object(l.b)("inlineCode",{parentName:"p"},"false")," \u5373\u53ef\uff0c\u5982\uff1a",Object(l.b)("inlineCode",{parentName:"p"},".AddDataValidation(false)"),"\u3002"),Object(l.b)("h3",{id:"892-nonvalidation-\u8df3\u8fc7\u9a8c\u8bc1"},"8.9.2 ",Object(l.b)("inlineCode",{parentName:"h3"},"[NonValidation]")," \u8df3\u8fc7\u9a8c\u8bc1"),Object(l.b)("p",null,"\u53ef\u901a\u8fc7 ",Object(l.b)("inlineCode",{parentName:"p"},"[NonValidation]")," \u8d34\u5728 ",Object(l.b)("inlineCode",{parentName:"p"},"\u63a7\u5236\u5668"),"\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"\u52a8\u4f5c\u65b9\u6cd5"),"\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"\u7c7b")," \u4e2d\u8df3\u8fc7\u5168\u5c40\u9a8c\u8bc1\u6216\u4e0d\u9700\u8981\u9a8c\u8bc1"),Object(l.b)("h3",{id:"893-typefiltertypeofdatavalidationfilter-\u5c40\u90e8\u9a8c\u8bc1"},"8.9.3 ",Object(l.b)("inlineCode",{parentName:"h3"},"[TypeFilter(typeof(DataValidationFilter))]")," \u5c40\u90e8\u9a8c\u8bc1"),Object(l.b)("p",null,"\u6211\u4eec\u4e5f\u53ef\u4ee5\u65e0\u9700\u6ce8\u518c ",Object(l.b)("inlineCode",{parentName:"p"},".AddDataValidation()")," \u670d\u52a1\uff0c\u76f4\u63a5\u5728 ",Object(l.b)("inlineCode",{parentName:"p"},"\u52a8\u4f5c\u65b9\u6cd5")," \u4e0a\u8d34 ",Object(l.b)("inlineCode",{parentName:"p"},"[TypeFilter(typeof(DataValidationFilter))]")," \u53ef\u542f\u7528\u5c40\u90e8\u9a8c\u8bc1\u3002\u5982\uff1a"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,3,9}","{1,3,9}":!0}),"using Fur.DataValidation;\nusing Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [TypeFilter(typeof(DataValidationFilter))]\n public TestDto Post(TestDto testDto)\n {\n return testDto;\n }\n }\n}\n")),Object(l.b)("h3",{id:"894-apicontroller-\u63a7\u5236\u5668\u8303\u56f4\u9a8c\u8bc1"},"8.9.4 ",Object(l.b)("inlineCode",{parentName:"h3"},"[ApiController]")," \u63a7\u5236\u5668\u8303\u56f4\u9a8c\u8bc1"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"[ApiController]")," \u662f ",Object(l.b)("inlineCode",{parentName:"p"},"Mvc")," \u63d0\u4f9b\u7684\u63a7\u5236\u5668\u8303\u56f4\uff08\u542b\u6240\u6709\u52a8\u4f5c\u65b9\u6cd5\uff09\u7684\u9a8c\u8bc1\u3002"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5}","{1,5}":!0}),"using Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [ApiController]\n public class MvcController : Controller\n {\n public IActionResult Index()\n {\n return View();\n }\n }\n}\n")),Object(l.b)("h2",{id:"810-miniprofiler-\u67e5\u770b"},"8.10 ",Object(l.b)("inlineCode",{parentName:"h2"},"MiniProfiler")," \u67e5\u770b"),Object(l.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(l.b)("img",{src:Object(r.a)("img/sjyz5.png")}),Object(l.b)("h2",{id:"810-\u591a\u8bed\u8a00\u652f\u6301"},"8.10 \u591a\u8bed\u8a00\u652f\u6301"),Object(l.b)("p",null,"\u6587\u6863\u6574\u7406\u4e2d..."),Object(l.b)("h2",{id:"811-\u9a8c\u8bc1\u6a21\u578b\u63d0\u4f9b\u5668"},"8.11 \u9a8c\u8bc1\u6a21\u578b\u63d0\u4f9b\u5668"),Object(l.b)("p",null,"\u6587\u6863\u6574\u7406\u4e2d..."),Object(l.b)("h2",{id:"812-\u53cd\u9988\u4e0e\u5efa\u8bae"},"8.12 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(l.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(l.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/17256d0f.c1719a38.js b/handbook/build/17256d0f.c1719a38.js new file mode 100644 index 00000000000..30273fef326 --- /dev/null +++ b/handbook/build/17256d0f.c1719a38.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{142:function(e,t,n){"use strict";n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return u}));var a=n(0),i=n.n(a);function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e){for(var t=1;t=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var o=i.a.createContext({}),p=function(e){var t=i.a.useContext(o),n=t;return e&&(n="function"==typeof e?e(t):b(b({},t),e)),n},s=function(e){var t=p(e.components);return i.a.createElement(o.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return i.a.createElement(i.a.Fragment,{},t)}},m=i.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,l=e.originalType,r=e.parentName,o=c(e,["components","mdxType","originalType","parentName"]),s=p(n),m=a,u=s["".concat(r,".").concat(m)]||s[m]||d[m]||l;return n?i.a.createElement(u,b(b({ref:t},o),{},{components:n})):i.a.createElement(u,b({ref:t},o))}));function u(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var l=n.length,r=new Array(l);r[0]=m;var b={};for(var c in t)hasOwnProperty.call(t,c)&&(b[c]=t[c]);b.originalType=e,b.mdxType="string"==typeof e?e:a,r[1]=b;for(var o=2;oMvc \u7279\u6027\u65b9\u5f0f",id:"832-mvc-\u7279\u6027\u65b9\u5f0f",children:[]}]},{value:"8.4 DataValidation \u9a8c\u8bc1 \ud83e\udd17",id:"84-datavalidation-\u9a8c\u8bc1-",children:[{value:"8.4.1 DataValidation \u4f18\u70b9",id:"841-datavalidation-\u4f18\u70b9",children:[]}]},{value:"8.5 DataValidation \u4f7f\u7528",id:"85-datavalidation-\u4f7f\u7528",children:[{value:"8.5.1 \u6ce8\u518c\u9a8c\u8bc1\u670d\u52a1",id:"851-\u6ce8\u518c\u9a8c\u8bc1\u670d\u52a1",children:[]},{value:"8.5.2 \u517c\u5bb9 Mvc \u7279\u6027\u9a8c\u8bc1",id:"852-\u517c\u5bb9-mvc-\u7279\u6027\u9a8c\u8bc1",children:[]},{value:"8.5.3 \u517c\u5bb9 Mvc \u590d\u6742\u9a8c\u8bc1",id:"853-\u517c\u5bb9-mvc-\u590d\u6742\u9a8c\u8bc1",children:[]}]},{value:"8.6 \u624b\u52a8\u9a8c\u8bc1",id:"86-\u624b\u52a8\u9a8c\u8bc1",children:[{value:"8.7.1 \u9a8c\u8bc1\u6a21\u578b",id:"871-\u9a8c\u8bc1\u6a21\u578b",children:[]},{value:"8.7.2 ValidationTypes \u5e38\u89c1\u9a8c\u8bc1",id:"872-validationtypes-\u5e38\u89c1\u9a8c\u8bc1",children:[]},{value:"8.7.3 [DataValidation] \u7279\u6027",id:"873-datavalidation-\u7279\u6027",children:[]}]},{value:"8.7 [NonValidation] \u8df3\u8fc7\u9a8c\u8bc1",id:"87-nonvalidation-\u8df3\u8fc7\u9a8c\u8bc1",children:[]},{value:"8.8 \u9ad8\u7ea7\u81ea\u5b9a\u4e49\u64cd\u4f5c",id:"88-\u9ad8\u7ea7\u81ea\u5b9a\u4e49\u64cd\u4f5c",children:[{value:"8.8.1 \u81ea\u5b9a\u4e49 ValidationTypes \u7c7b\u578b",id:"881-\u81ea\u5b9a\u4e49-validationtypes-\u7c7b\u578b",children:[]},{value:"8.8.2 \u81ea\u5b9a\u4e49 ValidationTypes \u5931\u8d25\u6d88\u606f",id:"882-\u81ea\u5b9a\u4e49-validationtypes-\u5931\u8d25\u6d88\u606f",children:[]}]},{value:"8.9 \u6a21\u578b\u9a8c\u8bc1\u8303\u56f4",id:"89-\u6a21\u578b\u9a8c\u8bc1\u8303\u56f4",children:[{value:"8.9.1 \u5168\u5c40\u9a8c\u8bc1",id:"891-\u5168\u5c40\u9a8c\u8bc1",children:[]},{value:"8.9.2 [NonValidation] \u8df3\u8fc7\u9a8c\u8bc1",id:"892-nonvalidation-\u8df3\u8fc7\u9a8c\u8bc1",children:[]},{value:"8.9.3 [TypeFilter(typeof(DataValidationFilter))] \u5c40\u90e8\u9a8c\u8bc1",id:"893-typefiltertypeofdatavalidationfilter-\u5c40\u90e8\u9a8c\u8bc1",children:[]},{value:"8.9.4 [ApiController] \u63a7\u5236\u5668\u8303\u56f4\u9a8c\u8bc1",id:"894-apicontroller-\u63a7\u5236\u5668\u8303\u56f4\u9a8c\u8bc1",children:[]}]},{value:"8.10 MiniProfiler \u67e5\u770b",id:"810-miniprofiler-\u67e5\u770b",children:[]},{value:"8.10 \u591a\u8bed\u8a00\u652f\u6301",id:"810-\u591a\u8bed\u8a00\u652f\u6301",children:[]},{value:"8.11 \u9a8c\u8bc1\u6a21\u578b\u63d0\u4f9b\u5668",id:"811-\u9a8c\u8bc1\u6a21\u578b\u63d0\u4f9b\u5668",children:[]},{value:"8.12 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"812-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],d={rightToc:s};function m(e){var t=e.components,n=Object(i.a)(e,["components"]);return Object(l.b)("wrapper",Object(a.a)({},d,n,{components:t,mdxType:"MDXLayout"}),Object(l.b)("h2",{id:"81-\u5173\u4e8e\u6570\u636e\u6821\u9a8c"},"8.1 \u5173\u4e8e\u6570\u636e\u6821\u9a8c"),Object(l.b)("p",null,"\u6570\u636e\u6821\u9a8c\u5b57\u9762\u4e0a\u7684\u610f\u601d\u5c31\u662f\u5bf9\u4f7f\u7528\u8005\u63d0\u4ea4\u8fc7\u6765\u7684\u6570\u636e\u8fdb\u884c\u5408\u6cd5\u6027\u9a8c\u8bc1\u3002\u5728\u4e00\u5957\u5b8c\u5584\u7684\u5e94\u7528\u7cfb\u7edf\u4e2d\uff0c\u6570\u636e\u6709\u6548\u6027\u6821\u9a8c\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u4e1a\u52a1\u5904\u7406\u7b2c\u4e00\u9053\u5173\u5361\u3002"),Object(l.b)("h2",{id:"82-\u6570\u636e\u6821\u9a8c\u7684\u597d\u5904"},"8.2 \u6570\u636e\u6821\u9a8c\u7684\u597d\u5904"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u8fc7\u6ee4\u4e0d\u5b89\u5168\u6570\u636e\uff0c\u63d0\u9ad8\u7cfb\u7edf\u7684\u5b89\u5168\u6027"),Object(l.b)("li",{parentName:"ul"},"\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u4e1a\u52a1\u5f02\u5e38\u5904\u7406\uff0c\u63d0\u9ad8\u7cfb\u7edf\u7684\u54cd\u5e94\u901f\u5ea6"),Object(l.b)("li",{parentName:"ul"},"\u5927\u5927\u63d0\u9ad8\u7cfb\u7edf\u7a33\u5b9a\u6027"),Object(l.b)("li",{parentName:"ul"},"\u5927\u6570\u636e\u5e76\u53d1\u65f6\u8d77\u7740\u4e00\u5b9a\u7684\u7f13\u51b2\u4f5c\u7528")),Object(l.b)("h2",{id:"83-\u6570\u636e\u6821\u9a8c\u65b9\u5f0f"},"8.3 \u6570\u636e\u6821\u9a8c\u65b9\u5f0f"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u4f20\u7edf\u65b9\u5f0f\uff0c\u5728\u4e1a\u52a1\u4ee3\u7801\u4e4b\u524d\u624b\u52a8\u9a8c\u8bc1"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Mvc")," \u7279\u6027\u65b9\u5f0f\uff0c",Object(l.b)("inlineCode",{parentName:"li"},"Mvc")," \u5185\u7f6e\u7684 ",Object(l.b)("inlineCode",{parentName:"li"},"DataAnnotations")," \u65b9\u5f0f"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"\u63a8\u8350\u65b9\u5f0f"),"\uff0c",Object(l.b)("inlineCode",{parentName:"li"},"Fur")," \u6846\u67b6\u5185\u7f6e\u7684 ",Object(l.b)("inlineCode",{parentName:"li"},"DataValidation")," \u9a8c\u8bc1"),Object(l.b)("li",{parentName:"ul"},"\u5176\u4ed6\u65b9\u5f0f\uff0c\u4f7f\u7528\u7b2c\u4e09\u65b9\u9a8c\u8bc1\u5e93\uff0c\u5982 ",Object(l.b)("inlineCode",{parentName:"li"},"FluentValidation"))),Object(l.b)("h3",{id:"831-\u4f20\u7edf\u65b9\u5f0f"},"8.3.1 \u4f20\u7edf\u65b9\u5f0f"),Object(l.b)("p",null,"\u5728\u5f88\u591a\u8001\u9879\u76ee\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u770b\u5230\u8fd9\u6837\u7684\u4ee3\u7801\uff1a"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{4,9,14}","{4,9,14}":!0}),'public bool Insert(Person person)\n{\n // \u9a8c\u8bc1\u53c2\u6570\n if(string.IsNullOrEmty(person.Name))\n {\n throw new System.Exception("\u540d\u5b57\u4e0d\u80fd\u4e3a\u7a7a");\n }\n\n if(person.Age < 18)\n {\n throw new System.Exception("\u5e74\u9f84\u4e0d\u80fd\u5c0f\u4e8e 18 \u5c81");\n }\n\n if(!person.Password.Equals(person.ConfirmPassword)\n {\n throw new System.Exception("\u4e24\u6b21\u5bc6\u7801\u4e0d\u4e00\u81f4");\n }\n\n // \u4e1a\u52a1\u4ee3\u7801\n _repository.Insert(person.Adapt());\n\n // ...\n}\n')),Object(l.b)("p",null,"\u4ece\u4e0a\u9762\u7684\u4ee3\u7801\u770b\u8d77\u6765\uff0c\u4f3c\u4e4e\u6ca1\u6709\u4ec0\u4e48\u4e0d\u59a5\uff0c\u4f46\u662f\u4ece\u4e00\u4e2a\u7a0b\u5e8f\u53ef\u7ef4\u62a4\u6027\u6765\u8bf4\uff0c\u8fd9\u662f\u4e00\u4e2a\u7cdf\u7cd5\u7684\u4ee3\u7801\uff0c\u56e0\u4e3a\u8be5\u4e1a\u52a1\u4ee3\u7801\u4e2d",Object(l.b)("strong",{parentName:"p"},"\u5305\u542b\u4e86\u592a\u591a\u4e0e\u4e1a\u52a1\u65e0\u5173\u7684\u6570\u636e\u9a8c\u8bc1"),"\u3002"),Object(l.b)("p",null,"\u8bd5\u60f3\u4e00\u4e0b\uff0c\u5982\u679c\u8fd9\u4e2a ",Object(l.b)("inlineCode",{parentName:"p"},"Person")," \u6709 \u51e0\u5341\u4e2a\u53c2\u6570\u90fd\u9700\u8981\u9a8c\u8bc1\u5462\uff1f\u53ef\u60f3\u800c\u77e5\uff0c\u8fd9\u662f\u4e00\u4e2a\u5e9e\u5927\u7684\u4e1a\u52a1\u4ee3\u7801\u3002"),Object(l.b)("p",null,"\u518d\u8005\uff0c\u5982\u679c\u5176\u4ed6\u5730\u65b9\u4e5f\u9700\u8981\u7528\u5230\u8fd9\u4e2a ",Object(l.b)("inlineCode",{parentName:"p"},"Person")," \u7c7b\u9a8c\u8bc1\u5462\uff1f\u90a3\u4ee3\u7801\u597d\u6bd4\u8001\u9f20\u5543\u8fc7\u7684\u9762\u5305\u5c51\u4e00\u6837\uff0c\u5230\u5904\u90fd\u662f\u3002"),Object(l.b)("p",null,"\u5982\u6b64\u5f97\u77e5\uff0c\u8fd9\u6837\u7684\u65b9\u5f0f\u662f\u6781\u5176\u4e0d\u63a8\u8350\u7684\uff0c",Object(l.b)("strong",{parentName:"p"},"\u4e0d\u4f46\u6c61\u67d3\u4e86\u4e1a\u52a1\u4ee3\u7801\uff0c\u4e5f\u7834\u574f\u4e86\u4e1a\u52a1\u804c\u8d23\u5355\u4e00\u6027\u539f\u7406\uff0c\u4e5f\u8ba9\u9a8c\u8bc1\u903b\u8f91\u65e0\u6cd5\u5b9e\u73b0\u901a\u7528\uff0c\u540e\u7eed\u7ef4\u62a4\u96be\u5ea6\u5927\u5927\u5347\u7ea7"),"\u3002"),Object(l.b)("h3",{id:"832-mvc-\u7279\u6027\u65b9\u5f0f"},"8.3.2 ",Object(l.b)("inlineCode",{parentName:"h3"},"Mvc")," \u7279\u6027\u65b9\u5f0f"),Object(l.b)("p",null,"\u5728 ",Object(l.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u4e2d\uff0c\u5fae\u8f6f\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u5168\u65b0\u7684 ",Object(l.b)("inlineCode",{parentName:"p"},"\u7279\u6027")," \u9a8c\u8bc1\u65b9\u5f0f\uff0c\u53ef\u901a\u8fc7\u5bf9\u5bf9\u8c61\u8d34\u7279\u6027\u5b9e\u73b0\u6570\u636e\u9a8c\u8bc1\u3002\u8fd9\u79cd\u65b9\u5f0f\u6709\u6548\u7684\u5c06\u6570\u636e\u6821\u9a8c\u548c\u4e1a\u52a1\u4ee3\u7801\u5265\u79bb\u5f00\u6765\uff0c\u800c\u4e14\u5bb9\u6613\u4f7f\u7528\u548c\u62d3\u5c55\u3002"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"\u5728\u6a21\u578b\u4e2d\u9a8c\u8bc1"))),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,7-8,11-12}","{1,7-8,11-12}":!0}),"using System.ComponentModel.DataAnnotations;\n\nnamespace Hoa.Application.Authorization.Dtos\n{\n public class SignInInput\n {\n [Required] // \u5fc5\u586b\u9a8c\u8bc1\n [MinLength(4)] // \u6700\u5c0f\u957f\u5ea6\u9a8c\u8bc1\n public string Account { get; set; }\n\n [Required] // \u5fc5\u586b\u9a8c\u8bc1\n [MaxLength(32)] // \u6700\u5927\u957f\u5ea6\u9a8c\u8bc1\n public string Password { get; set; }\n }\n}\n")),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"\u5728\u53c2\u6570\u4e2d\u9a8c\u8bc1"))),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2-3,8-9,12-13}","{2-3,8-9,12-13}":!0}),'public void CheckMethodParameterValid(\n [Required] // \u5fc5\u586b\u9a8c\u8bc1\n [MinLength(4)] // \u6700\u5c0f\u957f\u5ea6\u9a8c\u8bc1\n string name,\n\n int age,\n\n [Required] // \u5fc5\u586b\u9a8c\u8bc1\n [RegularExpression("[a-zA-Z0-9_]{8,30}") // \u6b63\u5219\u8868\u8fbe\u5f0f\u9a8c\u8bc1\n string password,\n\n [Required] // \u5fc5\u586b\u9a8c\u8bc1\n [RegularExpression("[a-zA-Z0-9_]{8,30}") // \u6b63\u5219\u8868\u8fbe\u5f0f\u9a8c\u8bc1\n string confirmPassword\n)\n{\n // TODO\n}\n')),Object(l.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5c0f\u63d0\u9192")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"\u5982\u679c\u51fd\u6570\u7684\u53c2\u6570\u5927\u4e8e\u6216\u7b49\u4e8e 3 \u4e2a\uff0c\u5efa\u8bae\u62bd\u79bb\u51fa\u6a21\u578b\u7c7b\uff0c\u4e5f\u5c31\u662f\u4e0d\u5efa\u8bae\u4e0a\u9762\u7684\u65b9\u5f0f\u3002"))),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"\u81ea\u5b9a\u4e49\u7279\u6027\u9a8c\u8bc1"))),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,13-24}","{1,13-24}":!0}),'public class ClassicMovieAttribute : ValidationAttribute\n{\n public ClassicMovieAttribute(int year)\n {\n Year = year;\n }\n\n public int Year { get; }\n\n public string GetErrorMessage() =>\n $"Classic movies must have a release year no later than {Year}.";\n\n protected override ValidationResult IsValid(object value, ValidationContext validationContext)\n {\n var movie = (Movie)validationContext.ObjectInstance;\n var releaseYear = ((DateTime)value).Year;\n\n if (movie.Genre == Genre.Classic && releaseYear > Year)\n {\n return new ValidationResult(GetErrorMessage());\n }\n\n return ValidationResult.Success;\n }\n}\n')),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},Object(l.b)("inlineCode",{parentName:"strong"},"IValidatableObject")," \u590d\u6742\u9a8c\u8bc1"))),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,3,10-19}","{1,3,10-19}":!0}),'using System.Collections.Generic;\n\npublic class DtoModel : IValidatableObject\n{\n [Required]\n [StringLength(100)]\n public string Title { get; set; }\n\n // \u4f60\u7684\u9a8c\u8bc1\u903b\u8f91\n public IEnumerable Validate(ValidationContext validationContext)\n {\n if (\u4f60\u7684\u903b\u8f91\u4ee3\u7801)\n {\n yield return new ValidationResult(\n "\u9519\u8bef\u6d88\u606f"\n ,new[] { nameof(Title) } // \u9a8c\u8bc1\u5931\u8d25\u7684\u5c5e\u6027\n );\n }\n }\n}\n')),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"Mvc")," \u7279\u6027\u65b9\u5f0f\u6781\u5927\u7684\u5c06\u4e1a\u52a1\u903b\u8f91\u548c\u9a8c\u8bc1\u8fdb\u884c\u4e86\u5265\u79bb\u548c\u89e3\u8026\uff0c\u800c\u4e14\u8fd8\u80fd\u5b9e\u73b0\u81ea\u5b9a\u4e49\u590d\u6742\u9a8c\u8bc1\u3002"),Object(l.b)("p",null,Object(l.b)("strong",{parentName:"p"},"\u4f46\u662f ",Object(l.b)("inlineCode",{parentName:"strong"},"Mvc")," \u7279\u6027\u9a8c\u8bc1\u65b9\u5f0f\u6709\u51e0\u4e2a\u660e\u663e\u7684\u7f3a\u70b9"),"\uff1a"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u53ea\u80fd\u5728 ",Object(l.b)("inlineCode",{parentName:"li"},"\u63a7\u5236\u5668")," \u4e2d\u7684 ",Object(l.b)("inlineCode",{parentName:"li"},"Action"),"\uff08\u52a8\u4f5c\u65b9\u6cd5\uff09\u4e2d\u4f7f\u7528"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"\u65e0\u6cd5\u5728\u4efb\u610f\u7c7b\u3001\u4efb\u610f\u65b9\u6cd5\u4e2d\u4f7f\u7528")),Object(l.b)("li",{parentName:"ul"},"\u5185\u7f6e\u7684\u9a8c\u8bc1\u7c7b\u578b\u975e\u5e38\u6709\u9650\uff0c\u4e14\u4e0d\u6613\u62d3\u5c55"),Object(l.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\u9a8c\u8bc1\u6d88\u606f\u540e\u671f\u914d\u7f6e")),Object(l.b)("p",null,"\u6240\u4ee5\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u4e86\u65b0\u7684\u9a8c\u8bc1\u5f15\u64ce ",Object(l.b)("inlineCode",{parentName:"p"},"DataValidation"),"\uff0c\u5728\u5b8c\u5168\u517c\u5bb9 ",Object(l.b)("inlineCode",{parentName:"p"},"Mvc")," \u5185\u7f6e\u9a8c\u8bc1\u7684\u540c\u65f6\u63d0\u4f9b\u4e86\u5927\u91cf\u5e38\u89c1\u9a8c\u8bc1\u3001\u590d\u6742\u9a8c\u8bc1\u3001\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u7b49\u80fd\u529b\u3002"),Object(l.b)("h2",{id:"84-datavalidation-\u9a8c\u8bc1-"},"8.4 ",Object(l.b)("inlineCode",{parentName:"h2"},"DataValidation")," \u9a8c\u8bc1 \ud83e\udd17"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"DataValidation")," \u662f ",Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u5168\u65b0\u7684\u9a8c\u8bc1\u65b9\u5f0f\uff0c\u5b8c\u5168\u517c\u5bb9 ",Object(l.b)("inlineCode",{parentName:"p"},"Mvc")," \u5185\u7f6e\u9a8c\u8bc1\uff0c\u5e76\u4e14\u8d4b\u4e88\u4e86\u8d85\u80fd\u3002"),Object(l.b)("h3",{id:"841-datavalidation-\u4f18\u70b9"},"8.4.1 ",Object(l.b)("inlineCode",{parentName:"h3"},"DataValidation")," \u4f18\u70b9"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"\u5b8c\u5168\u517c\u5bb9 ",Object(l.b)("inlineCode",{parentName:"strong"},"Mvc")," \u5185\u7f6e\u9a8c\u8bc1\u5f15\u64ce")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"\u5185\u7f6e\u5e38\u89c1\u9a8c\u8bc1\u7c7b\u578b\u53ca\u53ef\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u7c7b\u578b\u529f\u80fd")),Object(l.b)("li",{parentName:"ul"},"\u63d0\u4f9b\u5168\u5c40\u5bf9\u8c61\u62d3\u5c55\u9a8c\u8bc1\u65b9\u5f0f"),Object(l.b)("li",{parentName:"ul"},"\u652f\u6301\u9a8c\u8bc1\u6d88\u606f\u540e\u671f\u914d\u7f6e\uff0c\u652f\u6301\u5b9e\u65f6\u66f4\u65b0"),Object(l.b)("li",{parentName:"ul"},"\u652f\u6301\u5728\u4efb\u4f55\u7c7b\uff0c\u4efb\u4f55\u65b9\u6cd5\u3001\u4efb\u4f55\u4f4d\u7f6e\u5b9e\u73b0\u624b\u52a8\u9a8c\u8bc1\u3001\u7279\u6027\u65b9\u5f0f\u9a8c\u8bc1\u7b49"),Object(l.b)("li",{parentName:"ul"},"\u652f\u6301\u8bbe\u7f6e\u9a8c\u8bc1\u7ed3\u679c\u6a21\u578b")),Object(l.b)("h2",{id:"85-datavalidation-\u4f7f\u7528"},"8.5 ",Object(l.b)("inlineCode",{parentName:"h2"},"DataValidation")," \u4f7f\u7528"),Object(l.b)("h3",{id:"851-\u6ce8\u518c\u9a8c\u8bc1\u670d\u52a1"},"8.5.1 \u6ce8\u518c\u9a8c\u8bc1\u670d\u52a1"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{11} title="Fur.Web.Core\\FurWebCoreStartup.cs"',"{11}":!0,title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddControllers()\n .AddDataValidation();\n }\n }\n}\n")),Object(l.b)("div",{className:"admonition admonition-important alert alert--info"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},Object(l.b)("inlineCode",{parentName:"p"},".AddDataValidation()")," \u9700\u5728 ",Object(l.b)("inlineCode",{parentName:"p"},"services.AddControllers()")," \u4e4b\u540e\u6ce8\u518c\u3002"))),Object(l.b)("h3",{id:"852-\u517c\u5bb9-mvc-\u7279\u6027\u9a8c\u8bc1"},"8.5.2 \u517c\u5bb9 ",Object(l.b)("inlineCode",{parentName:"h3"},"Mvc")," \u7279\u6027\u9a8c\u8bc1"),Object(l.b)(b.a,{defaultValue:"testdto",values:[{label:"TestDto",value:"testdto"},{label:"FurAppService",value:"furAppService"}],mdxType:"Tabs"},Object(l.b)(c.a,{value:"testdto",mdxType:"TabItem"},Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,7,10}","{1,7,10}":!0}),'using System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Application\n{\n public class TestDto\n {\n [Range(10, 20, ErrorMessage = "Id \u53ea\u80fd\u5728 10-20 \u533a\u95f4\u53d6\u503c")]\n public int Id { get; set; }\n\n [Required(ErrorMessage = "\u5fc5\u586b"), MinLength(3, ErrorMessage = "\u5b57\u7b26\u4e32\u957f\u5ea6\u4e0d\u80fd\u5c11\u4e8e3\u4f4d")]\n public string Name { get; set; }\n }\n}\n'))),Object(l.b)(c.a,{value:"furAppService",mdxType:"TabItem"},Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{12,22}","{12,22}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n /// \n /// \u503c\u7c7b\u578b\u9a8c\u8bc1\n /// \n /// \n /// \n public int Get(int id)\n {\n return id;\n }\n\n /// \n /// \u5bf9\u8c61\u7c7b\u578b\u9a8c\u8bc1\n /// \n /// \n /// \n public TestDto Post(TestDto testDto)\n {\n return testDto;\n }\n }\n}\n')))),Object(l.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(l.b)("img",{src:Object(r.a)("img/sjyz1.gif")}),Object(l.b)("h3",{id:"853-\u517c\u5bb9-mvc-\u590d\u6742\u9a8c\u8bc1"},"8.5.3 \u517c\u5bb9 ",Object(l.b)("inlineCode",{parentName:"h3"},"Mvc")," \u590d\u6742\u9a8c\u8bc1"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,6,14-22}","{2,6,14-22}":!0}),'using System.Collections.Generic;\nusing System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Application\n{\n public class TestDto : IValidatableObject\n {\n [Range(10, 20, ErrorMessage = "Id \u53ea\u80fd\u5728 10-20 \u533a\u95f4\u53d6\u503c")]\n public int Id { get; set; }\n\n [Required(ErrorMessage = "\u5fc5\u586b"), MinLength(3, ErrorMessage = "\u5b57\u7b26\u4e32\u957f\u5ea6\u4e0d\u80fd\u5c11\u4e8e3\u4f4d")]\n public string Name { get; set; }\n\n public IEnumerable Validate(ValidationContext validationContext)\n {\n if (Name.StartsWith("Fur"))\n {\n yield return new ValidationResult(\n "\u4e0d\u80fd\u4ee5 Fur \u5f00\u5934"\n , new[] { nameof(Name) }\n );\n }\n }\n }\n}\n')),Object(l.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(l.b)("img",{src:Object(r.a)("img/sjyz2.gif")}),Object(l.b)("h2",{id:"86-\u624b\u52a8\u9a8c\u8bc1"},"8.6 \u624b\u52a8\u9a8c\u8bc1"),Object(l.b)("h3",{id:"871-\u9a8c\u8bc1\u6a21\u578b"},"8.7.1 \u9a8c\u8bc1\u6a21\u578b"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,11}","{1,11}":!0}),"using Fur.DataValidation;\nusing Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [NonValidation] // \u8df3\u8fc7\u5168\u5c40\u9a8c\u8bc1\n public DataValidationResult Post(TestDto testDto)\n {\n return testDto.TryValidate();\n }\n }\n}\n")),Object(l.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(l.b)("img",{src:Object(r.a)("img/sjyz3.gif")}),Object(l.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"note")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"\u652f\u6301 ",Object(l.b)("strong",{parentName:"p"},Object(l.b)("inlineCode",{parentName:"strong"},"Mvc"))," \u5185\u7f6e\u7684\u7279\u6027\u9a8c\u8bc1\u3001\u5c5e\u6027\u9a8c\u8bc1\u53ca\u590d\u6742\u7684 ",Object(l.b)("strong",{parentName:"p"},Object(l.b)("inlineCode",{parentName:"strong"},"IValidatableObject"))," \u9a8c\u8bc1\u3002"))),Object(l.b)("h3",{id:"872-validationtypes-\u5e38\u89c1\u9a8c\u8bc1"},"8.7.2 ",Object(l.b)("inlineCode",{parentName:"h3"},"ValidationTypes")," \u5e38\u89c1\u9a8c\u8bc1"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u5185\u7f6e\u4e86\u5f88\u591a\u5e38\u7528\u7c7b\u578b\u7684\u6570\u636e\u9a8c\u8bc1\uff0c\u5305\u62ec\uff1a"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Required"),"\uff1a\u975e\u7a7a\u3001\u975e Null \u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Numeric"),"\uff1a\u6570\u503c\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PositiveNumber"),"\uff1a\u6b63\u6570\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"NegativeNumber"),"\uff1a\u8d1f\u6570\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Integer"),"\uff1a\u6574\u6570\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Money"),"\uff1a\u91d1\u94b1\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Date"),"\uff1a\u65e5\u671f\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Time"),"\uff1a\u65f6\u95f4\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"IDCard"),"\uff1a\u8eab\u4efd\u8bc1\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PostCode"),"\uff1a\u90ae\u7f16\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PhoneNumber"),"\uff1a\u624b\u673a\u53f7\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Telephone"),"\uff1a\u56fa\u8bdd\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PhoneOrTelNumber"),"\uff1a\u624b\u673a\u6216\u56fa\u8bdd\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"EmailAddress"),"\uff1a\u90ae\u4ef6\u5730\u5740\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Url"),"\uff1a\u7f51\u5740\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Color"),"\uff1a\u989c\u8272\u503c\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Chinese"),"\uff1a\u4e2d\u6587\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"IPv4"),"\uff1aIPv4 \u5730\u5740\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"IPv6"),"\uff1aIPv6 \u5730\u5740\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Age"),"\uff1a\u5e74\u9f84\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"ChineseName"),"\uff1a\u4e2d\u6587\u540d\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"EnglishName"),"\uff1a\u82f1\u6587\u540d\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Capital"),"\uff1a\u7eaf\u5927\u5199\u82f1\u6587\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Lowercase"),"\uff1a\u7eaf\u5c0f\u5199\u82f1\u6587\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Ascii"),"\uff1aAscii \u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Md5"),"\uff1aMd5 \u5b57\u7b26\u4e32\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Zip"),"\uff1a\u538b\u7f29\u5305\u683c\u5f0f\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Image"),"\uff1a\u56fe\u7247\u683c\u5f0f\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Document"),"\uff1a\u6587\u6863\u683c\u5f0f\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"MP3"),"\uff1aMp3 \u683c\u5f0f\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Flash"),"\uff1aFlash \u683c\u5f0f\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Video"),"\uff1a\u89c6\u9891\u6587\u4ef6\u683c\u5f0f\u7c7b\u578b")),Object(l.b)("p",null,Object(l.b)("strong",{parentName:"p"},"\u4f7f\u7528\u793a\u4f8b")),Object(l.b)(b.a,{defaultValue:"dglx",values:[{label:"\u5355\u4e2a\u7c7b\u578b\u9a8c\u8bc1",value:"dglx"},{label:"\u591a\u4e2a\u7ec4\u5408\u7c7b\u578b\u9a8c\u8bc1",value:"zhlx"}],mdxType:"Tabs"},Object(l.b)(c.a,{value:"dglx",mdxType:"TabItem"},Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// \u9a8c\u8bc1\u5fc5\u586b\n"".TryValidate(ValidationTypes.Required); // => false\n\n// \u9a8c\u8bc1\u4e2d\u6587\n"\u6211\u53eb MonK".TryValidate(ValidationTypes.Chinese); // => false\n\n// \u9a8c\u8bc1\u6570\u503c\n2.TryValidate(ValidationTypes.Numeric); // => true\n\n// \u9a8c\u8bc1\u6574\u6570\ntrue.TryValidate(ValidationTypes.Integer); // => false\n\n// \u9a8c\u8bc1\u90ae\u7bb1\n"monksoul@outlook.com".TryValidate(ValidationTypes.EmailAddress); // => true\n\n// \u9a8c\u8bc1\u8d1f\u6570\n2.0m.TryValidate(ValidationTypes.NegativeNumber); // => false\n\n// \u81ea\u5b9a\u4e49\u6b63\u5219\u8868\u8fbe\u5f0f\u9a8c\u8bc1\n"Fur".TryValidate("/^Fur$"); // => true\n'))),Object(l.b)(c.a,{value:"zhlx",mdxType:"TabItem"},Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// \u9a8c\u8bc1\u6570\u503c\u7c7b\u578b\u4e14\u662f\u6574\u6570\n"20".TryValidate(ValidationTypes.Numeric, ValidationTypes.Integer); // => true\n\n// \u9a8c\u8bc1\u65f6\u65e5\u671f\u6216\u65f6\u95f4\u683c\u5f0f\n"2020-05-20".TryValidate(ValidationOptions.AtLeastOne, ValidationTypes.Date, ValidationTypes.Time); // => true\n"23:45:20".TryValidate(ValidationOptions.AtLeastOne, ValidationTypes.Date, ValidationTypes.Time); // => true\n\n')))),Object(l.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"\u53ef\u901a\u8fc7\u8bbe\u7f6e ",Object(l.b)("inlineCode",{parentName:"p"},"TryValidate([ValidationOptions], params object[] validationTypes)")," \u65b9\u6cd5\u7684 ",Object(l.b)("inlineCode",{parentName:"p"},"ValidationOptions")," \u53c2\u6570\u914d\u7f6e\u9a8c\u8bc1\u903b\u8f91\uff0c\u5982\uff1a",Object(l.b)("strong",{parentName:"p"},Object(l.b)("inlineCode",{parentName:"strong"},"\u540c\u65f6\u6210\u7acb"))," \u6216 ",Object(l.b)("strong",{parentName:"p"},Object(l.b)("inlineCode",{parentName:"strong"},"\u53ea\u8981\u4e00\u4e2a\u6210\u7acb"))," \u5373\u53ef\u9a8c\u8bc1\u901a\u8fc7"))),Object(l.b)("h3",{id:"873-datavalidation-\u7279\u6027"},"8.7.3 ",Object(l.b)("inlineCode",{parentName:"h3"},"[DataValidation]")," \u7279\u6027"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u8fd8\u63d0\u4f9b\u4e86 ",Object(l.b)("inlineCode",{parentName:"p"},"[DataValidation]")," \u7279\u6027\u65b9\u4fbf\u5728\u6a21\u578b\u53c2\u6570\u4e2d\u4f7f\u7528 ",Object(l.b)("inlineCode",{parentName:"p"},"ValidationTypes")," \u5e38\u89c1\u9a8c\u8bc1\u6216\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u3002"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,7,10,14,17,20}","{1,7,10,14,17,20}":!0}),'using Fur.DataValidation;\n\nnamespace Fur.Application\n{\n public class TestDto\n {\n [DataValidation(ValidationTypes.Integer)]\n public int Id { get; set; }\n\n [DataValidation(ValidationTypes.Numeric, ValidationTypes.Integer)]\n public int Cost { get; set; }\n\n [DataValidation(ValidationOptions.AtLeastOne, ValidationTypes.Chinese, ValidationTypes.Date)]\n public string Name { get; set; }\n\n // \u53ef\u4ee5\u548cMvc\u7279\u6027\u5171\u5b58\n [Required, DataValidation(ValidationTypes.Age)]\n public int Age { get; set; }\n\n [DataValidation(ValidationTypes.IDCard, ErrorMessage = "\u81ea\u5b9a\u4e49\u8eab\u4efd\u8bc1\u63d0\u793a\u6d88\u606f")]\n public string IDCard { get; set; }\n }\n}\n')),Object(l.b)("h2",{id:"87-nonvalidation-\u8df3\u8fc7\u9a8c\u8bc1"},"8.7 ",Object(l.b)("inlineCode",{parentName:"h2"},"[NonValidation]")," \u8df3\u8fc7\u9a8c\u8bc1"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u5bf9\u8c61\u6a21\u578b\u8df3\u8fc7\u9a8c\u8bc1\u7279\u6027 ",Object(l.b)("inlineCode",{parentName:"p"},"[NonValidation]"),"\uff0c\u652f\u6301\u5728 ",Object(l.b)("inlineCode",{parentName:"p"},"\u63a7\u5236\u5668"),"\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"\u52a8\u4f5c\u65b9\u6cd5"),"\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"\u7c7b")," \u4e2d\u4f7f\u7528\u3002"),Object(l.b)("p",null,"\u4e00\u65e6\u8d34\u4e86\u6b64\u7279\u6027\uff0c\u90a3\u4e48\u5c06\u4e0d\u4f1a\u6267\u884c\u9a8c\u8bc1\u64cd\u4f5c\u3002"),Object(l.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"note")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},Object(l.b)("strong",{parentName:"p"},Object(l.b)("inlineCode",{parentName:"strong"},"[NonValidation]"))," \u53ea\u5bf9\u5bf9\u8c61\u7c7b\u578b\u6709\u6548\uff0c\u503c\u7c7b\u578b\u65e0\u6548\u3002"))),Object(l.b)("h2",{id:"88-\u9ad8\u7ea7\u81ea\u5b9a\u4e49\u64cd\u4f5c"},"8.8 \u9ad8\u7ea7\u81ea\u5b9a\u4e49\u64cd\u4f5c"),Object(l.b)("h3",{id:"881-\u81ea\u5b9a\u4e49-validationtypes-\u7c7b\u578b"},"8.8.1 \u81ea\u5b9a\u4e49 ",Object(l.b)("inlineCode",{parentName:"h3"},"ValidationTypes")," \u7c7b\u578b"),Object(l.b)("p",null,"\u9664\u4e86 ",Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u5185\u7f6e\u7684\u9a8c\u8bc1\u7c7b\u578b\u4ee5\u5916\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u8fd8\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u7684\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u7c7b\u578b\u673a\u5236\u3002"),Object(l.b)("p",null,"\u5b9e\u73b0\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u7c7b\u578b\u5fc5\u987b\u9075\u5faa\u4ee5\u4e0b\u914d\u7f6e\uff1a"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u9a8c\u8bc1\u7c7b\u578b\u5fc5\u987b\u65f6\u516c\u5f00\u4e14\u65f6 ",Object(l.b)("inlineCode",{parentName:"li"},"Enum")," \u679a\u4e3e\u7c7b\u578b"),Object(l.b)("li",{parentName:"ul"},"\u679a\u4e3e\u7c7b\u578b\u5fc5\u987b\u8d34\u6709 ",Object(l.b)("inlineCode",{parentName:"li"},"[ValidationType]")," \u7279\u6027"),Object(l.b)("li",{parentName:"ul"},"\u679a\u4e3e\u4e2d\u6bcf\u4e00\u9879\u5fc5\u987b\u8d34\u6709 ",Object(l.b)("inlineCode",{parentName:"li"},"[ValidationItemMetadata]")," \u7279\u6027")),Object(l.b)("p",null,Object(l.b)("strong",{parentName:"p"},"\u5982"),"\uff1a"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,6,12,18}","{1,6,12,18}":!0}),'using Fur.DataValidation;\nusing System.Text.RegularExpressions;\n\nnamespace Fur.Application\n{\n [ValidationType]\n public enum MyValidationTypes\n {\n /// \n /// \u5f3a\u5bc6\u7801\u7c7b\u578b\n /// \n [ValidationItemMetadata(@"^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$", "\u5fc5\u987b\u987b\u5305\u542b\u5927\u5c0f\u5199\u5b57\u6bcd\u548c\u6570\u5b57\u7684\u7ec4\u5408\uff0c\u4e0d\u80fd\u4f7f\u7528\u7279\u6b8a\u5b57\u7b26\uff0c\u957f\u5ea6\u57288-10\u4e4b\u95f4")]\n StrongPassword,\n\n /// \n /// \u4ee5 Fur \u5b57\u7b26\u4e32\u5f00\u5934\uff0c\u5ffd\u7565\u5927\u5c0f\u5199\n /// \n [ValidationItemMetadata(@"^(fur).*", "\u9ed8\u8ba4\u63d0\u793a\uff1a\u5fc5\u987b\u4ee5Fur\u5b57\u7b26\u4e32\u5f00\u5934\uff0c\u5ffd\u7565\u5927\u5c0f\u5199", RegexOptions.IgnoreCase)]\n StartWithFurString\n }\n}\n\n')),Object(l.b)("p",null,Object(l.b)("strong",{parentName:"p"},"\u4f7f\u7528")),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u624b\u52a8\u4f7f\u7528")),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'"q1w2e3".TryValidate(MyValidationTypes.StrongPassword); // => false\n\n"furos".TryValidate(MyValidationTypes.StartWithFurString); // => true\n')),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"[DataValidation]")," \u4e2d\u4f7f\u7528")),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"[DataValidation(MyValidationTypes.StrongPassword)]\npublic string Password { get; set; }\n")),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u591a\u4e2a\u81ea\u5b9a\u4e49\u7c7b\u578b\u6df7\u7528")),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'"Q1w2e3r4t5!*".TryValidate(MyValidationTypes.StrongPassword, ValidationTypes.Required); // => true\n')),Object(l.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"\u81ea\u5b9a\u4e49\u7684\u9a8c\u8bc1\u7c7b\u578b\u4e5f\u8981\u4fdd\u8bc1\u540d\u79f0\u5168\u5c40\u552f\u4e00\uff0c\u4e5f\u5c31\u662f\u591a\u4e2a\u9a8c\u8bc1\u7c7b\u578b\u4e0d\u80fd\u51fa\u73b0\u4e00\u6837\u7684\u540d\u5b57\u3002"))),Object(l.b)("h3",{id:"882-\u81ea\u5b9a\u4e49-validationtypes-\u5931\u8d25\u6d88\u606f"},"8.8.2 \u81ea\u5b9a\u4e49 ",Object(l.b)("inlineCode",{parentName:"h3"},"ValidationTypes")," \u5931\u8d25\u6d88\u606f"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u5185\u7f6e\u7684 ",Object(l.b)("inlineCode",{parentName:"p"},"ValidationTypes")," \u5df2\u6709\u9ed8\u8ba4\u7684\u5931\u8d25\u6d88\u606f\uff1a"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Required"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is required.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Numeric"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a numeric type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PositiveNumber"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a positive number type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"NegativeNumber"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a negative number type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Integer"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a integer type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Money"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a money type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Date"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a date type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Time"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a time type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"IDCard"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a idcard type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PostCode"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a postcode type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PhoneNumber"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a phone number type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Telephone"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a telephone type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"PhoneOrTelNumber"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a phone number or telephone type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"EmailAddress"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a email address type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Url"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a url address type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Color"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a color type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Chinese"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a chinese type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"IPv4"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a IPv4 type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"IPv6"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a IPv6 type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Age"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a age type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"ChineseName"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a chinese name type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"EnglishName"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a english name type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Capital"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a capital type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Lowercase"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a lowercase type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Ascii"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a ascii type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Md5"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a md5 type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Zip"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a zip type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Image"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a image type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Document"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a document type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"MP3"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a mp3 type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Flash"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a flash type.")),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"Video"),"\uff1a",Object(l.b)("strong",{parentName:"li"},"The Value is not a video type."))),Object(l.b)("p",null,"\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u7ee7\u627f ",Object(l.b)("inlineCode",{parentName:"p"},"IValidationMessageTypeProvider")," \u9a8c\u8bc1\u6d88\u606f\u63d0\u4f9b\u5668\u7c7b\u578b\uff0c\u6216\u901a\u8fc7 ",Object(l.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u914d\u7f6e\u3002"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},Object(l.b)("inlineCode",{parentName:"strong"},"[ValidationMessageType]"))," \u65b9\u5f0f")),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,9,12,15,19,22}","{5,9,12,15,19,22}":!0}),'using Fur.DataValidation;\n\nnamespace Fur.Application\n{\n [ValidationMessageType]\n public enum MyValidationMessageType\n {\n // \u4fee\u6539\u5185\u7f6e\u9a8c\u8bc1\u7c7b\u578b\u9a8c\u8bc1\u5931\u8d25\u6d88\u606f\n [ValidationMessage("\u503c\u4e0d\u80fd\u4e3a\u7a7a\u6216Null")]\n Required,\n\n [ValidationMessage("\u5fc5\u987b\u662f\u6570\u503c\u7c7b\u578b")]\n Numeric,\n\n [ValidationMessage("\u5fc5\u987b\u662f\u6b63\u6570")]\n PositiveNumber,\n\n // \u4fee\u6539\u81ea\u5b9a\u4e49\u7c7b\u578b\u9a8c\u8bc1\u5931\u8d25\u6d88\u606f\n [ValidationMessage("\u5bc6\u7801\u592a\u7b80\u5355\u4e86")]\n StrongPassword,\n\n [ValidationMessage("\u5fc5\u987b\u4ee5 Fur \u5f00\u5934")]\n StartWithFurString\n }\n}\n')),Object(l.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"\u9664\u4e86\u8d34 ",Object(l.b)("inlineCode",{parentName:"p"},"[ValidationMessageType]")," \u7279\u6027\u5916\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u8fd8\u63d0\u4f9b\u4e86 ",Object(l.b)("inlineCode",{parentName:"p"},"IValidationMessageTypeProvider")," \u65b9\u5f0f\u67e5\u627e\u9a8c\u8bc1\u6d88\u606f\u7c7b\u578b\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(l.b)("pre",{parentName:"div"},Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,6,8-12}","{1,6,8-12}":!0}),"using Fur.DataValidation;\nusing System;\n\nnamespace Fur.Application\n{\n public class MyValidationTypeMessageProvider : IValidationMessageTypeProvider\n {\n public Type[] Definitions => new[]\n {\n typeof(MyValidationMessageType),\n typeof(MyValidationMessageType2)\n };\n }\n}\n")),Object(l.b)("p",{parentName:"div"},"\u6ce8\u518c\u9a8c\u8bc1\u6d88\u606f\u63d0\u4f9b\u5668"),Object(l.b)("pre",{parentName:"div"},Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{11} title="Fur.Web.Core\\FurWebCoreStartup.cs"',"{11}":!0,title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddControllers()\n .AddDataValidation();\n }\n }\n}\n")))),Object(l.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(l.b)("img",{src:Object(r.a)("img/sjyz4.png")}),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},Object(l.b)("inlineCode",{parentName:"strong"},"appsettings.json")," \u65b9\u5f0f"))),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:'{2-11} title="Fur.Web.Entry/appsettings.json"',"{2-11}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "ValidationTypeMessageSettings": {\n "Definitions": [\n ["Required", "\u503c\u4e0d\u80fd\u4e3a\u7a7a\u6216Null"],\n ["Numeric", "\u5fc5\u987b\u662f\u6570\u503c\u7c7b\u578b"],\n\n ["StrongPassword", "\u5bc6\u7801\u592a\u7b80\u5355\u4e86!!!"]\n ]\n }\n }\n}\n')),Object(l.b)("div",{className:"admonition admonition-important alert alert--info"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"important")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},Object(l.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u4e2d\u76f8\u540c\u7684 ",Object(l.b)("inlineCode",{parentName:"p"},"Key")," \u6216\u8986\u76d6 ",Object(l.b)("inlineCode",{parentName:"p"},"IValidationMessageTypeProvider")," \u63d0\u4f9b\u76f8\u540c ",Object(l.b)("inlineCode",{parentName:"p"},"Key")," \u7684\u503c\u3002"))),Object(l.b)("h4",{id:"\u9519\u8bef\u6d88\u606f\u67e5\u627e\u4f18\u5148\u7ea7"},"\u9519\u8bef\u6d88\u606f\u67e5\u627e\u4f18\u5148\u7ea7"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"DefaultErrorMessage")," -> ",Object(l.b)("inlineCode",{parentName:"p"},"IValidationMessageTypeProvider")," -> ",Object(l.b)("inlineCode",{parentName:"p"},"appsettings.json")," (",Object(l.b)("strong",{parentName:"p"},"\u4f4e -> \u9ad8"),")"),Object(l.b)("h2",{id:"89-\u6a21\u578b\u9a8c\u8bc1\u8303\u56f4"},"8.9 \u6a21\u578b\u9a8c\u8bc1\u8303\u56f4"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u591a\u79cd\u6a21\u578b\u9a8c\u8bc1\u8303\u56f4\u8bbe\u7f6e\uff1a"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u5168\u5c40\u9a8c\u8bc1\uff08\u9ed8\u8ba4\uff09"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"[NonValidation]")," \u8df3\u8fc7\u9a8c\u8bc1"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"[TypeFilter(typeof(DataValidationFilter))]")," \u5c40\u90e8\u9a8c\u8bc1"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"[ApiController]")," \u63a7\u5236\u5668\u8303\u56f4\u9a8c\u8bc1")),Object(l.b)("h3",{id:"891-\u5168\u5c40\u9a8c\u8bc1"},"8.9.1 \u5168\u5c40\u9a8c\u8bc1"),Object(l.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u901a\u8fc7 ",Object(l.b)("inlineCode",{parentName:"p"},".AddDataValidation()")," \u6ce8\u518c\u6570\u636e\u9a8c\u8bc1\u670d\u52a1\u5df2\u7ecf\u542f\u7528\u4e86\u5168\u5c40\u9a8c\u8bc1\uff0c\u5982\u82e5\u4e0d\u60f3\u542f\u7528\u5168\u5c40\u9a8c\u8bc1\uff0c\u5219\u4f20\u5165 ",Object(l.b)("inlineCode",{parentName:"p"},"false")," \u5373\u53ef\uff0c\u5982\uff1a",Object(l.b)("inlineCode",{parentName:"p"},".AddDataValidation(false)"),"\u3002"),Object(l.b)("h3",{id:"892-nonvalidation-\u8df3\u8fc7\u9a8c\u8bc1"},"8.9.2 ",Object(l.b)("inlineCode",{parentName:"h3"},"[NonValidation]")," \u8df3\u8fc7\u9a8c\u8bc1"),Object(l.b)("p",null,"\u53ef\u901a\u8fc7 ",Object(l.b)("inlineCode",{parentName:"p"},"[NonValidation]")," \u8d34\u5728 ",Object(l.b)("inlineCode",{parentName:"p"},"\u63a7\u5236\u5668"),"\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"\u52a8\u4f5c\u65b9\u6cd5"),"\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"\u7c7b")," \u4e2d\u8df3\u8fc7\u5168\u5c40\u9a8c\u8bc1\u6216\u4e0d\u9700\u8981\u9a8c\u8bc1"),Object(l.b)("h3",{id:"893-typefiltertypeofdatavalidationfilter-\u5c40\u90e8\u9a8c\u8bc1"},"8.9.3 ",Object(l.b)("inlineCode",{parentName:"h3"},"[TypeFilter(typeof(DataValidationFilter))]")," \u5c40\u90e8\u9a8c\u8bc1"),Object(l.b)("p",null,"\u6211\u4eec\u4e5f\u53ef\u4ee5\u65e0\u9700\u6ce8\u518c ",Object(l.b)("inlineCode",{parentName:"p"},".AddDataValidation()")," \u670d\u52a1\uff0c\u76f4\u63a5\u5728 ",Object(l.b)("inlineCode",{parentName:"p"},"\u52a8\u4f5c\u65b9\u6cd5")," \u4e0a\u8d34 ",Object(l.b)("inlineCode",{parentName:"p"},"[TypeFilter(typeof(DataValidationFilter))]")," \u53ef\u542f\u7528\u5c40\u90e8\u9a8c\u8bc1\u3002\u5982\uff1a"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,3,9}","{1,3,9}":!0}),"using Fur.DataValidation;\nusing Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [TypeFilter(typeof(DataValidationFilter))]\n public TestDto Post(TestDto testDto)\n {\n return testDto;\n }\n }\n}\n")),Object(l.b)("h3",{id:"894-apicontroller-\u63a7\u5236\u5668\u8303\u56f4\u9a8c\u8bc1"},"8.9.4 ",Object(l.b)("inlineCode",{parentName:"h3"},"[ApiController]")," \u63a7\u5236\u5668\u8303\u56f4\u9a8c\u8bc1"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"[ApiController]")," \u662f ",Object(l.b)("inlineCode",{parentName:"p"},"Mvc")," \u63d0\u4f9b\u7684\u63a7\u5236\u5668\u8303\u56f4\uff08\u542b\u6240\u6709\u52a8\u4f5c\u65b9\u6cd5\uff09\u7684\u9a8c\u8bc1\u3002"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5}","{1,5}":!0}),"using Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [ApiController]\n public class MvcController : Controller\n {\n public IActionResult Index()\n {\n return View();\n }\n }\n}\n")),Object(l.b)("h2",{id:"810-miniprofiler-\u67e5\u770b"},"8.10 ",Object(l.b)("inlineCode",{parentName:"h2"},"MiniProfiler")," \u67e5\u770b"),Object(l.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(l.b)("img",{src:Object(r.a)("img/sjyz5.png")}),Object(l.b)("h2",{id:"810-\u591a\u8bed\u8a00\u652f\u6301"},"8.10 \u591a\u8bed\u8a00\u652f\u6301"),Object(l.b)("p",null,"\u6587\u6863\u6574\u7406\u4e2d..."),Object(l.b)("h2",{id:"811-\u9a8c\u8bc1\u6a21\u578b\u63d0\u4f9b\u5668"},"8.11 \u9a8c\u8bc1\u6a21\u578b\u63d0\u4f9b\u5668"),Object(l.b)("p",null,"\u6587\u6863\u6574\u7406\u4e2d..."),Object(l.b)("h2",{id:"812-\u53cd\u9988\u4e0e\u5efa\u8bae"},"8.12 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(l.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(l.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/1761adf3.0eeb8b92.js b/handbook/build/1761adf3.0eeb8b92.js deleted file mode 100644 index dc4dea982a6..00000000000 --- a/handbook/build/1761adf3.0eeb8b92.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{142:function(e,t,n){"use strict";n.d(t,"a",(function(){return p})),n.d(t,"b",(function(){return O}));var r=n(0),a=n.n(r);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var s=a.a.createContext({}),b=function(e){var t=a.a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},p=function(e){var t=b(e.components);return a.a.createElement(s.Provider,{value:t},e.children)},u={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},d=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,l=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),p=b(n),d=r,O=p["".concat(l,".").concat(d)]||p[d]||u[d]||i;return n?a.a.createElement(O,c(c({ref:t},s),{},{components:n})):a.a.createElement(O,c({ref:t},s))}));function O(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,l=new Array(i);l[0]=d;var c={};for(var o in t)hasOwnProperty.call(t,o)&&(c[o]=t[o]);c.originalType=e,c.mdxType="string"==typeof e?e:r,l[1]=c;for(var s=2;sDataTable",id:"91322-\u8fd4\u56de-datatable",children:[]},{value:"9.13.2.3 \u8fd4\u56de DataSet",id:"91323-\u8fd4\u56de-dataset",children:[]},{value:"9.13.2.4 \u8fd4\u56de List<T>",id:"91324-\u8fd4\u56de-listt",children:[]},{value:"9.13.2.5 \u8fd4\u56de Tuple<T1,...T8>",id:"91325-\u8fd4\u56de-tuplet1t8",children:[]},{value:"9.13.2.6 \u8fd4\u56de \u5355\u884c\u5355\u5217 object",id:"91326-\u8fd4\u56de-\u5355\u884c\u5355\u5217-object",children:[]},{value:"9.13.2.7 \u8fd4\u56de \u5355\u884c\u5355\u5217 <T>",id:"91327-\u8fd4\u56de-\u5355\u884c\u5355\u5217-t",children:[]},{value:"9.13.2.8 \u6267\u884c\u4f46\u65e0\u8fd4\u56de",id:"91328-\u6267\u884c\u4f46\u65e0\u8fd4\u56de",children:[]}]},{value:"9.13.3 \u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b",id:"9133-\u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b",children:[{value:"9.13.3.1 \u521b\u5efa\u53c2\u6570\u6a21\u578b",id:"91331-\u521b\u5efa\u53c2\u6570\u6a21\u578b",children:[]},{value:"9.13.3.2 \u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b",id:"91332-\u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b",children:[]}]},{value:"9.13.3 \u5173\u4e8e [DbParameter]",id:"9133-\u5173\u4e8e-dbparameter",children:[]},{value:"9.13.4 \u5173\u4e8e ProcedureOutputResult",id:"9134-\u5173\u4e8e-procedureoutputresult",children:[]},{value:"9.13.5 \u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570",id:"9135-\u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570",children:[]},{value:"9.13.6 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9136-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],p={rightToc:b};function u(e){var t=e.components,n=Object(a.a)(e,["components"]);return Object(i.b)("wrapper",Object(r.a)({},p,n,{components:t,mdxType:"MDXLayout"}),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u6e29\u99a8\u63d0\u793a")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u63a8\u8350\u4f7f\u7528 \u300a",Object(i.b)("a",Object(r.a)({parentName:"p"},{href:"/docs/dbcontext-sql-proxy"}),"9.15 Sql \u9ad8\u7ea7\u4ee3\u7406"),"\u300b\u4ee3\u66ff\u672c\u7ae0\u8282\u529f\u80fd\u3002",Object(i.b)("inlineCode",{parentName:"p"},"Sql \u9ad8\u7ea7\u4ee3\u7406")," \u80fd\u591f\u63d0\u4f9b\u66f4\u5bb9\u6613\u4e14\u66f4\u6613\u7ef4\u62a4\u7684\u65b9\u5f0f\u3002"))),Object(i.b)("h2",{id:"9131-\u5173\u4e8e\u5b58\u50a8\u8fc7\u7a0b"},"9.13.1 \u5173\u4e8e\u5b58\u50a8\u8fc7\u7a0b"),Object(i.b)("p",null,"\u5f15\u7528\u767e\u5ea6\u767e\u79d1\uff1a"),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},"\u5b58\u50a8\u8fc7\u7a0b\uff08Stored Procedure\uff09\u662f\u5728\u5927\u578b\u6570\u636e\u5e93\u7cfb\u7edf\u4e2d\uff0c\u4e00\u7ec4\u4e3a\u4e86\u5b8c\u6210\u7279\u5b9a\u529f\u80fd\u7684 SQL \u8bed\u53e5\u96c6\uff0c\u5b83\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u4e00\u6b21\u7f16\u8bd1\u540e\u6c38\u4e45\u6709\u6548\uff0c\u7528\u6237\u901a\u8fc7\u6307\u5b9a\u5b58\u50a8\u8fc7\u7a0b\u7684\u540d\u5b57\u5e76\u7ed9\u51fa\u53c2\u6570\uff08\u5982\u679c\u8be5\u5b58\u50a8\u8fc7\u7a0b\u5e26\u6709\u53c2\u6570\uff09\u6765\u6267\u884c\u5b83\u3002"),Object(i.b)("p",{parentName:"blockquote"},"\u5b58\u50a8\u8fc7\u7a0b\u662f\u6570\u636e\u5e93\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u5bf9\u8c61\u3002\u5728\u6570\u636e\u91cf\u7279\u522b\u5e9e\u5927\u7684\u60c5\u51b5\u4e0b\u5229\u7528\u5b58\u50a8\u8fc7\u7a0b\u80fd\u8fbe\u5230\u500d\u901f\u7684\u6548\u7387\u63d0\u5347\u3002")),Object(i.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u5b58\u50a8\u8fc7\u7a0b\u5c31\u662f\u5173\u7cfb\u578b\u6570\u636e\u5e93\u4e2d\uff08",Object(i.b)("inlineCode",{parentName:"p"},"Sqlite")," \u9664\u5916\uff09\u4e2d\u7f16\u5199\u903b\u8f91\u7684\u51fd\u6570/\u65b9\u6cd5\uff0c\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5c06 ",Object(i.b)("inlineCode",{parentName:"p"},"sql")," \u7f16\u8bd1\u7f13\u5b58\u8d77\u6765\uff0c\u5927\u5927\u63d0\u9ad8\u5b58\u50a8\u8fc7\u7a0b\u7684\u6267\u884c\u6548\u7387\u3002"),Object(i.b)("p",null,Object(i.b)("strong",{parentName:"p"},"\u8fd9\u91cc\u4e0d\u8ba8\u8bba\u5b58\u50a8\u8fc7\u7a0b\u7684\u4f18\u7f3a\u70b9\u3002")),Object(i.b)("h3",{id:"91311-\u652f\u6301\u5b58\u50a8\u8fc7\u7a0b\u7684\u6570\u636e\u5e93"},"9.13.1.1 \u652f\u6301\u5b58\u50a8\u8fc7\u7a0b\u7684\u6570\u636e\u5e93"),Object(i.b)("table",null,Object(i.b)("thead",{parentName:"table"},Object(i.b)("tr",{parentName:"thead"},Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"SqlServer"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Sqlite"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Cosmos"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"InMemoryDatabase"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"MySql"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"PostgreSQL"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Oracle"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Firebird"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Dm"))),Object(i.b)("tbody",{parentName:"table"},Object(i.b)("tr",{parentName:"tbody"},Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null})),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null})),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714")))),Object(i.b)("h2",{id:"9132-\u5b58\u50a8\u8fc7\u7a0b\u4f7f\u7528"},"9.13.2 \u5b58\u50a8\u8fc7\u7a0b\u4f7f\u7528"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u63d0\u4f9b\u4e86\u591a\u79cd\u5b58\u50a8\u8fc7\u7a0b\u64cd\u4f5c\u65b9\u5f0f\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlRepository"),"\uff1a",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8\uff0c\u53ef\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"li"},"\u4f9d\u8d56\u6ce8\u5165")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlDispatchProxy"),"\uff1a",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u4ee3\u7406\u65b9\u5f0f\uff08\u9ad8\u7ea7\u7528\u6cd5\uff0c\u63a8\u8350\uff09"),Object(i.b)("li",{parentName:"ul"},"\u901a\u8fc7\u4efb\u610f\u5b9e\u4f53\u4ed3\u50a8\u64cd\u4f5c\uff1a",Object(i.b)("inlineCode",{parentName:"li"},"personRepository.SqlProcedureQuery(procName)")),Object(i.b)("li",{parentName:"ul"},"\u901a\u8fc7\u5b57\u7b26\u4e32\u62d3\u5c55\u65b9\u6cd5\uff1a",Object(i.b)("inlineCode",{parentName:"li"},"procName.SqlProcedureQuery()")),Object(i.b)("li",{parentName:"ul"},"\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"li"},"repository.Sql().SqlProcedureQuery()")," \u65b9\u5f0f")),Object(i.b)("h3",{id:"91321-\u521d\u59cb\u5316\u65b9\u5f0f"},"9.13.2.1 \u521d\u59cb\u5316\u65b9\u5f0f"),Object(i.b)(l.a,{defaultValue:"one",values:[{label:"ISqlRepository",value:"one"},{label:"ISqlDispatchProxy",value:"two"},{label:"\u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f",value:"three"},{label:"\u5b57\u7b26\u4e32\u62d3\u5c55\u65b9\u5f0f",value:"four"}],mdxType:"Tabs"},Object(i.b)(c.a,{value:"one",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,9-12}","{1,9-12}":!0}),"using Fur.DatabaseAccessor;\nusing Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [DynamicApiController]\n public class SqlService\n {\n private ISqlRepository _sqlRepository;\n public SqlService(ISqlRepository sqlRepository)\n {\n _sqlRepository = sqlRepository;\n }\n }\n}\n"))),Object(i.b)(c.a,{value:"two",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,7,9-10}","{2,7,9-10}":!0}),'using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing System.Collections.Generic;\n\nnamespace Fur.Application\n{\n public interface ISqlExecuteProxy : ISqlDispatchProxy\n {\n [SqlProcedure("proc_GetPersons")]\n List GetPersons(string keyword);\n }\n}\n')),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{9-12}","{9-12}":!0}),"using Fur.DatabaseAccessor;\nusing Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [DynamicApiController]\n public class SqlService\n {\n private ISqlExecuteProxy _sqlExecuteProxy;\n public SqlService(ISqlExecuteProxy sqlExecuteProxy)\n {\n _sqlExecuteProxy = sqlExecuteProxy;\n }\n }\n}\n"))),Object(i.b)(c.a,{value:"three",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'var persons = personRepository.SqlProcedureQuery("proc_GetPersons");\n'))),Object(i.b)(c.a,{value:"four",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'var persons = "proc_GetPersons".SqlProcedureQuery();\n')))),Object(i.b)("h3",{id:"91322-\u8fd4\u56de-datatable"},"9.13.2.2 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"DataTable")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar dataTable = _sqlRepository.SqlProcedureQuery("proc_GetPersons");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar dataTable = _sqlExecuteProxy.GetPersons(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar dataTable = _personRepository.SqlProcedureQuery("proc_GetPersons");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar dataTable = _repository.Sql().SqlProcedureQuery("proc_GetPersons");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\nvar dataTable = "proc_GetPersons".SqlProcedureQuery();\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h3",{id:"91323-\u8fd4\u56de-dataset"},"9.13.2.3 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"DataSet")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar dataSet = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar dataSet = _sqlExecuteProxy.GetPersons(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar dataSet = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar dataSet = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\nvar dataSet = "proc_GetPersons".SqlProcedureQueries();\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h3",{id:"91324-\u8fd4\u56de-listt"},"9.13.2.4 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"List")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar list = _sqlRepository.SqlProcedureQuery("proc_GetPersons");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar list = _sqlExecuteProxy.GetPersons(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar list = _personRepository.SqlProcedureQuery("proc_GetPersons");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar list = _repository.Sql().SqlProcedureQuery("proc_GetPersons");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\nvar list = "proc_GetPersons".SqlProcedureQuery();\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h3",{id:"91325-\u8fd4\u56de-tuplet1t8"},"9.13.2.5 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"Tuple")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u5927\u5927\u5229\u7528\u4e86 ",Object(i.b)("inlineCode",{parentName:"p"},"Tuple")," \u7684\u7279\u6027\uff0c\u5c06\u8fd4\u56de\u591a\u4e2a\u7ed3\u679c\u96c6\u8f6c\u6210 ",Object(i.b)("inlineCode",{parentName:"p"},"Tuple")," \u7c7b\u578b"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\n\n// \u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u96c6\nvar list1 = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e24\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2) = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e09\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3) = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u56db\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4) = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e94\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5) = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u516d\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6) = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e03\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7) = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u516b\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7, list8) = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// ==================================\n\n// ISqlDispatchProxy \u65b9\u5f0f\uff0c\u63a8\u8350\u65b9\u5f0f\uff0c\u81ea\u52a8\u5904\u7406\u591a\u4e2a\u7ed3\u679c\u96c6\n\n// \u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u96c6\nvar list1 = _sqlRepository.GetDatas();\n\n// \u8fd4\u56de\u4e24\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2) = _sqlRepository.GetDatas();\n\n// \u8fd4\u56de\u4e09\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3) = _sqlRepository.GetDatas();\n\n// \u8fd4\u56de\u56db\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4) = _sqlRepository.GetDatas();\n\n// \u8fd4\u56de\u4e94\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5) = _sqlRepository.GetDatas();\n\n// \u8fd4\u56de\u516d\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6) = _sqlRepository.GetDatas();\n\n// \u8fd4\u56de\u4e03\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7) = _sqlRepository.GetDatas();\n\n// \u8fd4\u56de\u516b\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7, list8) = _sqlRepository.GetDatas();\n\n// ==================================\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\n\n// \u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u96c6\nvar list1 = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e24\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2) = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e09\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3) = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u56db\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4) = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e94\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5) = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u516d\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6) = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e03\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7) = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u516b\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7, list8) = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// ==================================\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\n\n// \u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u96c6\nvar list1 = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e24\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2) = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e09\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3) = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u56db\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4) = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e94\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5) = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u516d\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6) = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e03\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7) = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u516b\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7, list8) = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// ==================================\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\n\n// \u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u96c6\nvar list1 = "proc_GetPersons".SqlProcedureQueries();\n\n// \u8fd4\u56de\u4e24\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2) = "proc_GetPersons".SqlProcedureQueries();\n\n// \u8fd4\u56de\u4e09\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3) = "proc_GetPersons".SqlProcedureQueries();\n\n// \u8fd4\u56de\u56db\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4) = "proc_GetPersons".SqlProcedureQueries();\n\n// \u8fd4\u56de\u4e94\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5) = "proc_GetPersons".SqlProcedureQueries();\n\n// \u8fd4\u56de\u516d\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6) = "proc_GetPersons".SqlProcedureQueries();\n\n// \u8fd4\u56de\u4e03\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7) = "proc_GetPersons".SqlProcedureQueries();\n\n// \u8fd4\u56de\u516b\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7, list8) = "proc_GetPersons".SqlProcedureQueries();\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h3",{id:"91326-\u8fd4\u56de-\u5355\u884c\u5355\u5217-object"},"9.13.2.6 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"\u5355\u884c\u5355\u5217 object")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar value = _sqlRepository.SqlProcedureScalar("proc_GetName");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar value = _sqlExecuteProxy.GetName(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar value = _personRepository.SqlProcedureScalar("proc_GetName");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar value = _repository.Sql().SqlProcedureScalar("proc_GetName");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\nvar value = "proc_GetName".SqlProcedureScalar();\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h3",{id:"91327-\u8fd4\u56de-\u5355\u884c\u5355\u5217-t"},"9.13.2.7 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"\u5355\u884c\u5355\u5217 ")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar value = _sqlRepository.SqlProcedureScalar("proc_GetName");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar value = _sqlExecuteProxy.GetName(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar value = _personRepository.SqlProcedureScalar("proc_GetName");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar value = _repository.Sql().SqlProcedureScalar("proc_GetName");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\nvar value = "proc_GetName".SqlProcedureScalar();\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h3",{id:"91328-\u6267\u884c\u4f46\u65e0\u8fd4\u56de"},"9.13.2.8 \u6267\u884c\u4f46\u65e0\u8fd4\u56de"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\n_sqlRepository.SqlProcedureNonQuery("proc_UpdateData");\n\n// ISqlDispatchProxy \u65b9\u5f0f\n_sqlExecuteProxy.UpdateData(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\n_personRepository.SqlProcedureNonQuery("proc_UpdateData");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\n_repository.Sql().SqlProcedureNonQuery("proc_UpdateData");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\n"proc_UpdateData".SqlProcedureNonQuery();\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h2",{id:"9133-\u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b"},"9.13.3 \u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b"),Object(i.b)("p",null,"\u5728\u5b58\u50a8\u8fc7\u7a0b\u4e2d\uff0c\u6709\u4e00\u79cd\u4f8b\u5b50\u975e\u5e38\u590d\u6742\uff0c\u90a3\u5c31\u662f\u65e2\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"INPUT")," \u53c2\u6570\uff0c\u53c8\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"OUTPUT")," \u53c2\u6570\uff0c\u8fd8\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"RETURN")," \u53c2\u6570\uff0c\u540c\u65f6\u8fd8\u8f93\u51fa \u7ed3\u679c\u96c6 \ud83d\udca5\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-sql",metastring:"{3,4,10-12,15-17,22}","{3,4,10-12,15-17,22}":!0}),"CREATE PROC PROC_Output\n @Id INT, // \u8f93\u5165\u53c2\u6570\n @Name NVARCHAR(32) OUTPUT, // \u8f93\u51fa\u53c2\u6570\uff0c\u8fd8\u5e26\u957f\u5ea6\n @Age INT OUTPUT // \u8f93\u51fa\u53c2\u6570\nAS\nBEGIN\n SET @Name = 'Fur Output';\n\n // \u8f93\u51fa\u7ed3\u679c\u96c6\n SELECT *\n FROM dbo.Test\n WHERE Id > @Id;\n\n // \u8f93\u51fa\u7ed3\u679c\u96c6\n SELECT TOP 10\n *\n FROM dbo.Test;\n\n SET @Age = 27;\n\n // \u5e26 RETURN \u8fd4\u56de\n RETURN 10;\nEND;\n")),Object(i.b)("h3",{id:"91331-\u521b\u5efa\u53c2\u6570\u6a21\u578b"},"9.13.3.1 \u521b\u5efa\u53c2\u6570\u6a21\u578b"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,10,13,16}","{1,10,13,16}":!0}),"using Fur.DatabaseAccessor;\nusing System.Data;\n\nnamespace Fur.Application\n{\n public class ProcOutputModel\n {\n public int Id { get; set; } // \u8f93\u5165\u53c2\u6570\n\n [DbParameter(ParameterDirection.Output, Size = 32)]\n public string Name { get; set; } // \u8f93\u51fa\u53c2\u6570\n\n [DbParameter(ParameterDirection.Output)]\n public int Age { get; set; } // \u8f93\u51fa\u53c2\u6570\n\n [DbParameter(ParameterDirection.ReturnValue)]\n public int ReturnValue { get; set; } // \u8fd4\u56de\u503c\n }\n}\n")),Object(i.b)("h3",{id:"91332-\u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b"},"9.13.3.2 \u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("strong",{parentName:"li"}," ",Object(i.b)("inlineCode",{parentName:"strong"},"DataSet")," ")," \u65b9\u5f0f")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nProcedureOutputResult result = _sqlRepository.SqlProcedureOutput("proc_Complex", new ProcOutputModel{});\n\n// ISqlDispatchProxy \u65b9\u5f0f\nProcedureOutputResult result = _sqlExecuteProxy.Complex(new ProcOutputModel{}); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nProcedureOutputResult result = _personRepository.SqlProcedureOutput("proc_Complex", new ProcOutputModel{});\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nProcedureOutputResult result = _repository.Sql().SqlProcedureOutput("proc_Complex", new ProcOutputModel{});\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\nProcedureOutputResult result = "proc_Complex".SqlProcedureOutput(new ProcOutputModel{});\n')),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// \u83b7\u53d6 OUTPUT \u53c2\u6570\u503c\nvar outputs = result.OutputValues;\n\n// \u83b7\u53d6 RETURN \u8fd4\u56de\u503c\nvar reval = result.ReturnValue;\n\n// \u83b7\u53d6\u8fd4\u56de\u7ed3\u679c\u96c6\nvar dataSet = result.Result;\n")),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Tuple")," \u65b9\u5f0f")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nProcedureOutputResult<(List, List)> result = _sqlRepository.SqlProcedureOutput<(List, List)>("proc_Complex", new ProcOutputModel{});\n\n// ISqlDispatchProxy \u65b9\u5f0f\nProcedureOutputResult<(List, List)> result = _sqlExecuteProxy.Complex(new ProcOutputModel{}); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nProcedureOutputResult<(List, List)> result = _personRepository.SqlProcedureOutput<(List, List)>("proc_Complex", new ProcOutputModel{});\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nProcedureOutputResult<(List, List)> result = _repository.Sql().SqlProcedureOutput<(List, List)>("proc_Complex", new ProcOutputModel{});\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\nProcedureOutputResult<(List, List)> result = "proc_Complex".SqlProcedureOutput<(List, List)>(new ProcOutputModel{});\n')),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// \u83b7\u53d6 OUTPUT \u53c2\u6570\u503c\nvar outputs = result.OutputValues;\n\n// \u83b7\u53d6 RETURN \u8fd4\u56de\u503c\nvar reval = result.ReturnValue;\n\n// \u83b7\u53d6\u8fd4\u56de\u7ed3\u679c\u96c6\nvar (list1,list2) = result.Result;\n")),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h2",{id:"9133-\u5173\u4e8e-dbparameter"},"9.13.3 \u5173\u4e8e ",Object(i.b)("inlineCode",{parentName:"h2"},"[DbParameter]")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"[DbParameter]")," \u7279\u6027\u662f\u7528\u6765\u6807\u6ce8 ",Object(i.b)("inlineCode",{parentName:"p"},"Sql"),"\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"\u51fd\u6570"),"\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"\u5b58\u50a8\u8fc7\u7a0b")," \u53c2\u6570\u7684\uff0c\u53ef\u914d\u7f6e\u5c5e\u6027\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Direction"),"\uff1a\u8bbe\u7f6e\u53c2\u6570\u65b9\u5411\uff0c",Object(i.b)("inlineCode",{parentName:"li"},"ParameterDirection")," \u679a\u4e3e\u7c7b\u578b\uff0c\u9ed8\u8ba4 ",Object(i.b)("inlineCode",{parentName:"li"},"ParameterDirection.Input")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"DbType"),"\uff1a\u8bbe\u7f6e\u53c2\u6570\u7c7b\u578b\uff0c",Object(i.b)("inlineCode",{parentName:"li"},"DbType")," \u679a\u4e3e\u7c7b\u578b\uff0c\u65e0\u9ed8\u8ba4"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Size"),"\uff1a\u8bbe\u7f6e\u53c2\u6570\u957f\u5ea6\u7684\uff0c",Object(i.b)("inlineCode",{parentName:"li"},"int")," \u7c7b\u578b")),Object(i.b)("p",null,"\u5176\u4e2d ",Object(i.b)("inlineCode",{parentName:"p"},"Direction")," \u5c5e\u6027\u662f\u9ed8\u8ba4\u6784\u9020\u51fd\u6570\u53c2\u6570\u3002"),Object(i.b)("h2",{id:"9134-\u5173\u4e8e-procedureoutputresult"},"9.13.4 \u5173\u4e8e ",Object(i.b)("inlineCode",{parentName:"h2"},"ProcedureOutputResult")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"ProcedureOutputResult")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"ProcedureOutputResult")," \u662f\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b\u6267\u884c\u8fd4\u56de\u6a21\u578b\u7c7b\uff0c\u6709\u4ee5\u4e0b\u5c5e\u6027\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"OutputValues"),"\uff1a\u591a\u4e2a\u8f93\u51fa\u503c\uff0c",Object(i.b)("inlineCode",{parentName:"li"},"ProcedureOutputValue")," \u7c7b\u578b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ReturnValue"),"\uff1a\u8fd4\u56de\u503c\uff0c",Object(i.b)("inlineCode",{parentName:"li"},"object")," \u7c7b\u578b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Result"),"\uff1a\u7ed3\u679c\u96c6\uff0c\u975e\u6cdb\u578b\u7248\u672c\u662f ",Object(i.b)("inlineCode",{parentName:"li"},"DataSet"),"\u7c7b\u578b\uff0c\u5426\u5219\u662f \u6cdb\u578b\u7c7b\u578b")),Object(i.b)("h2",{id:"9135-\u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570"},"9.13.5 \u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570"),Object(i.b)("p",null,"\u6240\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"sql")," \u53c2\u6570\u90fd\u652f\u6301\u56db\u79cd\u65b9\u5f0f\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"DbParameter[]"),"\uff1a\u6570\u7ec4\u7c7b\u578b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"new {}"),"\uff1a\u533f\u540d\u7c7b\u578b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"new Class{}"),"\uff1a\u5f3a\u7c7b\u578b\u7c7b\u578b\uff08\u652f\u6301\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570\uff09"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Dictionary")," \u7c7b\u578b")),Object(i.b)("h2",{id:"9136-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.13.6 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(r.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}u.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/1761adf3.37f331f5.js b/handbook/build/1761adf3.37f331f5.js new file mode 100644 index 00000000000..2cc3ada179b --- /dev/null +++ b/handbook/build/1761adf3.37f331f5.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{142:function(e,t,n){"use strict";n.d(t,"a",(function(){return p})),n.d(t,"b",(function(){return O}));var r=n(0),a=n.n(r);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var s=a.a.createContext({}),b=function(e){var t=a.a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},p=function(e){var t=b(e.components);return a.a.createElement(s.Provider,{value:t},e.children)},u={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},d=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,l=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),p=b(n),d=r,O=p["".concat(l,".").concat(d)]||p[d]||u[d]||i;return n?a.a.createElement(O,c(c({ref:t},s),{},{components:n})):a.a.createElement(O,c({ref:t},s))}));function O(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,l=new Array(i);l[0]=d;var c={};for(var o in t)hasOwnProperty.call(t,o)&&(c[o]=t[o]);c.originalType=e,c.mdxType="string"==typeof e?e:r,l[1]=c;for(var s=2;sDataTable",id:"91322-\u8fd4\u56de-datatable",children:[]},{value:"9.13.2.3 \u8fd4\u56de DataSet",id:"91323-\u8fd4\u56de-dataset",children:[]},{value:"9.13.2.4 \u8fd4\u56de List<T>",id:"91324-\u8fd4\u56de-listt",children:[]},{value:"9.13.2.5 \u8fd4\u56de Tuple<T1,...T8>",id:"91325-\u8fd4\u56de-tuplet1t8",children:[]},{value:"9.13.2.6 \u8fd4\u56de \u5355\u884c\u5355\u5217 object",id:"91326-\u8fd4\u56de-\u5355\u884c\u5355\u5217-object",children:[]},{value:"9.13.2.7 \u8fd4\u56de \u5355\u884c\u5355\u5217 <T>",id:"91327-\u8fd4\u56de-\u5355\u884c\u5355\u5217-t",children:[]},{value:"9.13.2.8 \u6267\u884c\u4f46\u65e0\u8fd4\u56de",id:"91328-\u6267\u884c\u4f46\u65e0\u8fd4\u56de",children:[]}]},{value:"9.13.3 \u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b",id:"9133-\u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b",children:[{value:"9.13.3.1 \u521b\u5efa\u53c2\u6570\u6a21\u578b",id:"91331-\u521b\u5efa\u53c2\u6570\u6a21\u578b",children:[]},{value:"9.13.3.2 \u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b",id:"91332-\u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b",children:[]}]},{value:"9.13.3 \u5173\u4e8e [DbParameter]",id:"9133-\u5173\u4e8e-dbparameter",children:[]},{value:"9.13.4 \u5173\u4e8e ProcedureOutputResult",id:"9134-\u5173\u4e8e-procedureoutputresult",children:[]},{value:"9.13.5 \u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570",id:"9135-\u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570",children:[]},{value:"9.13.6 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9136-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],p={rightToc:b};function u(e){var t=e.components,n=Object(a.a)(e,["components"]);return Object(i.b)("wrapper",Object(r.a)({},p,n,{components:t,mdxType:"MDXLayout"}),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u6e29\u99a8\u63d0\u793a")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u63a8\u8350\u4f7f\u7528 \u300a",Object(i.b)("a",Object(r.a)({parentName:"p"},{href:"/fur/docs/dbcontext-sql-proxy"}),"9.15 Sql \u9ad8\u7ea7\u4ee3\u7406"),"\u300b\u4ee3\u66ff\u672c\u7ae0\u8282\u529f\u80fd\u3002",Object(i.b)("inlineCode",{parentName:"p"},"Sql \u9ad8\u7ea7\u4ee3\u7406")," \u80fd\u591f\u63d0\u4f9b\u66f4\u5bb9\u6613\u4e14\u66f4\u6613\u7ef4\u62a4\u7684\u65b9\u5f0f\u3002"))),Object(i.b)("h2",{id:"9131-\u5173\u4e8e\u5b58\u50a8\u8fc7\u7a0b"},"9.13.1 \u5173\u4e8e\u5b58\u50a8\u8fc7\u7a0b"),Object(i.b)("p",null,"\u5f15\u7528\u767e\u5ea6\u767e\u79d1\uff1a"),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},"\u5b58\u50a8\u8fc7\u7a0b\uff08Stored Procedure\uff09\u662f\u5728\u5927\u578b\u6570\u636e\u5e93\u7cfb\u7edf\u4e2d\uff0c\u4e00\u7ec4\u4e3a\u4e86\u5b8c\u6210\u7279\u5b9a\u529f\u80fd\u7684 SQL \u8bed\u53e5\u96c6\uff0c\u5b83\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u4e00\u6b21\u7f16\u8bd1\u540e\u6c38\u4e45\u6709\u6548\uff0c\u7528\u6237\u901a\u8fc7\u6307\u5b9a\u5b58\u50a8\u8fc7\u7a0b\u7684\u540d\u5b57\u5e76\u7ed9\u51fa\u53c2\u6570\uff08\u5982\u679c\u8be5\u5b58\u50a8\u8fc7\u7a0b\u5e26\u6709\u53c2\u6570\uff09\u6765\u6267\u884c\u5b83\u3002"),Object(i.b)("p",{parentName:"blockquote"},"\u5b58\u50a8\u8fc7\u7a0b\u662f\u6570\u636e\u5e93\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u5bf9\u8c61\u3002\u5728\u6570\u636e\u91cf\u7279\u522b\u5e9e\u5927\u7684\u60c5\u51b5\u4e0b\u5229\u7528\u5b58\u50a8\u8fc7\u7a0b\u80fd\u8fbe\u5230\u500d\u901f\u7684\u6548\u7387\u63d0\u5347\u3002")),Object(i.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u5b58\u50a8\u8fc7\u7a0b\u5c31\u662f\u5173\u7cfb\u578b\u6570\u636e\u5e93\u4e2d\uff08",Object(i.b)("inlineCode",{parentName:"p"},"Sqlite")," \u9664\u5916\uff09\u4e2d\u7f16\u5199\u903b\u8f91\u7684\u51fd\u6570/\u65b9\u6cd5\uff0c\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5c06 ",Object(i.b)("inlineCode",{parentName:"p"},"sql")," \u7f16\u8bd1\u7f13\u5b58\u8d77\u6765\uff0c\u5927\u5927\u63d0\u9ad8\u5b58\u50a8\u8fc7\u7a0b\u7684\u6267\u884c\u6548\u7387\u3002"),Object(i.b)("p",null,Object(i.b)("strong",{parentName:"p"},"\u8fd9\u91cc\u4e0d\u8ba8\u8bba\u5b58\u50a8\u8fc7\u7a0b\u7684\u4f18\u7f3a\u70b9\u3002")),Object(i.b)("h3",{id:"91311-\u652f\u6301\u5b58\u50a8\u8fc7\u7a0b\u7684\u6570\u636e\u5e93"},"9.13.1.1 \u652f\u6301\u5b58\u50a8\u8fc7\u7a0b\u7684\u6570\u636e\u5e93"),Object(i.b)("table",null,Object(i.b)("thead",{parentName:"table"},Object(i.b)("tr",{parentName:"thead"},Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"SqlServer"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Sqlite"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Cosmos"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"InMemoryDatabase"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"MySql"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"PostgreSQL"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Oracle"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Firebird"),Object(i.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Dm"))),Object(i.b)("tbody",{parentName:"table"},Object(i.b)("tr",{parentName:"tbody"},Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null})),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null})),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(i.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714")))),Object(i.b)("h2",{id:"9132-\u5b58\u50a8\u8fc7\u7a0b\u4f7f\u7528"},"9.13.2 \u5b58\u50a8\u8fc7\u7a0b\u4f7f\u7528"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u63d0\u4f9b\u4e86\u591a\u79cd\u5b58\u50a8\u8fc7\u7a0b\u64cd\u4f5c\u65b9\u5f0f\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlRepository"),"\uff1a",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8\uff0c\u53ef\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"li"},"\u4f9d\u8d56\u6ce8\u5165")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlDispatchProxy"),"\uff1a",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u4ee3\u7406\u65b9\u5f0f\uff08\u9ad8\u7ea7\u7528\u6cd5\uff0c\u63a8\u8350\uff09"),Object(i.b)("li",{parentName:"ul"},"\u901a\u8fc7\u4efb\u610f\u5b9e\u4f53\u4ed3\u50a8\u64cd\u4f5c\uff1a",Object(i.b)("inlineCode",{parentName:"li"},"personRepository.SqlProcedureQuery(procName)")),Object(i.b)("li",{parentName:"ul"},"\u901a\u8fc7\u5b57\u7b26\u4e32\u62d3\u5c55\u65b9\u6cd5\uff1a",Object(i.b)("inlineCode",{parentName:"li"},"procName.SqlProcedureQuery()")),Object(i.b)("li",{parentName:"ul"},"\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"li"},"repository.Sql().SqlProcedureQuery()")," \u65b9\u5f0f")),Object(i.b)("h3",{id:"91321-\u521d\u59cb\u5316\u65b9\u5f0f"},"9.13.2.1 \u521d\u59cb\u5316\u65b9\u5f0f"),Object(i.b)(l.a,{defaultValue:"one",values:[{label:"ISqlRepository",value:"one"},{label:"ISqlDispatchProxy",value:"two"},{label:"\u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f",value:"three"},{label:"\u5b57\u7b26\u4e32\u62d3\u5c55\u65b9\u5f0f",value:"four"}],mdxType:"Tabs"},Object(i.b)(c.a,{value:"one",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,9-12}","{1,9-12}":!0}),"using Fur.DatabaseAccessor;\nusing Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [DynamicApiController]\n public class SqlService\n {\n private ISqlRepository _sqlRepository;\n public SqlService(ISqlRepository sqlRepository)\n {\n _sqlRepository = sqlRepository;\n }\n }\n}\n"))),Object(i.b)(c.a,{value:"two",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,7,9-10}","{2,7,9-10}":!0}),'using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing System.Collections.Generic;\n\nnamespace Fur.Application\n{\n public interface ISqlExecuteProxy : ISqlDispatchProxy\n {\n [SqlProcedure("proc_GetPersons")]\n List GetPersons(string keyword);\n }\n}\n')),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{9-12}","{9-12}":!0}),"using Fur.DatabaseAccessor;\nusing Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [DynamicApiController]\n public class SqlService\n {\n private ISqlExecuteProxy _sqlExecuteProxy;\n public SqlService(ISqlExecuteProxy sqlExecuteProxy)\n {\n _sqlExecuteProxy = sqlExecuteProxy;\n }\n }\n}\n"))),Object(i.b)(c.a,{value:"three",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'var persons = personRepository.SqlProcedureQuery("proc_GetPersons");\n'))),Object(i.b)(c.a,{value:"four",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'var persons = "proc_GetPersons".SqlProcedureQuery();\n')))),Object(i.b)("h3",{id:"91322-\u8fd4\u56de-datatable"},"9.13.2.2 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"DataTable")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar dataTable = _sqlRepository.SqlProcedureQuery("proc_GetPersons");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar dataTable = _sqlExecuteProxy.GetPersons(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar dataTable = _personRepository.SqlProcedureQuery("proc_GetPersons");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar dataTable = _repository.Sql().SqlProcedureQuery("proc_GetPersons");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\nvar dataTable = "proc_GetPersons".SqlProcedureQuery();\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h3",{id:"91323-\u8fd4\u56de-dataset"},"9.13.2.3 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"DataSet")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar dataSet = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar dataSet = _sqlExecuteProxy.GetPersons(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar dataSet = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar dataSet = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\nvar dataSet = "proc_GetPersons".SqlProcedureQueries();\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h3",{id:"91324-\u8fd4\u56de-listt"},"9.13.2.4 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"List")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar list = _sqlRepository.SqlProcedureQuery("proc_GetPersons");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar list = _sqlExecuteProxy.GetPersons(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar list = _personRepository.SqlProcedureQuery("proc_GetPersons");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar list = _repository.Sql().SqlProcedureQuery("proc_GetPersons");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\nvar list = "proc_GetPersons".SqlProcedureQuery();\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h3",{id:"91325-\u8fd4\u56de-tuplet1t8"},"9.13.2.5 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"Tuple")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u5927\u5927\u5229\u7528\u4e86 ",Object(i.b)("inlineCode",{parentName:"p"},"Tuple")," \u7684\u7279\u6027\uff0c\u5c06\u8fd4\u56de\u591a\u4e2a\u7ed3\u679c\u96c6\u8f6c\u6210 ",Object(i.b)("inlineCode",{parentName:"p"},"Tuple")," \u7c7b\u578b"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\n\n// \u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u96c6\nvar list1 = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e24\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2) = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e09\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3) = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u56db\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4) = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e94\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5) = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u516d\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6) = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e03\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7) = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u516b\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7, list8) = _sqlRepository.SqlProcedureQueries("proc_GetPersons");\n\n// ==================================\n\n// ISqlDispatchProxy \u65b9\u5f0f\uff0c\u63a8\u8350\u65b9\u5f0f\uff0c\u81ea\u52a8\u5904\u7406\u591a\u4e2a\u7ed3\u679c\u96c6\n\n// \u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u96c6\nvar list1 = _sqlRepository.GetDatas();\n\n// \u8fd4\u56de\u4e24\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2) = _sqlRepository.GetDatas();\n\n// \u8fd4\u56de\u4e09\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3) = _sqlRepository.GetDatas();\n\n// \u8fd4\u56de\u56db\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4) = _sqlRepository.GetDatas();\n\n// \u8fd4\u56de\u4e94\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5) = _sqlRepository.GetDatas();\n\n// \u8fd4\u56de\u516d\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6) = _sqlRepository.GetDatas();\n\n// \u8fd4\u56de\u4e03\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7) = _sqlRepository.GetDatas();\n\n// \u8fd4\u56de\u516b\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7, list8) = _sqlRepository.GetDatas();\n\n// ==================================\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\n\n// \u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u96c6\nvar list1 = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e24\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2) = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e09\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3) = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u56db\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4) = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e94\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5) = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u516d\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6) = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e03\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7) = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u516b\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7, list8) = _personRepository.SqlProcedureQueries("proc_GetPersons");\n\n// ==================================\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\n\n// \u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u96c6\nvar list1 = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e24\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2) = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e09\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3) = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u56db\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4) = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e94\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5) = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u516d\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6) = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u4e03\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7) = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// \u8fd4\u56de\u516b\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7, list8) = _repository.Sql().SqlProcedureQueries("proc_GetPersons");\n\n// ==================================\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\n\n// \u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u96c6\nvar list1 = "proc_GetPersons".SqlProcedureQueries();\n\n// \u8fd4\u56de\u4e24\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2) = "proc_GetPersons".SqlProcedureQueries();\n\n// \u8fd4\u56de\u4e09\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3) = "proc_GetPersons".SqlProcedureQueries();\n\n// \u8fd4\u56de\u56db\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4) = "proc_GetPersons".SqlProcedureQueries();\n\n// \u8fd4\u56de\u4e94\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5) = "proc_GetPersons".SqlProcedureQueries();\n\n// \u8fd4\u56de\u516d\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6) = "proc_GetPersons".SqlProcedureQueries();\n\n// \u8fd4\u56de\u4e03\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7) = "proc_GetPersons".SqlProcedureQueries();\n\n// \u8fd4\u56de\u516b\u4e2a\u7ed3\u679c\u96c6\nvar (list1, list2, list3, list4, list5, list6, list7, list8) = "proc_GetPersons".SqlProcedureQueries();\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h3",{id:"91326-\u8fd4\u56de-\u5355\u884c\u5355\u5217-object"},"9.13.2.6 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"\u5355\u884c\u5355\u5217 object")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar value = _sqlRepository.SqlProcedureScalar("proc_GetName");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar value = _sqlExecuteProxy.GetName(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar value = _personRepository.SqlProcedureScalar("proc_GetName");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar value = _repository.Sql().SqlProcedureScalar("proc_GetName");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\nvar value = "proc_GetName".SqlProcedureScalar();\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h3",{id:"91327-\u8fd4\u56de-\u5355\u884c\u5355\u5217-t"},"9.13.2.7 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"\u5355\u884c\u5355\u5217 ")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar value = _sqlRepository.SqlProcedureScalar("proc_GetName");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar value = _sqlExecuteProxy.GetName(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar value = _personRepository.SqlProcedureScalar("proc_GetName");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar value = _repository.Sql().SqlProcedureScalar("proc_GetName");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\nvar value = "proc_GetName".SqlProcedureScalar();\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h3",{id:"91328-\u6267\u884c\u4f46\u65e0\u8fd4\u56de"},"9.13.2.8 \u6267\u884c\u4f46\u65e0\u8fd4\u56de"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\n_sqlRepository.SqlProcedureNonQuery("proc_UpdateData");\n\n// ISqlDispatchProxy \u65b9\u5f0f\n_sqlExecuteProxy.UpdateData(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\n_personRepository.SqlProcedureNonQuery("proc_UpdateData");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\n_repository.Sql().SqlProcedureNonQuery("proc_UpdateData");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\n"proc_UpdateData".SqlProcedureNonQuery();\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h2",{id:"9133-\u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b"},"9.13.3 \u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b"),Object(i.b)("p",null,"\u5728\u5b58\u50a8\u8fc7\u7a0b\u4e2d\uff0c\u6709\u4e00\u79cd\u4f8b\u5b50\u975e\u5e38\u590d\u6742\uff0c\u90a3\u5c31\u662f\u65e2\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"INPUT")," \u53c2\u6570\uff0c\u53c8\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"OUTPUT")," \u53c2\u6570\uff0c\u8fd8\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"RETURN")," \u53c2\u6570\uff0c\u540c\u65f6\u8fd8\u8f93\u51fa \u7ed3\u679c\u96c6 \ud83d\udca5\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-sql",metastring:"{3,4,10-12,15-17,22}","{3,4,10-12,15-17,22}":!0}),"CREATE PROC PROC_Output\n @Id INT, // \u8f93\u5165\u53c2\u6570\n @Name NVARCHAR(32) OUTPUT, // \u8f93\u51fa\u53c2\u6570\uff0c\u8fd8\u5e26\u957f\u5ea6\n @Age INT OUTPUT // \u8f93\u51fa\u53c2\u6570\nAS\nBEGIN\n SET @Name = 'Fur Output';\n\n // \u8f93\u51fa\u7ed3\u679c\u96c6\n SELECT *\n FROM dbo.Test\n WHERE Id > @Id;\n\n // \u8f93\u51fa\u7ed3\u679c\u96c6\n SELECT TOP 10\n *\n FROM dbo.Test;\n\n SET @Age = 27;\n\n // \u5e26 RETURN \u8fd4\u56de\n RETURN 10;\nEND;\n")),Object(i.b)("h3",{id:"91331-\u521b\u5efa\u53c2\u6570\u6a21\u578b"},"9.13.3.1 \u521b\u5efa\u53c2\u6570\u6a21\u578b"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,10,13,16}","{1,10,13,16}":!0}),"using Fur.DatabaseAccessor;\nusing System.Data;\n\nnamespace Fur.Application\n{\n public class ProcOutputModel\n {\n public int Id { get; set; } // \u8f93\u5165\u53c2\u6570\n\n [DbParameter(ParameterDirection.Output, Size = 32)]\n public string Name { get; set; } // \u8f93\u51fa\u53c2\u6570\n\n [DbParameter(ParameterDirection.Output)]\n public int Age { get; set; } // \u8f93\u51fa\u53c2\u6570\n\n [DbParameter(ParameterDirection.ReturnValue)]\n public int ReturnValue { get; set; } // \u8fd4\u56de\u503c\n }\n}\n")),Object(i.b)("h3",{id:"91332-\u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b"},"9.13.3.2 \u6267\u884c\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("strong",{parentName:"li"}," ",Object(i.b)("inlineCode",{parentName:"strong"},"DataSet")," ")," \u65b9\u5f0f")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nProcedureOutputResult result = _sqlRepository.SqlProcedureOutput("proc_Complex", new ProcOutputModel{});\n\n// ISqlDispatchProxy \u65b9\u5f0f\nProcedureOutputResult result = _sqlExecuteProxy.Complex(new ProcOutputModel{}); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nProcedureOutputResult result = _personRepository.SqlProcedureOutput("proc_Complex", new ProcOutputModel{});\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nProcedureOutputResult result = _repository.Sql().SqlProcedureOutput("proc_Complex", new ProcOutputModel{});\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\nProcedureOutputResult result = "proc_Complex".SqlProcedureOutput(new ProcOutputModel{});\n')),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// \u83b7\u53d6 OUTPUT \u53c2\u6570\u503c\nvar outputs = result.OutputValues;\n\n// \u83b7\u53d6 RETURN \u8fd4\u56de\u503c\nvar reval = result.ReturnValue;\n\n// \u83b7\u53d6\u8fd4\u56de\u7ed3\u679c\u96c6\nvar dataSet = result.Result;\n")),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Tuple")," \u65b9\u5f0f")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nProcedureOutputResult<(List, List)> result = _sqlRepository.SqlProcedureOutput<(List, List)>("proc_Complex", new ProcOutputModel{});\n\n// ISqlDispatchProxy \u65b9\u5f0f\nProcedureOutputResult<(List, List)> result = _sqlExecuteProxy.Complex(new ProcOutputModel{}); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nProcedureOutputResult<(List, List)> result = _personRepository.SqlProcedureOutput<(List, List)>("proc_Complex", new ProcOutputModel{});\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nProcedureOutputResult<(List, List)> result = _repository.Sql().SqlProcedureOutput<(List, List)>("proc_Complex", new ProcOutputModel{});\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u5b58\u50a8\u8fc7\u7a0b\u540d\u6267\u884c\nProcedureOutputResult<(List, List)> result = "proc_Complex".SqlProcedureOutput<(List, List)>(new ProcOutputModel{});\n')),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// \u83b7\u53d6 OUTPUT \u53c2\u6570\u503c\nvar outputs = result.OutputValues;\n\n// \u83b7\u53d6 RETURN \u8fd4\u56de\u503c\nvar reval = result.ReturnValue;\n\n// \u83b7\u53d6\u8fd4\u56de\u7ed3\u679c\u96c6\nvar (list1,list2) = result.Result;\n")),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(i.b)("h2",{id:"9133-\u5173\u4e8e-dbparameter"},"9.13.3 \u5173\u4e8e ",Object(i.b)("inlineCode",{parentName:"h2"},"[DbParameter]")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"[DbParameter]")," \u7279\u6027\u662f\u7528\u6765\u6807\u6ce8 ",Object(i.b)("inlineCode",{parentName:"p"},"Sql"),"\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"\u51fd\u6570"),"\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"\u5b58\u50a8\u8fc7\u7a0b")," \u53c2\u6570\u7684\uff0c\u53ef\u914d\u7f6e\u5c5e\u6027\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Direction"),"\uff1a\u8bbe\u7f6e\u53c2\u6570\u65b9\u5411\uff0c",Object(i.b)("inlineCode",{parentName:"li"},"ParameterDirection")," \u679a\u4e3e\u7c7b\u578b\uff0c\u9ed8\u8ba4 ",Object(i.b)("inlineCode",{parentName:"li"},"ParameterDirection.Input")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"DbType"),"\uff1a\u8bbe\u7f6e\u53c2\u6570\u7c7b\u578b\uff0c",Object(i.b)("inlineCode",{parentName:"li"},"DbType")," \u679a\u4e3e\u7c7b\u578b\uff0c\u65e0\u9ed8\u8ba4"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Size"),"\uff1a\u8bbe\u7f6e\u53c2\u6570\u957f\u5ea6\u7684\uff0c",Object(i.b)("inlineCode",{parentName:"li"},"int")," \u7c7b\u578b")),Object(i.b)("p",null,"\u5176\u4e2d ",Object(i.b)("inlineCode",{parentName:"p"},"Direction")," \u5c5e\u6027\u662f\u9ed8\u8ba4\u6784\u9020\u51fd\u6570\u53c2\u6570\u3002"),Object(i.b)("h2",{id:"9134-\u5173\u4e8e-procedureoutputresult"},"9.13.4 \u5173\u4e8e ",Object(i.b)("inlineCode",{parentName:"h2"},"ProcedureOutputResult")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"ProcedureOutputResult")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"ProcedureOutputResult")," \u662f\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b\u6267\u884c\u8fd4\u56de\u6a21\u578b\u7c7b\uff0c\u6709\u4ee5\u4e0b\u5c5e\u6027\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"OutputValues"),"\uff1a\u591a\u4e2a\u8f93\u51fa\u503c\uff0c",Object(i.b)("inlineCode",{parentName:"li"},"ProcedureOutputValue")," \u7c7b\u578b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ReturnValue"),"\uff1a\u8fd4\u56de\u503c\uff0c",Object(i.b)("inlineCode",{parentName:"li"},"object")," \u7c7b\u578b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Result"),"\uff1a\u7ed3\u679c\u96c6\uff0c\u975e\u6cdb\u578b\u7248\u672c\u662f ",Object(i.b)("inlineCode",{parentName:"li"},"DataSet"),"\u7c7b\u578b\uff0c\u5426\u5219\u662f \u6cdb\u578b\u7c7b\u578b")),Object(i.b)("h2",{id:"9135-\u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570"},"9.13.5 \u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570"),Object(i.b)("p",null,"\u6240\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"sql")," \u53c2\u6570\u90fd\u652f\u6301\u56db\u79cd\u65b9\u5f0f\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"DbParameter[]"),"\uff1a\u6570\u7ec4\u7c7b\u578b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"new {}"),"\uff1a\u533f\u540d\u7c7b\u578b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"new Class{}"),"\uff1a\u5f3a\u7c7b\u578b\u7c7b\u578b\uff08\u652f\u6301\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570\uff09"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Dictionary")," \u7c7b\u578b")),Object(i.b)("h2",{id:"9136-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.13.6 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(r.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}u.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/17666df9.37cd28d0.js b/handbook/build/17666df9.37cd28d0.js new file mode 100644 index 00000000000..7703786ef8b --- /dev/null +++ b/handbook/build/17666df9.37cd28d0.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[9],{142:function(e,n,a){"use strict";a.d(n,"a",(function(){return p})),a.d(n,"b",(function(){return w}));var t=a(0),u=a.n(t);function s(e,n,a){return n in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}function r(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),a.push.apply(a,t)}return a}function c(e){for(var n=1;n=0||(u[a]=e[a]);return u}(e,n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(u[a]=e[a])}return u}var i=u.a.createContext({}),o=function(e){var n=u.a.useContext(i),a=n;return e&&(a="function"==typeof e?e(n):c(c({},n),e)),a},p=function(e){var n=o(e.components);return u.a.createElement(i.Provider,{value:n},e.children)},l={inlineCode:"code",wrapper:function(e){var n=e.children;return u.a.createElement(u.a.Fragment,{},n)}},N=u.a.forwardRef((function(e,n){var a=e.components,t=e.mdxType,s=e.originalType,r=e.parentName,i=d(e,["components","mdxType","originalType","parentName"]),p=o(a),N=t,w=p["".concat(r,".").concat(N)]||p[N]||l[N]||s;return a?u.a.createElement(w,c(c({ref:n},i),{},{components:a})):u.a.createElement(w,c({ref:n},i))}));function w(e,n){var a=arguments,t=n&&n.mdxType;if("string"==typeof e||t){var s=a.length,r=new Array(s);r[0]=N;var c={};for(var d in n)hasOwnProperty.call(n,d)&&(c[d]=n[d]);c.originalType=e,c.mdxType="string"==typeof e?e:t,r[1]=c;for(var i=2;iu.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateInclude(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateInclude(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateInclude(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateInclude(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateInclude("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateInclude(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateInclude(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateIncludeAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateIncludeAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateIncludeAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateIncludeAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateIncludeAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateIncludeAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateIncludeAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateIncludeAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"964-\u66f4\u65b0\u90e8\u5206\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.4 \u66f4\u65b0\u90e8\u5206\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateIncludeNow(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateIncludeNow(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateIncludeNow(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateIncludeNow(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateIncludeNow(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateIncludeNow("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateIncludeNow(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateIncludeNow(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateIncludeNowAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateIncludeNowAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateIncludeNowAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateIncludeNowAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateIncludeNowAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateIncludeNowAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateIncludeNowAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateIncludeNowAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"965-\u6392\u9664\u7279\u5b9a\u5217\u66f4\u65b0\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.5 \u6392\u9664\u7279\u5b9a\u5217\u66f4\u65b0\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateExclude(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateExclude(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateExclude(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateExclude(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateExclude(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateExclude("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateExclude(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateExclude(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateExcludeAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateExcludeAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateExcludeAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateExcludeAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateExcludeAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateExcludeAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateExcludeAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateExcludeAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"966-\u6392\u9664\u7279\u5b9a\u5217\u66f4\u65b0\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.6 \u6392\u9664\u7279\u5b9a\u5217\u66f4\u65b0\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateExcludeNow(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateExcludeNow(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateExcludeNow(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateExcludeNow(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateExcludeNow(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateExcludeNow("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateExcludeNow(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateExcludeNow(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateExcludeNowAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateExcludeNowAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateExcludeNowAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateExcludeNowAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateExcludeNowAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateExcludeNowAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateExcludeNowAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateExcludeNowAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"967-\u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u6240\u6709\u5217\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.7 \u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u6240\u6709\u5217\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateExists(user);\n\n// \u793a\u4f8b\u4e8c\nuser.UpdateExists();\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateExistsAsync(user);\n\n// \u793a\u4f8b\u4e8c\nawait user.UpdateExistsAsync();\n")),Object(s.b)("h2",{id:"968-\u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u6240\u6709\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.8 \u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u6240\u6709\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateExistsNow(user);\n\n// \u793a\u4f8b\u4e8c\nuser.UpdateExistsNow();\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateExistsNowAsync(user);\n\n// \u793a\u4f8b\u4e8c\nawait user.UpdateExistsNowAsync();\n")),Object(s.b)("h2",{id:"969-\u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u90e8\u5206\u5217\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.9 \u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u90e8\u5206\u5217\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateIncludeExists(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateIncludeExists(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateIncludeExists(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateIncludeExists(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateIncludeExists(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateIncludeExists("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateIncludeExists(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateIncludeExists(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateIncludeExistsAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateIncludeExistsAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateIncludeExistsAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateIncludeExistsAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateIncludeExistsAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateIncludeExistsAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateIncludeExistsAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateIncludeExistsAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"9610-\u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u90e8\u5206\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.10 \u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u90e8\u5206\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateIncludeExistsNow(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateIncludeExistsNow(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateIncludeExistsNow(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateIncludeExistsNow(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateIncludeExistsNow(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateIncludeExistsNow("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateIncludeExistsNow(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateIncludeExistsNow(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateIncludeExistsNowAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateIncludeExistsNowAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateIncludeExistsNowAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateIncludeExistsNowAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateIncludeExistsNowAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateIncludeExistsNowAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateIncludeExistsNowAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateIncludeExistsNowAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"9611-\u6570\u636e\u5b58\u5728\u624d\u6392\u9664\u7279\u5b9a\u90e8\u5206\u5217\u66f4\u65b0\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.11 \u6570\u636e\u5b58\u5728\u624d\u6392\u9664\u7279\u5b9a\u90e8\u5206\u5217\u66f4\u65b0\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateExcludeExists(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateExcludeExists(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateExcludeExists(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateExcludeExists(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateExcludeExists(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateExcludeExists("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateExcludeExists(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateExcludeExists(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateExcludeExistsAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateExcludeExistsAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateExcludeExistsAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateExcludeExistsAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateExcludeExistsAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateExcludeExistsAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateExcludeExistsAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateExcludeExistsAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"9612-\u6570\u636e\u5b58\u5728\u624d\u6392\u9664\u7279\u5b9a\u90e8\u5206\u5217\u66f4\u65b0\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.12 \u6570\u636e\u5b58\u5728\u624d\u6392\u9664\u7279\u5b9a\u90e8\u5206\u5217\u66f4\u65b0\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateExcludeExistsNow(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateExcludeExistsNow(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateExcludeExistsNow(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateExcludeExistsNow(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateExcludeExistsNow(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateExcludeExistsNow("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateExcludeExistsNow(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateExcludeExistsNow(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateExcludeExistsNowAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateExcludeExistsNowAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateExcludeExistsNowAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateExcludeExistsNowAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateExcludeExistsNowAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateExcludeExistsNowAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateExcludeExistsNowAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateExcludeExistsNowAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"9613-\u66f4\u65b0\u591a\u6761\u8bb0\u5f55\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.13 \u66f4\u65b0\u591a\u6761\u8bb0\u5f55\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.Update(user, user2);\n\n// \u793a\u4f8b\u4e8c\nrepository.Update(new List { user, user2 });\n\n// \u793a\u4f8b\u4e09\nrepository.Update(new[] {user, user2 });\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateAsync(user, user2);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateAsync(new List { user, user2 });\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateAsync(new[] {user, user2 });\n")),Object(s.b)("h2",{id:"9614-\u66f4\u65b0\u591a\u6761\u8bb0\u5f55\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.14 \u66f4\u65b0\u591a\u6761\u8bb0\u5f55\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateNow(user, user2);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateNow(new List { user, user2 });\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateNow(new[] {user, user2 });\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateNowAsync(user, user2);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateNowAsync(new List { user, user2 });\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateNowAsync(new[] {user, user2 });\n")),Object(s.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(s.b)("h5",{parentName:"div"},Object(s.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(s.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(s.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(s.b)("p",{parentName:"div"},"\u6240\u6709\u5e26 ",Object(s.b)("inlineCode",{parentName:"p"},"Now")," \u7ed3\u5c3e\u7684\u8868\u793a\u7acb\u5373\u63d0\u4ea4\u5230\u6570\u636e\u5e93\uff0c\u4e5f\u5c31\u662f\u7acb\u5373\u8c03\u7528 ",Object(s.b)("inlineCode",{parentName:"p"},"SaveChanges")," \u6216 ",Object(s.b)("inlineCode",{parentName:"p"},"SaveChangesAsync"),"\u3002"))),Object(s.b)("h2",{id:"9615-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.6.15 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(s.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(s.b)("h5",{parentName:"div"},Object(s.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(s.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(s.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(s.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(s.b)("a",Object(t.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}o.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/17666df9.a5abd77b.js b/handbook/build/17666df9.a5abd77b.js deleted file mode 100644 index f47742c6460..00000000000 --- a/handbook/build/17666df9.a5abd77b.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[9],{142:function(e,n,a){"use strict";a.d(n,"a",(function(){return p})),a.d(n,"b",(function(){return w}));var t=a(0),u=a.n(t);function s(e,n,a){return n in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}function r(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),a.push.apply(a,t)}return a}function c(e){for(var n=1;n=0||(u[a]=e[a]);return u}(e,n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(u[a]=e[a])}return u}var i=u.a.createContext({}),o=function(e){var n=u.a.useContext(i),a=n;return e&&(a="function"==typeof e?e(n):c(c({},n),e)),a},p=function(e){var n=o(e.components);return u.a.createElement(i.Provider,{value:n},e.children)},l={inlineCode:"code",wrapper:function(e){var n=e.children;return u.a.createElement(u.a.Fragment,{},n)}},N=u.a.forwardRef((function(e,n){var a=e.components,t=e.mdxType,s=e.originalType,r=e.parentName,i=d(e,["components","mdxType","originalType","parentName"]),p=o(a),N=t,w=p["".concat(r,".").concat(N)]||p[N]||l[N]||s;return a?u.a.createElement(w,c(c({ref:n},i),{},{components:a})):u.a.createElement(w,c({ref:n},i))}));function w(e,n){var a=arguments,t=n&&n.mdxType;if("string"==typeof e||t){var s=a.length,r=new Array(s);r[0]=N;var c={};for(var d in n)hasOwnProperty.call(n,d)&&(c[d]=n[d]);c.originalType=e,c.mdxType="string"==typeof e?e:t,r[1]=c;for(var i=2;iu.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateInclude(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateInclude(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateInclude(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateInclude(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateInclude("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateInclude(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateInclude(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateIncludeAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateIncludeAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateIncludeAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateIncludeAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateIncludeAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateIncludeAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateIncludeAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateIncludeAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"964-\u66f4\u65b0\u90e8\u5206\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.4 \u66f4\u65b0\u90e8\u5206\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateIncludeNow(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateIncludeNow(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateIncludeNow(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateIncludeNow(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateIncludeNow(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateIncludeNow("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateIncludeNow(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateIncludeNow(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateIncludeNowAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateIncludeNowAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateIncludeNowAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateIncludeNowAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateIncludeNowAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateIncludeNowAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateIncludeNowAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateIncludeNowAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"965-\u6392\u9664\u7279\u5b9a\u5217\u66f4\u65b0\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.5 \u6392\u9664\u7279\u5b9a\u5217\u66f4\u65b0\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateExclude(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateExclude(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateExclude(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateExclude(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateExclude(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateExclude("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateExclude(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateExclude(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateExcludeAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateExcludeAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateExcludeAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateExcludeAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateExcludeAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateExcludeAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateExcludeAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateExcludeAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"966-\u6392\u9664\u7279\u5b9a\u5217\u66f4\u65b0\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.6 \u6392\u9664\u7279\u5b9a\u5217\u66f4\u65b0\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateExcludeNow(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateExcludeNow(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateExcludeNow(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateExcludeNow(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateExcludeNow(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateExcludeNow("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateExcludeNow(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateExcludeNow(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateExcludeNowAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateExcludeNowAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateExcludeNowAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateExcludeNowAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateExcludeNowAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateExcludeNowAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateExcludeNowAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateExcludeNowAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"967-\u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u6240\u6709\u5217\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.7 \u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u6240\u6709\u5217\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateExists(user);\n\n// \u793a\u4f8b\u4e8c\nuser.UpdateExists();\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateExistsAsync(user);\n\n// \u793a\u4f8b\u4e8c\nawait user.UpdateExistsAsync();\n")),Object(s.b)("h2",{id:"968-\u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u6240\u6709\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.8 \u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u6240\u6709\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateExistsNow(user);\n\n// \u793a\u4f8b\u4e8c\nuser.UpdateExistsNow();\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateExistsNowAsync(user);\n\n// \u793a\u4f8b\u4e8c\nawait user.UpdateExistsNowAsync();\n")),Object(s.b)("h2",{id:"969-\u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u90e8\u5206\u5217\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.9 \u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u90e8\u5206\u5217\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateIncludeExists(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateIncludeExists(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateIncludeExists(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateIncludeExists(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateIncludeExists(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateIncludeExists("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateIncludeExists(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateIncludeExists(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateIncludeExistsAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateIncludeExistsAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateIncludeExistsAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateIncludeExistsAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateIncludeExistsAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateIncludeExistsAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateIncludeExistsAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateIncludeExistsAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"9610-\u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u90e8\u5206\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.10 \u6570\u636e\u5b58\u5728\u624d\u66f4\u65b0\u90e8\u5206\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateIncludeExistsNow(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateIncludeExistsNow(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateIncludeExistsNow(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateIncludeExistsNow(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateIncludeExistsNow(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateIncludeExistsNow("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateIncludeExistsNow(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateIncludeExistsNow(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateIncludeExistsNowAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateIncludeExistsNowAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateIncludeExistsNowAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateIncludeExistsNowAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateIncludeExistsNowAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateIncludeExistsNowAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateIncludeExistsNowAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateIncludeExistsNowAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"9611-\u6570\u636e\u5b58\u5728\u624d\u6392\u9664\u7279\u5b9a\u90e8\u5206\u5217\u66f4\u65b0\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.11 \u6570\u636e\u5b58\u5728\u624d\u6392\u9664\u7279\u5b9a\u90e8\u5206\u5217\u66f4\u65b0\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateExcludeExists(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateExcludeExists(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateExcludeExists(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateExcludeExists(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateExcludeExists(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateExcludeExists("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateExcludeExists(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateExcludeExists(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateExcludeExistsAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateExcludeExistsAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateExcludeExistsAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateExcludeExistsAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateExcludeExistsAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateExcludeExistsAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateExcludeExistsAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateExcludeExistsAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"9612-\u6570\u636e\u5b58\u5728\u624d\u6392\u9664\u7279\u5b9a\u90e8\u5206\u5217\u66f4\u65b0\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.12 \u6570\u636e\u5b58\u5728\u624d\u6392\u9664\u7279\u5b9a\u90e8\u5206\u5217\u66f4\u65b0\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateExcludeExistsNow(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateExcludeExistsNow(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateExcludeExistsNow(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.UpdateExcludeExistsNow(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.UpdateExcludeExistsNow(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.UpdateExcludeExistsNow("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.UpdateExcludeExistsNow(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.UpdateExcludeExistsNow(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateExcludeExistsNowAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateExcludeExistsNowAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateExcludeExistsNowAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.UpdateExcludeExistsNowAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.UpdateExcludeExistsNowAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.UpdateExcludeExistsNowAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.UpdateExcludeExistsNowAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.UpdateExcludeExistsNowAsync(new[] {"Age", "Name"});\n')),Object(s.b)("h2",{id:"9613-\u66f4\u65b0\u591a\u6761\u8bb0\u5f55\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.13 \u66f4\u65b0\u591a\u6761\u8bb0\u5f55\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.Update(user, user2);\n\n// \u793a\u4f8b\u4e8c\nrepository.Update(new List { user, user2 });\n\n// \u793a\u4f8b\u4e09\nrepository.Update(new[] {user, user2 });\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateAsync(user, user2);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateAsync(new List { user, user2 });\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateAsync(new[] {user, user2 });\n")),Object(s.b)("h2",{id:"9614-\u66f4\u65b0\u591a\u6761\u8bb0\u5f55\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.6.14 \u66f4\u65b0\u591a\u6761\u8bb0\u5f55\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.UpdateNow(user, user2);\n\n// \u793a\u4f8b\u4e8c\nrepository.UpdateNow(new List { user, user2 });\n\n// \u793a\u4f8b\u4e09\nrepository.UpdateNow(new[] {user, user2 });\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.UpdateNowAsync(user, user2);\n\n// \u793a\u4f8b\u4e8c\nawait repository.UpdateNowAsync(new List { user, user2 });\n\n// \u793a\u4f8b\u4e09\nawait repository.UpdateNowAsync(new[] {user, user2 });\n")),Object(s.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(s.b)("h5",{parentName:"div"},Object(s.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(s.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(s.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(s.b)("p",{parentName:"div"},"\u6240\u6709\u5e26 ",Object(s.b)("inlineCode",{parentName:"p"},"Now")," \u7ed3\u5c3e\u7684\u8868\u793a\u7acb\u5373\u63d0\u4ea4\u5230\u6570\u636e\u5e93\uff0c\u4e5f\u5c31\u662f\u7acb\u5373\u8c03\u7528 ",Object(s.b)("inlineCode",{parentName:"p"},"SaveChanges")," \u6216 ",Object(s.b)("inlineCode",{parentName:"p"},"SaveChangesAsync"),"\u3002"))),Object(s.b)("h2",{id:"9615-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.6.15 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(s.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(s.b)("h5",{parentName:"div"},Object(s.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(s.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(s.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(s.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(s.b)("a",Object(t.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}o.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/1d7b962e.4baa59fe.js b/handbook/build/1d7b962e.4baa59fe.js deleted file mode 100644 index 7f17b2e3c7c..00000000000 --- a/handbook/build/1d7b962e.4baa59fe.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[12],{142:function(e,n,r){"use strict";r.d(n,"a",(function(){return i})),r.d(n,"b",(function(){return m}));var t=r(0),a=r.n(t);function u(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function s(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,t)}return r}function c(e){for(var n=1;n=0||(a[r]=e[r]);return a}(e,n);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var d=a.a.createContext({}),p=function(e){var n=a.a.useContext(d),r=n;return e&&(r="function"==typeof e?e(n):c(c({},n),e)),r},i=function(e){var n=p(e.components);return a.a.createElement(d.Provider,{value:n},e.children)},l={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},O=a.a.forwardRef((function(e,n){var r=e.components,t=e.mdxType,u=e.originalType,s=e.parentName,d=o(e,["components","mdxType","originalType","parentName"]),i=p(r),O=t,m=i["".concat(s,".").concat(O)]||i[O]||l[O]||u;return r?a.a.createElement(m,c(c({ref:n},d),{},{components:r})):a.a.createElement(m,c({ref:n},d))}));function m(e,n){var r=arguments,t=n&&n.mdxType;if("string"==typeof e||t){var u=r.length,s=new Array(u);s[0]=O;var c={};for(var o in n)hasOwnProperty.call(n,o)&&(c[o]=n[o]);c.originalType=e,c.mdxType="string"==typeof e?e:t,s[1]=c;for(var d=2;du.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.InsertOrUpdateInclude(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.InsertOrUpdateInclude(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.InsertOrUpdateInclude(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.InsertOrUpdateInclude(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.InsertOrUpdateInclude("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.InsertOrUpdateInclude(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.InsertOrUpdateInclude(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.InsertOrUpdateIncludeAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.InsertOrUpdateIncludeAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.InsertOrUpdateIncludeAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.InsertOrUpdateIncludeAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.InsertOrUpdateIncludeAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.InsertOrUpdateIncludeAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.InsertOrUpdateIncludeAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.InsertOrUpdateIncludeAsync(new[] {"Age", "Name"});\n')),Object(u.b)("h2",{id:"974-\u65b0\u589e\u6216\u66f4\u65b0\u90e8\u5206\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.7.4 \u65b0\u589e\u6216\u66f4\u65b0\u90e8\u5206\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(u.b)("pre",null,Object(u.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.InsertOrUpdateIncludeNow(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.InsertOrUpdateIncludeNow(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.InsertOrUpdateIncludeNow(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.InsertOrUpdateIncludeNow(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.InsertOrUpdateIncludeNow(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.InsertOrUpdateIncludeNow("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.InsertOrUpdateIncludeNow(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.InsertOrUpdateIncludeNow(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.InsertOrUpdateIncludeNowAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.InsertOrUpdateIncludeNowAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.InsertOrUpdateIncludeNowAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.InsertOrUpdateIncludeNowAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.InsertOrUpdateIncludeNowAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.InsertOrUpdateIncludeNowAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.InsertOrUpdateIncludeNowAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.InsertOrUpdateIncludeNowAsync(new[] {"Age", "Name"});\n')),Object(u.b)("h2",{id:"975-\u65b0\u589e\u6216\u66f4\u65b0\u6392\u9664\u7279\u5b9a\u5217\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.7.5 \u65b0\u589e\u6216\u66f4\u65b0\u6392\u9664\u7279\u5b9a\u5217\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(u.b)("pre",null,Object(u.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.InsertOrUpdateExclude(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.InsertOrUpdateExclude(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.InsertOrUpdateExclude(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.InsertOrUpdateExclude(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.InsertOrUpdateExclude(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.InsertOrUpdateExclude("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.InsertOrUpdateExclude(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.InsertOrUpdateExclude(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.InsertOrUpdateExcludeAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.InsertOrUpdateExcludeAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.InsertOrUpdateExcludeAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.InsertOrUpdateExcludeAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.InsertOrUpdateExcludeAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.InsertOrUpdateExcludeAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.InsertOrUpdateExcludeAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.InsertOrUpdateExcludeAsync(new[] {"Age", "Name"});\n')),Object(u.b)("h2",{id:"976-\u65b0\u589e\u6216\u66f4\u65b0\u6392\u9664\u7279\u5b9a\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.7.6 \u65b0\u589e\u6216\u66f4\u65b0\u6392\u9664\u7279\u5b9a\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(u.b)("pre",null,Object(u.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.InsertOrUpdateExcludeNow(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.InsertOrUpdateExcludeNow(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.InsertOrUpdateExcludeNow(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.InsertOrUpdateExcludeNow(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.InsertOrUpdateExcludeNow(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.InsertOrUpdateExcludeNow("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.InsertOrUpdateExcludeNow(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.InsertOrUpdateExcludeNow(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.InsertOrUpdateExcludeNowAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.InsertOrUpdateExcludeNowAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.InsertOrUpdateExcludeNowAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.InsertOrUpdateExcludeNowAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.InsertOrUpdateExcludeNowAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.InsertOrUpdateExcludeNowAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.InsertOrUpdateExcludeNowAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.InsertOrUpdateExcludeNowAsync(new[] {"Age", "Name"});\n')),Object(u.b)("h2",{id:"957-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.5.7 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(u.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(u.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(u.b)("h5",{parentName:"div"},Object(u.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(u.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(u.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(u.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(u.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(u.b)("a",Object(t.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/1d7b962e.7e7e2e9f.js b/handbook/build/1d7b962e.7e7e2e9f.js new file mode 100644 index 00000000000..2423236dce8 --- /dev/null +++ b/handbook/build/1d7b962e.7e7e2e9f.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[12],{142:function(e,n,r){"use strict";r.d(n,"a",(function(){return i})),r.d(n,"b",(function(){return m}));var t=r(0),a=r.n(t);function u(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function s(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,t)}return r}function c(e){for(var n=1;n=0||(a[r]=e[r]);return a}(e,n);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var d=a.a.createContext({}),p=function(e){var n=a.a.useContext(d),r=n;return e&&(r="function"==typeof e?e(n):c(c({},n),e)),r},i=function(e){var n=p(e.components);return a.a.createElement(d.Provider,{value:n},e.children)},l={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},O=a.a.forwardRef((function(e,n){var r=e.components,t=e.mdxType,u=e.originalType,s=e.parentName,d=o(e,["components","mdxType","originalType","parentName"]),i=p(r),O=t,m=i["".concat(s,".").concat(O)]||i[O]||l[O]||u;return r?a.a.createElement(m,c(c({ref:n},d),{},{components:r})):a.a.createElement(m,c({ref:n},d))}));function m(e,n){var r=arguments,t=n&&n.mdxType;if("string"==typeof e||t){var u=r.length,s=new Array(u);s[0]=O;var c={};for(var o in n)hasOwnProperty.call(n,o)&&(c[o]=n[o]);c.originalType=e,c.mdxType="string"==typeof e?e:t,s[1]=c;for(var d=2;du.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.InsertOrUpdateInclude(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.InsertOrUpdateInclude(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.InsertOrUpdateInclude(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.InsertOrUpdateInclude(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.InsertOrUpdateInclude("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.InsertOrUpdateInclude(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.InsertOrUpdateInclude(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.InsertOrUpdateIncludeAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.InsertOrUpdateIncludeAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.InsertOrUpdateIncludeAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.InsertOrUpdateIncludeAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.InsertOrUpdateIncludeAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.InsertOrUpdateIncludeAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.InsertOrUpdateIncludeAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.InsertOrUpdateIncludeAsync(new[] {"Age", "Name"});\n')),Object(u.b)("h2",{id:"974-\u65b0\u589e\u6216\u66f4\u65b0\u90e8\u5206\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.7.4 \u65b0\u589e\u6216\u66f4\u65b0\u90e8\u5206\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(u.b)("pre",null,Object(u.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.InsertOrUpdateIncludeNow(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.InsertOrUpdateIncludeNow(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.InsertOrUpdateIncludeNow(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.InsertOrUpdateIncludeNow(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.InsertOrUpdateIncludeNow(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.InsertOrUpdateIncludeNow("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.InsertOrUpdateIncludeNow(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.InsertOrUpdateIncludeNow(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.InsertOrUpdateIncludeNowAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.InsertOrUpdateIncludeNowAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.InsertOrUpdateIncludeNowAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.InsertOrUpdateIncludeNowAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.InsertOrUpdateIncludeNowAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.InsertOrUpdateIncludeNowAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.InsertOrUpdateIncludeNowAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.InsertOrUpdateIncludeNowAsync(new[] {"Age", "Name"});\n')),Object(u.b)("h2",{id:"975-\u65b0\u589e\u6216\u66f4\u65b0\u6392\u9664\u7279\u5b9a\u5217\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.7.5 \u65b0\u589e\u6216\u66f4\u65b0\u6392\u9664\u7279\u5b9a\u5217\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(u.b)("pre",null,Object(u.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.InsertOrUpdateExclude(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.InsertOrUpdateExclude(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.InsertOrUpdateExclude(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.InsertOrUpdateExclude(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.InsertOrUpdateExclude(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.InsertOrUpdateExclude("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.InsertOrUpdateExclude(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.InsertOrUpdateExclude(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.InsertOrUpdateExcludeAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.InsertOrUpdateExcludeAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.InsertOrUpdateExcludeAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.InsertOrUpdateExcludeAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.InsertOrUpdateExcludeAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.InsertOrUpdateExcludeAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.InsertOrUpdateExcludeAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.InsertOrUpdateExcludeAsync(new[] {"Age", "Name"});\n')),Object(u.b)("h2",{id:"976-\u65b0\u589e\u6216\u66f4\u65b0\u6392\u9664\u7279\u5b9a\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.7.6 \u65b0\u589e\u6216\u66f4\u65b0\u6392\u9664\u7279\u5b9a\u5217\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(u.b)("pre",null,Object(u.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.InsertOrUpdateExcludeNow(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nrepository.InsertOrUpdateExcludeNow(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nrepository.InsertOrUpdateExcludeNow(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nrepository.InsertOrUpdateExcludeNow(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nuser.InsertOrUpdateExcludeNow(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nuser.InsertOrUpdateExcludeNow("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nuser.InsertOrUpdateExcludeNow(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nuser.InsertOrUpdateExcludeNow(new[] {"Age", "Name"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.InsertOrUpdateExcludeNowAsync(user, u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u4e8c\nawait repository.InsertOrUpdateExcludeNowAsync(user, "Age", "Name");\n\n// \u793a\u4f8b\u4e09\nawait repository.InsertOrUpdateExcludeNowAsync(user, new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u56db\nawait repository.InsertOrUpdateExcludeNowAsync(user, new[] {"Age", "Name"});\n\n// \u793a\u4f8b\u4e94\nawait user.InsertOrUpdateExcludeNowAsync(u=>u.Name, u=>u.Age);\n\n// \u793a\u4f8b\u516d\nawait user.InsertOrUpdateExcludeNowAsync("Age", "Name");\n\n// \u793a\u4f8b\u4e03\nawait user.InsertOrUpdateExcludeNowAsync(new[] { u=>u.Name, u=>u.Age});\n\n// \u793a\u4f8b\u516b\nawait user.InsertOrUpdateExcludeNowAsync(new[] {"Age", "Name"});\n')),Object(u.b)("h2",{id:"957-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.5.7 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(u.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(u.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(u.b)("h5",{parentName:"div"},Object(u.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(u.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(u.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(u.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(u.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(u.b)("a",Object(t.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/1e961311.d7cc7b4c.js b/handbook/build/1e961311.d7cc7b4c.js new file mode 100644 index 00000000000..ec59660b7d7 --- /dev/null +++ b/handbook/build/1e961311.d7cc7b4c.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[13],{142:function(e,t,n){"use strict";n.d(t,"a",(function(){return p})),n.d(t,"b",(function(){return m}));var a=n(0),r=n.n(a);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=r.a.createContext({}),l=function(e){var t=r.a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):b(b({},t),e)),n},p=function(e){var t=l(e.components);return r.a.createElement(s.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},O=r.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,i=e.originalType,c=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),p=l(n),O=a,m=p["".concat(c,".").concat(O)]||p[O]||d[O]||i;return n?r.a.createElement(m,b(b({ref:t},s),{},{components:n})):r.a.createElement(m,b({ref:t},s))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var i=n.length,c=new Array(i);c[0]=O;var b={};for(var o in t)hasOwnProperty.call(t,o)&&(b[o]=t[o]);b.originalType=e,b.mdxType="string"==typeof e?e:a,c[1]=b;for(var s=2;sEFCore.BulkExtensions \u4f7f\u7528",id:"992-efcorebulkextensions-\u4f7f\u7528",children:[{value:"9.9.2.1 \u5e38\u89c1\u6279\u91cf\u64cd\u4f5c",id:"9921-\u5e38\u89c1\u6279\u91cf\u64cd\u4f5c",children:[]},{value:"9.9.2.2 \u67e5\u8be2\u540e\u6279\u91cf\u64cd\u4f5c",id:"9922-\u67e5\u8be2\u540e\u6279\u91cf\u64cd\u4f5c",children:[]}]},{value:"9.9.3 \u6279\u91cf\u64cd\u4f5c\u6027\u80fd",id:"993-\u6279\u91cf\u64cd\u4f5c\u6027\u80fd",children:[]},{value:"9.9.4 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"994-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],s={rightToc:o};function l(e){var t=e.components,n=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},s,n,{components:t,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"991-\u5173\u4e8e\u6279\u91cf\u64cd\u4f5c"},"9.9.1 \u5173\u4e8e\u6279\u91cf\u64cd\u4f5c"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u9ed8\u8ba4\u53ea\u63d0\u4f9b\u5c0f\u6570\u636e\uff08100 \u4ee5\u5185\uff09\u6279\u91cf\u6570\u636e\u64cd\u4f5c\uff0c\u5982\u679c\u9700\u8981\u66f4\u5927\u7684\u6570\u636e\u6279\u91cf\u5904\u7406\uff0c\u63a8\u8350\u4f7f\u7528\u7b2c\u4e09\u65b9\u5305 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/borisdj/EFCore.BulkExtensions"}),"EFCore.BulkExtensions"),"\uff0c\u652f\u6301\u548c ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u65e0\u7f1d\u8854\u63a5\u3002"),Object(i.b)("h2",{id:"992-efcorebulkextensions-\u4f7f\u7528"},"9.9.2 ",Object(i.b)("inlineCode",{parentName:"h2"},"EFCore.BulkExtensions")," \u4f7f\u7528"),Object(i.b)("h3",{id:"9921-\u5e38\u89c1\u6279\u91cf\u64cd\u4f5c"},"9.9.2.1 \u5e38\u89c1\u6279\u91cf\u64cd\u4f5c"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u6279\u91cf\u63d2\u5165\nrepository.DbContext.BulkInsert(entitiesList);\nrepository.DbContext.BulkInsertAsync(entitiesList);\n\n// \u6279\u91cf\u66f4\u65b0\nrepository.DbContext.BulkUpdate(entitiesList);\nrepository.DbContext.BulkUpdateAsync(entitiesList);\n\n// \u6279\u91cf\u5220\u9664\nrepository.DbContext.BulkDelete(entitiesList);\nrepository.DbContext.BulkDeleteAsync(entitiesList);\n\n// \u6279\u91cf\u63d2\u5165\u6216\u66f4\u65b0\nrepository.DbContext.BulkInsertOrUpdate(entitiesList);\nrepository.DbContext.BulkInsertOrUpdateAsync(entitiesList);\n\n// \u6279\u91cf\u63d2\u5165\u6216\u66f4\u65b0\u6216\u5220\u9664\nrepository.DbContext.BulkInsertOrUpdateOrDelete(entitiesList);\nrepository.DbContext.BulkInsertOrUpdateOrDeleteAsync(entitiesList);\n\n// \u6279\u91cf\u8bfb\u53d6\u591a\u4e2a\u5b9e\u4f53\nrepository.DbContext.BulkRead(entitiesList);\nrepository.DbContext.BulkReadAsync(entitiesList);\n\n// \u6279\u91cf\u6e05\u7a7a\u8868\uff08\u614e\u7528\uff01\uff01\uff01\uff01\uff01\uff09\nrepository.DbContext.Truncate();\nrepository.DbContext.TruncateAsync();\n")),Object(i.b)("h3",{id:"9922-\u67e5\u8be2\u540e\u6279\u91cf\u64cd\u4f5c"},"9.9.2.2 \u67e5\u8be2\u540e\u6279\u91cf\u64cd\u4f5c"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// \u6839\u636e\u6761\u4ef6\u6279\u91cf\u5220\u9664\nrepository.Where(a => a.ItemId > 500).BatchDelete();\nawait repository.Where(a => a.ItemId > 500).BatchDeleteAsync();\n\n// \u6839\u636e\u6761\u4ef6\u6279\u91cf\u66f4\u65b0\nrepository.Where(a => a.ItemId <= 500).BatchUpdate(a => new Item { Quantity = a.Quantity + 100 });\nrepository.Where(a => a.ItemId <= 500).BatchUpdate(new Item { Description = "Updated" });\nawait repository.Where(a => a.ItemId <= 500).BatchUpdateAsync(new Item { Description = "Updated" });\n\n// \u6279\u91cf\u66f4\u65b0\u6307\u5b9a\u5217\nvar updateColumns = new List { nameof(Item.Quantity) };\nvar q = repository.Where(a => a.ItemId <= 500);\nint affected = q.BatchUpdate(new Item { Description = "Updated" }, updateColumns);\n')),Object(i.b)("h2",{id:"993-\u6279\u91cf\u64cd\u4f5c\u6027\u80fd"},"9.9.3 \u6279\u91cf\u64cd\u4f5c\u6027\u80fd"),Object(i.b)("table",null,Object(i.b)("thead",{parentName:"table"},Object(i.b)("tr",{parentName:"thead"},Object(i.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Operations\\Rows"),Object(i.b)("th",Object(a.a)({parentName:"tr"},{align:"right"}),"100,000 EF"),Object(i.b)("th",Object(a.a)({parentName:"tr"},{align:"right"}),"100,000 EFBulk"),Object(i.b)("th",Object(a.a)({parentName:"tr"},{align:"right"}),"1,000,000 EFBulk"))),Object(i.b)("tbody",{parentName:"table"},Object(i.b)("tr",{parentName:"tbody"},Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Insert"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"38.98 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"2.10 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"17.99 s")),Object(i.b)("tr",{parentName:"tbody"},Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Update"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"109.25 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"3.96 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"31.45 s")),Object(i.b)("tr",{parentName:"tbody"},Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Delete"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"7.26 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"2.04 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"12.18 s")),Object(i.b)("tr",{parentName:"tbody"},Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"-----------------"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"------------"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"----------------"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"------------------")),Object(i.b)("tr",{parentName:"tbody"},Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(i.b)("strong",{parentName:"td"},"Together")),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"70.70 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"5.88 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"56.84 s")))),Object(i.b)("h2",{id:"994-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.9.4 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))),Object(i.b)("hr",null),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(i.b)("inlineCode",{parentName:"p"},"EFCore.BulkExtensions")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/borisdj/EFCore.BulkExtensions"}),"EFCore.BulkExtensions \u5f00\u6e90\u4ed3\u5e93"),"\u3002"))))}l.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/1e961311.fef4867f.js b/handbook/build/1e961311.fef4867f.js deleted file mode 100644 index 1752807277f..00000000000 --- a/handbook/build/1e961311.fef4867f.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[13],{142:function(e,t,n){"use strict";n.d(t,"a",(function(){return p})),n.d(t,"b",(function(){return m}));var a=n(0),r=n.n(a);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=r.a.createContext({}),l=function(e){var t=r.a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):b(b({},t),e)),n},p=function(e){var t=l(e.components);return r.a.createElement(s.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},O=r.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,i=e.originalType,c=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),p=l(n),O=a,m=p["".concat(c,".").concat(O)]||p[O]||d[O]||i;return n?r.a.createElement(m,b(b({ref:t},s),{},{components:n})):r.a.createElement(m,b({ref:t},s))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var i=n.length,c=new Array(i);c[0]=O;var b={};for(var o in t)hasOwnProperty.call(t,o)&&(b[o]=t[o]);b.originalType=e,b.mdxType="string"==typeof e?e:a,c[1]=b;for(var s=2;sEFCore.BulkExtensions \u4f7f\u7528",id:"992-efcorebulkextensions-\u4f7f\u7528",children:[{value:"9.9.2.1 \u5e38\u89c1\u6279\u91cf\u64cd\u4f5c",id:"9921-\u5e38\u89c1\u6279\u91cf\u64cd\u4f5c",children:[]},{value:"9.9.2.2 \u67e5\u8be2\u540e\u6279\u91cf\u64cd\u4f5c",id:"9922-\u67e5\u8be2\u540e\u6279\u91cf\u64cd\u4f5c",children:[]}]},{value:"9.9.3 \u6279\u91cf\u64cd\u4f5c\u6027\u80fd",id:"993-\u6279\u91cf\u64cd\u4f5c\u6027\u80fd",children:[]},{value:"9.9.4 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"994-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],s={rightToc:o};function l(e){var t=e.components,n=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},s,n,{components:t,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"991-\u5173\u4e8e\u6279\u91cf\u64cd\u4f5c"},"9.9.1 \u5173\u4e8e\u6279\u91cf\u64cd\u4f5c"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u9ed8\u8ba4\u53ea\u63d0\u4f9b\u5c0f\u6570\u636e\uff08100 \u4ee5\u5185\uff09\u6279\u91cf\u6570\u636e\u64cd\u4f5c\uff0c\u5982\u679c\u9700\u8981\u66f4\u5927\u7684\u6570\u636e\u6279\u91cf\u5904\u7406\uff0c\u63a8\u8350\u4f7f\u7528\u7b2c\u4e09\u65b9\u5305 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/borisdj/EFCore.BulkExtensions"}),"EFCore.BulkExtensions"),"\uff0c\u652f\u6301\u548c ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u65e0\u7f1d\u8854\u63a5\u3002"),Object(i.b)("h2",{id:"992-efcorebulkextensions-\u4f7f\u7528"},"9.9.2 ",Object(i.b)("inlineCode",{parentName:"h2"},"EFCore.BulkExtensions")," \u4f7f\u7528"),Object(i.b)("h3",{id:"9921-\u5e38\u89c1\u6279\u91cf\u64cd\u4f5c"},"9.9.2.1 \u5e38\u89c1\u6279\u91cf\u64cd\u4f5c"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u6279\u91cf\u63d2\u5165\nrepository.DbContext.BulkInsert(entitiesList);\nrepository.DbContext.BulkInsertAsync(entitiesList);\n\n// \u6279\u91cf\u66f4\u65b0\nrepository.DbContext.BulkUpdate(entitiesList);\nrepository.DbContext.BulkUpdateAsync(entitiesList);\n\n// \u6279\u91cf\u5220\u9664\nrepository.DbContext.BulkDelete(entitiesList);\nrepository.DbContext.BulkDeleteAsync(entitiesList);\n\n// \u6279\u91cf\u63d2\u5165\u6216\u66f4\u65b0\nrepository.DbContext.BulkInsertOrUpdate(entitiesList);\nrepository.DbContext.BulkInsertOrUpdateAsync(entitiesList);\n\n// \u6279\u91cf\u63d2\u5165\u6216\u66f4\u65b0\u6216\u5220\u9664\nrepository.DbContext.BulkInsertOrUpdateOrDelete(entitiesList);\nrepository.DbContext.BulkInsertOrUpdateOrDeleteAsync(entitiesList);\n\n// \u6279\u91cf\u8bfb\u53d6\u591a\u4e2a\u5b9e\u4f53\nrepository.DbContext.BulkRead(entitiesList);\nrepository.DbContext.BulkReadAsync(entitiesList);\n\n// \u6279\u91cf\u6e05\u7a7a\u8868\uff08\u614e\u7528\uff01\uff01\uff01\uff01\uff01\uff09\nrepository.DbContext.Truncate();\nrepository.DbContext.TruncateAsync();\n")),Object(i.b)("h3",{id:"9922-\u67e5\u8be2\u540e\u6279\u91cf\u64cd\u4f5c"},"9.9.2.2 \u67e5\u8be2\u540e\u6279\u91cf\u64cd\u4f5c"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// \u6839\u636e\u6761\u4ef6\u6279\u91cf\u5220\u9664\nrepository.Where(a => a.ItemId > 500).BatchDelete();\nawait repository.Where(a => a.ItemId > 500).BatchDeleteAsync();\n\n// \u6839\u636e\u6761\u4ef6\u6279\u91cf\u66f4\u65b0\nrepository.Where(a => a.ItemId <= 500).BatchUpdate(a => new Item { Quantity = a.Quantity + 100 });\nrepository.Where(a => a.ItemId <= 500).BatchUpdate(new Item { Description = "Updated" });\nawait repository.Where(a => a.ItemId <= 500).BatchUpdateAsync(new Item { Description = "Updated" });\n\n// \u6279\u91cf\u66f4\u65b0\u6307\u5b9a\u5217\nvar updateColumns = new List { nameof(Item.Quantity) };\nvar q = repository.Where(a => a.ItemId <= 500);\nint affected = q.BatchUpdate(new Item { Description = "Updated" }, updateColumns);\n')),Object(i.b)("h2",{id:"993-\u6279\u91cf\u64cd\u4f5c\u6027\u80fd"},"9.9.3 \u6279\u91cf\u64cd\u4f5c\u6027\u80fd"),Object(i.b)("table",null,Object(i.b)("thead",{parentName:"table"},Object(i.b)("tr",{parentName:"thead"},Object(i.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Operations\\Rows"),Object(i.b)("th",Object(a.a)({parentName:"tr"},{align:"right"}),"100,000 EF"),Object(i.b)("th",Object(a.a)({parentName:"tr"},{align:"right"}),"100,000 EFBulk"),Object(i.b)("th",Object(a.a)({parentName:"tr"},{align:"right"}),"1,000,000 EFBulk"))),Object(i.b)("tbody",{parentName:"table"},Object(i.b)("tr",{parentName:"tbody"},Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Insert"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"38.98 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"2.10 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"17.99 s")),Object(i.b)("tr",{parentName:"tbody"},Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Update"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"109.25 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"3.96 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"31.45 s")),Object(i.b)("tr",{parentName:"tbody"},Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Delete"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"7.26 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"2.04 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"12.18 s")),Object(i.b)("tr",{parentName:"tbody"},Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"-----------------"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"------------"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"----------------"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"------------------")),Object(i.b)("tr",{parentName:"tbody"},Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(i.b)("strong",{parentName:"td"},"Together")),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"70.70 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"5.88 s"),Object(i.b)("td",Object(a.a)({parentName:"tr"},{align:"right"}),"56.84 s")))),Object(i.b)("h2",{id:"994-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.9.4 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))),Object(i.b)("hr",null),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(i.b)("inlineCode",{parentName:"p"},"EFCore.BulkExtensions")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/borisdj/EFCore.BulkExtensions"}),"EFCore.BulkExtensions \u5f00\u6e90\u4ed3\u5e93"),"\u3002"))))}l.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/1ea356f4.44a77987.js b/handbook/build/1ea356f4.44a77987.js new file mode 100644 index 00000000000..3f9fc38ce47 --- /dev/null +++ b/handbook/build/1ea356f4.44a77987.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[14],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return d})),t.d(n,"b",(function(){return m}));var a=t(0),i=t.n(a);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function c(e){for(var n=1;n=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var s=i.a.createContext({}),l=function(e){var n=i.a.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},d=function(e){var n=l(e.components);return i.a.createElement(s.Provider,{value:n},e.children)},p={inlineCode:"code",wrapper:function(e){var n=e.children;return i.a.createElement(i.a.Fragment,{},n)}},u=i.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,r=e.originalType,o=e.parentName,s=b(e,["components","mdxType","originalType","parentName"]),d=l(t),u=a,m=d["".concat(o,".").concat(u)]||d[u]||p[u]||r;return t?i.a.createElement(m,c(c({ref:n},s),{},{components:t})):i.a.createElement(m,c({ref:n},s))}));function m(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var r=t.length,o=new Array(r);o[0]=u;var c={};for(var b in n)hasOwnProperty.call(n,b)&&(c[b]=n[b]);c.originalType=e,c.mdxType="string"==typeof e?e:a,o[1]=c;for(var s=2;sSaaS",id:"101-\u4ec0\u4e48\u662f-saas",children:[]},{value:"10.2 \u4ec0\u4e48\u662f\u591a\u79df\u6237",id:"102-\u4ec0\u4e48\u662f\u591a\u79df\u6237",children:[]},{value:"10.3 \u5b9e\u73b0\u591a\u79df\u6237\u65b9\u6848",id:"103-\u5b9e\u73b0\u591a\u79df\u6237\u65b9\u6848",children:[{value:"10.3.1 \u72ec\u7acb\u6570\u636e\u5e93(\u57fa\u4e8e Database \u7684\u65b9\u5f0f)",id:"1031-\u72ec\u7acb\u6570\u636e\u5e93\u57fa\u4e8e-database-\u7684\u65b9\u5f0f",children:[]},{value:"10.3.2 \u5171\u4eab\u6570\u636e\u5e93\uff0c\u72ec\u7acb Schema (\u57fa\u4e8e Schema \u7684\u65b9\u5f0f)",id:"1032-\u5171\u4eab\u6570\u636e\u5e93\uff0c\u72ec\u7acb-schema-\u57fa\u4e8e-schema-\u7684\u65b9\u5f0f",children:[]},{value:"10.3.3 \u5171\u4eab\u6570\u636e\u5e93\uff0c\u5171\u4eab Schema (\u57fa\u4e8e TenantId \u7684\u65b9\u5f0f)",id:"1033-\u5171\u4eab\u6570\u636e\u5e93\uff0c\u5171\u4eab-schema-\u57fa\u4e8e-tenantid-\u7684\u65b9\u5f0f",children:[]}]},{value:"10.4 \u591a\u79df\u6237\u4f7f\u7528\u65b9\u6848",id:"104-\u591a\u79df\u6237\u4f7f\u7528\u65b9\u6848",children:[]},{value:"10.5 \u57fa\u4e8e TenantId \u7684\u65b9\u5f0f",id:"105-\u57fa\u4e8e-tenantid-\u7684\u65b9\u5f0f",children:[{value:"10.5.1 \u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"1051-\u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"10.5.2 \u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"1052-\u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"10.5.3 \u6dfb\u52a0 Tenant \u79cd\u5b50\u6570\u636e",id:"1053-\u6dfb\u52a0-tenant-\u79cd\u5b50\u6570\u636e",children:[]},{value:"10.5.4 \u6839\u636e\u6a21\u578b\u521b\u5efa Tenant \u8868",id:"1054-\u6839\u636e\u6a21\u578b\u521b\u5efa-tenant-\u8868",children:[]},{value:"10.5.5 \u5b9e\u73b0 IMultiTenantOnTable \u63a5\u53e3",id:"1055-\u5b9e\u73b0-imultitenantontable-\u63a5\u53e3",children:[]},{value:"10.5.6 \u5b9e\u73b0 IModelBuilderFilter \u63a5\u53e3",id:"1056-\u5b9e\u73b0-imodelbuilderfilter-\u63a5\u53e3",children:[]},{value:"10.5.7 \u91cd\u5199 SavingChangesEvent \u4e8b\u4ef6\u65b9\u6cd5",id:"1057-\u91cd\u5199-savingchangesevent-\u4e8b\u4ef6\u65b9\u6cd5",children:[]}]},{value:"10.6 \u57fa\u4e8e Database \u7684\u65b9\u5f0f",id:"106-\u57fa\u4e8e-database-\u7684\u65b9\u5f0f",children:[{value:"10.6.1 \u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"1061-\u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"10.6.2 \u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"1062-\u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"10.6.3 \u6dfb\u52a0 Tenant \u79cd\u5b50\u6570\u636e",id:"1063-\u6dfb\u52a0-tenant-\u79cd\u5b50\u6570\u636e",children:[]},{value:"10.6.4 \u6839\u636e\u6a21\u578b\u521b\u5efa Tenant \u8868",id:"1064-\u6839\u636e\u6a21\u578b\u521b\u5efa-tenant-\u8868",children:[]},{value:"10.6.5 \u5b9e\u73b0 IMultiTenantOnDatabase \u63a5\u53e3",id:"1065-\u5b9e\u73b0-imultitenantondatabase-\u63a5\u53e3",children:[]},{value:"10.6.6 \u91cd\u5199 OnConfiguring \u65b9\u6cd5",id:"1066-\u91cd\u5199-onconfiguring-\u65b9\u6cd5",children:[]}]},{value:"10.7 \u57fa\u4e8e Schema \u7684\u65b9\u5f0f",id:"107-\u57fa\u4e8e-schema-\u7684\u65b9\u5f0f",children:[{value:"10.7.1 \u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"1071-\u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"10.7.2 \u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"1072-\u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"10.7.3 \u6dfb\u52a0 Tenant \u79cd\u5b50\u6570\u636e",id:"1073-\u6dfb\u52a0-tenant-\u79cd\u5b50\u6570\u636e",children:[]},{value:"10.7.4 \u6839\u636e\u6a21\u578b\u521b\u5efa Tenant \u8868",id:"1074-\u6839\u636e\u6a21\u578b\u521b\u5efa-tenant-\u8868",children:[]},{value:"10.7.5 \u5b9e\u73b0 IMultiTenantOnSchema \u63a5\u53e3",id:"1075-\u5b9e\u73b0-imultitenantonschema-\u63a5\u53e3",children:[]},{value:"10.7.6 \u5173\u4e8e Code First \u6570\u636e\u8fc1\u79fb",id:"1076-\u5173\u4e8e-code-first-\u6570\u636e\u8fc1\u79fb",children:[]}]},{value:"10.8 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"108-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],l={rightToc:s};function d(e){var n=e.components,t=Object(i.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},l,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"101-\u4ec0\u4e48\u662f-saas"},"10.1 \u4ec0\u4e48\u662f ",Object(r.b)("inlineCode",{parentName:"h2"},"SaaS")),Object(r.b)("blockquote",null,Object(r.b)("p",{parentName:"blockquote"},"SaaS \u662f Software-as-a-Service\uff08\u8f6f\u4ef6\u5373\u670d\u52a1\uff09\u7684\u7b80\u79f0\uff0c\u968f\u7740\u4e92\u8054\u7f51\u6280\u672f\u7684\u53d1\u5c55\u548c\u5e94\u7528\u8f6f\u4ef6\u7684\u6210\u719f\uff0c \u5728 21 \u4e16\u7eaa\u5f00\u59cb\u5174\u8d77\u7684\u4e00\u79cd\u5b8c\u5168\u521b\u65b0\u7684\u8f6f\u4ef6\u5e94\u7528\u6a21\u5f0f\u3002\u5b83\u4e0e\u201con-demand software\u201d\uff0cthe application service provider(ASP\uff0c\u5e94\u7528\u670d\u52a1\u63d0\u4f9b\u5546)\uff0chosted software(\u6258\u7ba1\u8f6f\u4ef6)\u6240\u5177\u6709\u76f8\u4f3c\u7684\u542b\u4e49\u3002"),Object(r.b)("p",{parentName:"blockquote"},"\u5b83\u662f\u4e00\u79cd\u901a\u8fc7 Internet \u63d0\u4f9b\u8f6f\u4ef6\u7684\u6a21\u5f0f\uff0c\u5382\u5546\u5c06\u5e94\u7528\u8f6f\u4ef6\u7edf\u4e00\u90e8\u7f72\u5728\u81ea\u5df1\u7684\u670d\u52a1\u5668\u4e0a\uff0c\u5ba2\u6237\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u5b9e\u9645\u9700\u6c42\uff0c\u901a\u8fc7\u4e92\u8054\u7f51\u5411\u5382\u5546\u5b9a\u8d2d\u6240\u9700\u7684\u5e94\u7528\u8f6f\u4ef6\u670d\u52a1\uff0c\u6309\u5b9a\u8d2d\u7684\u670d\u52a1\u591a\u5c11\u548c\u65f6\u95f4\u957f\u77ed\u5411\u5382\u5546\u652f\u4ed8\u8d39\u7528\uff0c\u5e76\u901a\u8fc7\u4e92\u8054\u7f51\u83b7\u5f97\u5382\u5546\u63d0\u4f9b\u7684\u670d\u52a1\u3002\u7528\u6237\u4e0d\u7528\u518d\u8d2d\u4e70\u8f6f\u4ef6\uff0c\u800c\u6539\u7528\u5411\u63d0\u4f9b\u5546\u79df\u7528\u57fa\u4e8e Web \u7684\u8f6f\u4ef6\uff0c\u6765\u7ba1\u7406\u4f01\u4e1a\u7ecf\u8425\u6d3b\u52a8\uff0c\u4e14\u65e0\u9700\u5bf9\u8f6f\u4ef6\u8fdb\u884c\u7ef4\u62a4\uff0c\u670d\u52a1\u63d0\u4f9b\u5546\u4f1a\u5168\u6743\u7ba1\u7406\u548c\u7ef4\u62a4\u8f6f\u4ef6\uff0c\u8f6f\u4ef6\u5382\u5546\u5728\u5411\u5ba2\u6237\u63d0\u4f9b\u4e92\u8054\u7f51\u5e94\u7528\u7684\u540c\u65f6\uff0c\u4e5f\u63d0\u4f9b\u8f6f\u4ef6\u7684\u79bb\u7ebf\u64cd\u4f5c\u548c\u672c\u5730\u6570\u636e\u5b58\u50a8\uff0c\u8ba9\u7528\u6237\u968f\u65f6\u968f\u5730\u90fd\u53ef\u4ee5\u4f7f\u7528\u5176\u5b9a\u8d2d\u7684\u8f6f\u4ef6\u548c\u670d\u52a1\u3002"),Object(r.b)("p",{parentName:"blockquote"},"\u5bf9\u4e8e\u8bb8\u591a\u5c0f\u578b\u4f01\u4e1a\u6765\u8bf4\uff0cSaaS \u662f\u91c7\u7528\u5148\u8fdb\u6280\u672f\u7684\u6700\u597d\u9014\u5f84\uff0c\u5b83\u6d88\u9664\u4e86\u4f01\u4e1a\u8d2d\u4e70\u3001\u6784\u5efa\u548c\u7ef4\u62a4\u57fa\u7840\u8bbe\u65bd\u548c\u5e94\u7528\u7a0b\u5e8f\u7684\u9700\u8981\u3002")),Object(r.b)("h2",{id:"102-\u4ec0\u4e48\u662f\u591a\u79df\u6237"},"10.2 \u4ec0\u4e48\u662f\u591a\u79df\u6237"),Object(r.b)("p",null,"\u591a\u79df\u6237\u6280\u672f\u6216\u79f0\u591a\u91cd\u79df\u8d41\u6280\u672f\uff0c\u7b80\u79f0 ",Object(r.b)("inlineCode",{parentName:"p"},"SaaS"),"\uff0c\u662f\u4e00\u79cd\u8f6f\u4ef6\u67b6\u6784\u6280\u672f\uff0c\u662f\u5b9e\u73b0\u5982\u4f55\u5728\u591a\u7528\u6237\u73af\u5883\u4e0b\uff08\u6b64\u5904\u7684\u591a\u7528\u6237\u4e00\u822c\u662f\u9762\u5411\u4f01\u4e1a\u7528\u6237\uff09\u5171\u7528\u76f8\u540c\u7684\u7cfb\u7edf\u6216\u7a0b\u5e8f\u7ec4\u4ef6\uff0c\u5e76\u4e14\u53ef\u786e\u4fdd\u5404\u7528\u6237\u95f4\u6570\u636e\u7684\u9694\u79bb\u6027\u3002"),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"\u7b80\u5355\u8bb2\uff1a\u5728\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u5355\u4e2a\u5e94\u7528\u5b9e\u4f8b\uff0c\u5b83\u4e3a\u591a\u4e2a\u79df\u6237\uff08\u5ba2\u6237\uff09\u63d0\u4f9b\u670d\u52a1\u3002"),"\u4ece\u5b9a\u4e49\u4e2d\u6211\u4eec\u53ef\u4ee5\u7406\u89e3\uff1a\u591a\u79df\u6237\u662f\u4e00\u79cd\u67b6\u6784\uff0c\u76ee\u7684\u662f\u4e3a\u4e86\u8ba9\u591a\u7528\u6237\u73af\u5883\u4e0b\u4f7f\u7528\u540c\u4e00\u5957\u7a0b\u5e8f\uff0c\u4e14\u4fdd\u8bc1\u7528\u6237\u95f4\u6570\u636e\u9694\u79bb\u3002\u90a3\u4e48\u91cd\u70b9\u5c31\u5f88\u6d45\u663e\u6613\u61c2\u4e86\uff0c\u591a\u79df\u6237\u7684\u91cd\u70b9\u5c31\u662f\u540c\u4e00\u5957\u7a0b\u5e8f\u4e0b\u5b9e\u73b0\u591a\u7528\u6237\u6570\u636e\u7684\u9694\u79bb\u3002"),Object(r.b)("h2",{id:"103-\u5b9e\u73b0\u591a\u79df\u6237\u65b9\u6848"},"10.3 \u5b9e\u73b0\u591a\u79df\u6237\u65b9\u6848"),Object(r.b)("h3",{id:"1031-\u72ec\u7acb\u6570\u636e\u5e93\u57fa\u4e8e-database-\u7684\u65b9\u5f0f"},"10.3.1 \u72ec\u7acb\u6570\u636e\u5e93(\u57fa\u4e8e ",Object(r.b)("inlineCode",{parentName:"h3"},"Database")," \u7684\u65b9\u5f0f)"),Object(r.b)("p",null,"\u8fd9\u662f\u7b2c\u4e00\u79cd\u65b9\u6848\uff0c\u5373\u4e00\u4e2a\u79df\u6237\u4e00\u4e2a\u6570\u636e\u5e93\uff0c\u8fd9\u79cd\u65b9\u6848\u7684\u7528\u6237\u6570\u636e\u9694\u79bb\u7ea7\u522b\u6700\u9ad8\uff0c\u5b89\u5168\u6027\u6700\u597d\uff0c\u4f46\u6210\u672c\u8f83\u9ad8\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},Object(r.b)("strong",{parentName:"p"},"\u4f18\u70b9\uff1a"),"\n\u4e3a\u4e0d\u540c\u7684\u79df\u6237\u63d0\u4f9b\u72ec\u7acb\u7684\u6570\u636e\u5e93\uff0c\u6709\u52a9\u4e8e\u7b80\u5316\u6570\u636e\u6a21\u578b\u7684\u6269\u5c55\u8bbe\u8ba1\uff0c\u6ee1\u8db3\u4e0d\u540c\u79df\u6237\u7684\u72ec\u7279\u9700\u6c42\uff1b\u5982\u679c\u51fa\u73b0\u6545\u969c\uff0c\u6062\u590d\u6570\u636e\u6bd4\u8f83\u7b80\u5355\u3002")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},Object(r.b)("strong",{parentName:"p"},"\u7f3a\u70b9\uff1a"),"\n\u589e\u591a\u4e86\u6570\u636e\u5e93\u7684\u5b89\u88c5\u6570\u91cf\uff0c\u968f\u4e4b\u5e26\u6765\u7ef4\u62a4\u6210\u672c\u548c\u8d2d\u7f6e\u6210\u672c\u7684\u589e\u52a0\u3002 \u8fd9\u79cd\u65b9\u6848\u4e0e\u4f20\u7edf\u7684\u4e00\u4e2a\u5ba2\u6237\u3001\u4e00\u5957\u6570\u636e\u3001\u4e00\u5957\u90e8\u7f72\u7c7b\u4f3c\uff0c\u5dee\u522b\u53ea\u5728\u4e8e\u8f6f\u4ef6\u7edf\u4e00\u90e8\u7f72\u5728\u8fd0\u8425\u5546\u90a3\u91cc\u3002\u5982\u679c\u9762\u5bf9\u7684\u662f\u94f6\u884c\u3001\u533b\u9662\u7b49\u9700\u8981\u975e\u5e38\u9ad8\u6570\u636e\u9694\u79bb\u7ea7\u522b\u7684\u79df\u6237\uff0c\u53ef\u4ee5\u9009\u62e9\u8fd9\u79cd\u6a21\u5f0f\uff0c\u63d0\u9ad8\u79df\u7528\u7684\u5b9a\u4ef7\u3002\u5982\u679c\u5b9a\u4ef7\u8f83\u4f4e\uff0c\u4ea7\u54c1\u8d70\u4f4e\u4ef7\u8def\u7ebf\uff0c\u8fd9\u79cd\u65b9\u6848\u4e00\u822c\u5bf9\u8fd0\u8425\u5546\u6765\u8bf4\u662f\u65e0\u6cd5\u627f\u53d7\u7684\u3002"))),Object(r.b)("h3",{id:"1032-\u5171\u4eab\u6570\u636e\u5e93\uff0c\u72ec\u7acb-schema-\u57fa\u4e8e-schema-\u7684\u65b9\u5f0f"},"10.3.2 \u5171\u4eab\u6570\u636e\u5e93\uff0c\u72ec\u7acb ",Object(r.b)("inlineCode",{parentName:"h3"},"Schema")," (\u57fa\u4e8e ",Object(r.b)("inlineCode",{parentName:"h3"},"Schema")," \u7684\u65b9\u5f0f)"),Object(r.b)("p",null,"\u8fd9\u662f\u7b2c\u4e8c\u79cd\u65b9\u6848\uff0c\u5373\u591a\u4e2a\u6216\u6240\u6709\u79df\u6237\u5171\u4eab ",Object(r.b)("inlineCode",{parentName:"p"},"Database"),"\uff0c\u4f46\u662f\u6bcf\u4e2a\u79df\u6237\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"Schema"),"\uff08\u4e5f\u53ef\u53eb\u505a\u4e00\u4e2a user\uff09\u3002\u5e95\u5c42\u5e93\u6bd4\u5982\u662f\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"SqlServer"),"\u3001",Object(r.b)("inlineCode",{parentName:"p"},"Oracle")," \u7b49\uff0c\u4e00\u4e2a\u6570\u636e\u5e93\u4e0b\u53ef\u4ee5\u6709\u591a\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"Schema"),"\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},Object(r.b)("strong",{parentName:"p"},"\u4f18\u70b9\uff1a"),"\n\u4e3a\u5b89\u5168\u6027\u8981\u6c42\u8f83\u9ad8\u7684\u79df\u6237\u63d0\u4f9b\u4e86\u4e00\u5b9a\u7a0b\u5ea6\u7684\u903b\u8f91\u6570\u636e\u9694\u79bb\uff0c\u5e76\u4e0d\u662f\u5b8c\u5168\u9694\u79bb\uff1b\u6bcf\u4e2a\u6570\u636e\u5e93\u53ef\u652f\u6301\u66f4\u591a\u7684\u79df\u6237\u6570\u91cf\u3002")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},Object(r.b)("strong",{parentName:"p"},"\u7f3a\u70b9\uff1a"),"\n\u5982\u679c\u51fa\u73b0\u6545\u969c\uff0c\u6570\u636e\u6062\u590d\u6bd4\u8f83\u56f0\u96be\uff0c\u56e0\u4e3a\u6062\u590d\u6570\u636e\u5e93\u5c06\u7275\u6d89\u5230\u5176\u4ed6\u79df\u6237\u7684\u6570\u636e\uff1b \u5982\u679c\u9700\u8981\u8de8\u79df\u6237\u7edf\u8ba1\u6570\u636e\uff0c\u5b58\u5728\u4e00\u5b9a\u56f0\u96be\u3002"))),Object(r.b)("h3",{id:"1033-\u5171\u4eab\u6570\u636e\u5e93\uff0c\u5171\u4eab-schema-\u57fa\u4e8e-tenantid-\u7684\u65b9\u5f0f"},"10.3.3 \u5171\u4eab\u6570\u636e\u5e93\uff0c\u5171\u4eab ",Object(r.b)("inlineCode",{parentName:"h3"},"Schema")," (\u57fa\u4e8e ",Object(r.b)("inlineCode",{parentName:"h3"},"TenantId")," \u7684\u65b9\u5f0f)"),Object(r.b)("p",null,"\u5171\u4eab\u6570\u636e\u8868 \u8fd9\u662f\u7b2c\u4e09\u79cd\u65b9\u6848\uff0c\u5373\u79df\u6237\u5171\u4eab\u540c\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"Database"),"\u3001\u540c\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"Schema"),"\uff0c\u4f46\u5728\u8868\u4e2d\u589e\u52a0 ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"TenantId"))," \u591a\u79df\u6237\u7684\u6570\u636e\u5b57\u6bb5\u3002\u8fd9\u662f\u5171\u4eab\u7a0b\u5ea6\u6700\u9ad8\u3001\u9694\u79bb\u7ea7\u522b\u6700\u4f4e\u7684\u6a21\u5f0f\u3002 \u5373\u6bcf\u63d2\u5165\u4e00\u6761\u6570\u636e\u65f6\u90fd\u9700\u8981\u6709\u4e00\u4e2a\u5ba2\u6237\u7684\u6807\u8bc6\u3002\u8fd9\u6837\u624d\u80fd\u5728\u540c\u4e00\u5f20\u8868\u4e2d\u533a\u5206\u51fa\u4e0d\u540c\u5ba2\u6237\u7684\u6570\u636e\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},Object(r.b)("strong",{parentName:"p"},"\u4f18\u70b9\uff1a"),"\n\u4e09\u79cd\u65b9\u6848\u6bd4\u8f83\uff0c\u7b2c\u4e09\u79cd\u65b9\u6848\u7684\u7ef4\u62a4\u548c\u8d2d\u7f6e\u6210\u672c\u6700\u4f4e\uff0c\u5141\u8bb8\u6bcf\u4e2a\u6570\u636e\u5e93\u652f\u6301\u7684\u79df\u6237\u6570\u91cf\u6700\u591a\u3002")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},Object(r.b)("strong",{parentName:"p"},"\u7f3a\u70b9\uff1a"),"\n\u9694\u79bb\u7ea7\u522b\u6700\u4f4e\uff0c\u5b89\u5168\u6027\u6700\u4f4e\uff0c\u9700\u8981\u5728\u8bbe\u8ba1\u5f00\u53d1\u65f6\u52a0\u5927\u5bf9\u5b89\u5168\u7684\u5f00\u53d1\u91cf\uff1b \u6570\u636e\u5907\u4efd\u548c\u6062\u590d\u6700\u56f0\u96be\uff0c\u9700\u8981\u9010\u8868\u9010\u6761\u5907\u4efd\u548c\u8fd8\u539f\u3002"))),Object(r.b)("h2",{id:"104-\u591a\u79df\u6237\u4f7f\u7528\u65b9\u6848"},"10.4 \u591a\u79df\u6237\u4f7f\u7528\u65b9\u6848"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u652f\u6301\u4ee5\u4e0a\u4e09\u79cd\u591a\u79df\u6237\u5b9e\u73b0\u65b9\u6848\uff0c\u4f7f\u7528\u7b80\u5355\u4e14\u5bb9\u6613\u7ef4\u62a4\u3002\u4e0b\u9762\u5206\u522b\u4f7f\u7528\u4e09\u79cd\u4e0d\u540c\u65b9\u5f0f\u6f14\u793a\u591a\u79df\u6237\u65b9\u6848\u7528\u6cd5\u3002"),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u8bf4\u660e")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u4e00\u65e6 ",Object(r.b)("inlineCode",{parentName:"p"},"\u6570\u636e\u5e93\u4e0a\u4e0b\u6587")," \u7c7b\u7ee7\u627f\u4e86\u79df\u6237\u4efb\u610f\u63a5\u53e3\uff0c\u5219\u81ea\u52a8\u5f00\u59cb\u591a\u79df\u6237\u529f\u80fd\u652f\u6301\u3002"))),Object(r.b)("h2",{id:"105-\u57fa\u4e8e-tenantid-\u7684\u65b9\u5f0f"},"10.5 \u57fa\u4e8e ",Object(r.b)("inlineCode",{parentName:"h2"},"TenantId")," \u7684\u65b9\u5f0f"),Object(r.b)("p",null,"\u6b64\u65b9\u5f0f\u5728\u4e2d\u5c0f\u578b\u4f01\u4e1a\u7cfb\u7edf\u4e2d\u6700\u4e3a\u5e38\u7528\uff0c\u7ef4\u62a4\u6210\u672c\u4f4e\uff0c\u8d2d\u7f6e\u6210\u672c\u4f4e\u3002"),Object(r.b)("h3",{id:"1051-\u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"10.5.1 \u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{6-7} title="Fur.EntityFramework.Core\\DbContexts\\MultiTenantDbContext.cs"',"{6-7}":!0,title:'"Fur.EntityFramework.Core\\DbContexts\\MultiTenantDbContext.cs"'}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class MultiTenantDbContext : AppDbContext\n {\n public MultiTenantDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u591a\u79df\u6237\u64cd\u4f5c\u5efa\u8bae\u5355\u72ec\u4e00\u4e2a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u800c\u4e14\u9700\u6307\u5b9a ",Object(r.b)("inlineCode",{parentName:"p"},"MultiTenantDbContextLocator")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u3002"))),Object(r.b)("h3",{id:"1052-\u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"10.5.2 \u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{14}","{14}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(600)]\n public sealed class FurEntityFrameworkCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddDatabaseAccessor(options =>\n {\n options.AddDbPool(DbProvider.Sqlite);\n options.AddDbPool(DbProvider.Sqlite);\n });\n }\n }\n}\n")),Object(r.b)("h3",{id:"1053-\u6dfb\u52a0-tenant-\u79cd\u5b50\u6570\u636e"},"10.5.3 \u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"h3"},"Tenant")," \u79cd\u5b50\u6570\u636e"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{8,12-28} title="Fur.EntityFramework.Core\\SeedDatas\\TenantSeedData.cs"',"{8,12-28}":!0,title:'"Fur.EntityFramework.Core\\SeedDatas\\TenantSeedData.cs"'}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing System;\nusing System.Collections.Generic;\n\nnamespace Fur.EntityFramework.Core\n{\n public class TenantSeedData : IEntitySeedData\n {\n public IEnumerable HasData(DbContext dbContext, Type dbContextLocator)\n {\n return new List\n {\n new Tenant\n {\n TenantId=Guid.Parse("383AFB88-F519-FFF8-B364-6D563BF3687F"),\n Name="\u9ed8\u8ba4\u79df\u6237",\n Host="localhost:44313",\n CreatedTime=DateTime.Parse("2020-10-06 20:19:07")\n },\n new Tenant\n {\n TenantId=Guid.Parse("C5798CB6-16D6-0F42-EB56-59C695353BC0"),\n Name="\u5176\u4ed6\u79df\u6237",\n Host="localhost:5000",\n CreatedTime=DateTime.Parse("2020-10-06 20:20:32")\n }\n };\n }\n }\n}\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u8be5\u6b65\u9aa4\u53ea\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Code First")," \u65b9\u5f0f\u6267\u884c\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Database First")," \u65e0\u9700\u914d\u7f6e\u79cd\u5b50\u6570\u636e\u3002"))),Object(r.b)("h3",{id:"1054-\u6839\u636e\u6a21\u578b\u521b\u5efa-tenant-\u8868"},"10.5.4 \u6839\u636e\u6a21\u578b\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"h3"},"Tenant")," \u8868"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Add-Migration add_tenant_table -Context MultiTenantDbContext\n")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database -Context MultiTenantDbContext\n")),Object(r.b)("h3",{id:"1055-\u5b9e\u73b0-imultitenantontable-\u63a5\u53e3"},"10.5.5 \u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"h3"},"IMultiTenantOnTable")," \u63a5\u53e3"),Object(r.b)("p",null,"\u5728\u9700\u8981\u591a\u79df\u6237\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u4e2d\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"p"},"IMultiTenantOnTable")," \u63a5\u53e3\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8,14-17}","{8,14-17}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing System;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class FurDbContext : AppDbContext, IMultiTenantOnTable, IModelBuilderFilter\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n public Guid? GetTenantId()\n {\n return base.Tenant?.TenantId ?? Guid.Empty;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"GetTenantId()")," \u65b9\u6cd5\u4e2d\uff0c\u9996\u5148\u83b7\u53d6\u8bf7\u6c42\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"\u4e3b\u673a\u5730\u5740"),"\uff0c\u7136\u540e\u6839\u636e\u4e3b\u673a\u5730\u5740\u67e5\u8be2\u5bf9\u5e94\u7684\u79df\u6237 ",Object(r.b)("inlineCode",{parentName:"p"},"TenantIdId"),"\uff0c\u907f\u514d\u591a\u6b21\u67e5\u8be2\u6570\u636e\u5e93\uff0c\u8fd9\u91cc\u4f7f\u7528\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"IMemoryCache")," \u5185\u5b58\u7f13\u5b58\u3002"),Object(r.b)("h3",{id:"1056-\u5b9e\u73b0-imodelbuilderfilter-\u63a5\u53e3"},"10.5.6 \u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"h3"},"IModelBuilderFilter")," \u63a5\u53e3"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"IModelBuilderFilter")," \u63a5\u53e3\u662f\u5168\u5c40\u67e5\u8be2\u8fc7\u6ee4\u5668\u5b9e\u73b0\u63a5\u53e3\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u914d\u7f6e\u5b9e\u4f53 ",Object(r.b)("inlineCode",{parentName:"p"},"TenantId")," \u8fc7\u6ee4\u5668"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{9,20-23}","{9,20-23}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class FurDbContext : AppDbContext, IMultiTenantOnTable, IModelBuilderFilter\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n public Guid? GetTenantId()\n {\n base.Tenant?.TenantId ?? Guid.Empty;\n }\n\n public void OnCreating(ModelBuilder modelBuilder, EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasQueryFilter(TenantIdQueryFilterExpression(entityBuilder, GetTenantId().Value));\n }\n }\n}\n')),Object(r.b)("h3",{id:"1057-\u91cd\u5199-savingchangesevent-\u4e8b\u4ef6\u65b9\u6cd5"},"10.5.7 \u91cd\u5199 ",Object(r.b)("inlineCode",{parentName:"h3"},"SavingChangesEvent")," \u4e8b\u4ef6\u65b9\u6cd5"),Object(r.b)("p",null,"\u901a\u8fc7\u4e0a\u9762\u7684\u6b65\u9aa4\uff0c\u6211\u4eec\u5df2\u7ecf\u89e3\u51b3\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"\u67e5\u8be2")," \u79df\u6237\u8fc7\u6ee4\u529f\u80fd\uff0c\u4f46\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"\u65b0\u589e")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"\u66f4\u65b0")," \u8fd8\u672a\u5904\u7406\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u65b0\u589e")," \u6570\u636e\u7684\u65f6\u5019\u81ea\u52a8\u8bbe\u7f6e ",Object(r.b)("inlineCode",{parentName:"li"},"TenantId")," \u7684\u503c"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u66f4\u65b0")," \u6570\u636e\u7684\u65f6\u5019\u6392\u9664 ",Object(r.b)("inlineCode",{parentName:"li"},"TenantId")," \u5c5e\u6027\u66f4\u65b0")),Object(r.b)("p",null,"\u5b9e\u73b0\u4e0a\u9762\u7684\u6b65\u9aa4\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u91cd\u5199 ",Object(r.b)("inlineCode",{parentName:"p"},"SavingChangesEvent")," \u4e8b\u4ef6\u65b9\u6cd5\u5373\u53ef\u3002"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{26-48}","{26-48}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Linq;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class FurDbContext : AppDbContext, IMultiTenantOnTable, IModelBuilderFilter\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n public Guid? GetTenantId()\n {\n base.Tenant?.TenantId ?? Guid.Empty;\n }\n\n public void OnCreating(ModelBuilder modelBuilder, EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasQueryFilter(TenantIdQueryFilterExpression(entityBuilder, GetTenantId().Value));\n }\n\n protected override void SavingChangesEvent(object sender, SavingChangesEventArgs e)\n {\n // \u83b7\u53d6\u5f53\u524d\u4e8b\u4ef6\u5bf9\u5e94\u4e0a\u4e0b\u6587\n var dbContext = sender as FurDbContext;\n\n // \u83b7\u53d6\u6240\u6709\u65b0\u589e\u548c\u66f4\u65b0\u7684\u5b9e\u4f53\n var entities = dbContext.ChangeTracker.Entries().Where(u => u.State == EntityState.Added || u.State == EntityState.Modified);\n\n foreach (var entity in entities)\n {\n switch (entity.State)\n {\n // \u81ea\u52a8\u8bbe\u7f6e\u79df\u6237Id\n case EntityState.Added:\n entity.Property(nameof(Entity.TenantId)).CurrentValue = GetTenantId();\n break;\n // \u6392\u9664\u79df\u6237Id\n case EntityState.Modified:\n entity.Property(nameof(Entity.TenantId)).IsModified = false;\n break;\n }\n }\n }\n }\n}\n')),Object(r.b)("img",{src:Object(o.a)("img/saas1.png")}),Object(r.b)("h2",{id:"106-\u57fa\u4e8e-database-\u7684\u65b9\u5f0f"},"10.6 \u57fa\u4e8e ",Object(r.b)("inlineCode",{parentName:"h2"},"Database")," \u7684\u65b9\u5f0f"),Object(r.b)("p",null,"\u6b64\u65b9\u5f0f\u5728\u4e2d\u5927\u578b\u4f01\u4e1a\u7cfb\u7edf\u4e2d\u6700\u4e3a\u5e38\u7528\uff0c\u4e00\u4e2a\u79df\u6237\uff08\u5ba2\u6237\uff09\u4e00\u4e2a\u72ec\u7acb\u7684\u6570\u636e\u5e93\u3002"),Object(r.b)("h3",{id:"1061-\u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"10.6.1 \u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{6-7} title="Fur.EntityFramework.Core\\DbContexts\\MultiTenantDbContext.cs"',"{6-7}":!0,title:'"Fur.EntityFramework.Core\\DbContexts\\MultiTenantDbContext.cs"'}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class MultiTenantDbContext : AppDbContext\n {\n public MultiTenantDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u591a\u79df\u6237\u64cd\u4f5c\u5efa\u8bae\u5355\u72ec\u4e00\u4e2a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u800c\u4e14\u9700\u6307\u5b9a ",Object(r.b)("inlineCode",{parentName:"p"},"MultiTenantDbContextLocator")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u3002"))),Object(r.b)("h3",{id:"1062-\u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"10.6.2 \u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{13,14}","{13,14}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(600)]\n public sealed class FurEntityFrameworkCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddDatabaseAccessor(options =>\n {\n options.AddDb(DbProvider.Sqlite);\n options.AddDbPool(DbProvider.Sqlite);\n });\n }\n }\n}\n")),Object(r.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u9700\u8981 ",Object(r.b)("inlineCode",{parentName:"p"},"Database")," \u591a\u79df\u6237\u65b9\u6848\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u9700\u8981\u91c7\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"AddDb")," \u6ce8\u518c\uff0c\u800c\u4e0d\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"AddDbPool"),"\u3002\u539f\u56e0\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"AddDbPool")," \u65b9\u5f0f\u6ce8\u518c\u540e\u7eed\u4e0d\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"p"},"OnConfiguring")," \u91cd\u5199\uff01\uff01\uff01"))),Object(r.b)("h3",{id:"1063-\u6dfb\u52a0-tenant-\u79cd\u5b50\u6570\u636e"},"10.6.3 \u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"h3"},"Tenant")," \u79cd\u5b50\u6570\u636e"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{8,12-30} title="Fur.EntityFramework.Core\\SeedDatas\\TenantSeedData.cs"',"{8,12-30}":!0,title:'"Fur.EntityFramework.Core\\SeedDatas\\TenantSeedData.cs"'}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing System;\nusing System.Collections.Generic;\n\nnamespace Fur.EntityFramework.Core\n{\n public class TenantSeedData : IEntitySeedData\n {\n public IEnumerable HasData(DbContext dbContext, Type dbContextLocator)\n {\n return new List\n {\n new Tenant\n {\n TenantId=Guid.Parse("383AFB88-F519-FFF8-B364-6D563BF3687F"),\n Name="\u9ed8\u8ba4\u79df\u6237",\n Host="localhost:44313",\n CreatedTime=DateTime.Parse("2020-10-06 20:19:07"),\n ConnectionString="Data Source=./Fur.db" // \u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32\n },\n new Tenant\n {\n TenantId=Guid.Parse("C5798CB6-16D6-0F42-EB56-59C695353BC0"),\n Name="\u5176\u4ed6\u79df\u6237",\n Host="localhost:5000",\n CreatedTime=DateTime.Parse("2020-10-06 20:20:32"),\n ConnectionString="Data Source=./Fur2.db" // \u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32\n }\n };\n }\n }\n}\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u8be5\u6b65\u9aa4\u53ea\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Code First")," \u65b9\u5f0f\u6267\u884c\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Database First")," \u65e0\u9700\u914d\u7f6e\u79cd\u5b50\u6570\u636e\u3002"))),Object(r.b)("h3",{id:"1064-\u6839\u636e\u6a21\u578b\u521b\u5efa-tenant-\u8868"},"10.6.4 \u6839\u636e\u6a21\u578b\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"h3"},"Tenant")," \u8868"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Add-Migration add_tenant_table -Context MultiTenantDbContext\n")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database -Context MultiTenantDbContext\n")),Object(r.b)("h3",{id:"1065-\u5b9e\u73b0-imultitenantondatabase-\u63a5\u53e3"},"10.6.5 \u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"h3"},"IMultiTenantOnDatabase")," \u63a5\u53e3"),Object(r.b)("p",null,"\u5728\u9700\u8981\u591a\u79df\u6237\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u4e2d\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"p"},"IMultiTenantOnDatabase")," \u63a5\u53e3\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{6,12-15}","{6,12-15}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n public class FurDbContext : AppDbContext, IMultiTenantOnDatabase\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n public string GetDatabaseConnectionString()\n {\n return base.Tenant?.ConnectionString;\n }\n }\n}\n")),Object(r.b)("h3",{id:"1066-\u91cd\u5199-onconfiguring-\u65b9\u6cd5"},"10.6.6 \u91cd\u5199 ",Object(r.b)("inlineCode",{parentName:"h3"},"OnConfiguring")," \u65b9\u6cd5"),Object(r.b)("p",null,"\u5728\u9700\u8981\u591a\u79df\u6237\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u4e2d\u91cd\u5199 ",Object(r.b)("inlineCode",{parentName:"p"},"OnConfiguring")," \u65b9\u6cd5\u5e76\u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{12-17}","{12-17}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n public class FurDbContext : AppDbContext, IMultiTenantOnDatabase\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)\n {\n optionsBuilder.UseSqlite(GetDatabaseConnectionString());\n\n base.OnConfiguring(optionsBuilder);\n }\n\n public string GetDatabaseConnectionString()\n {\n return base.Tenant?.ConnectionString;\n }\n }\n}\n")),Object(r.b)("img",{src:Object(o.a)("img/saas2.png")}),Object(r.b)("h2",{id:"107-\u57fa\u4e8e-schema-\u7684\u65b9\u5f0f"},"10.7 \u57fa\u4e8e ",Object(r.b)("inlineCode",{parentName:"h2"},"Schema")," \u7684\u65b9\u5f0f"),Object(r.b)("p",null,"\u6b64\u65b9\u5f0f\u5728\u4e2d\u5c0f\u578b\u4f01\u4e1a\u7cfb\u7edf\u4e2d\u4e5f\u4e0d\u5c11\u89c1\uff0c\u4e00\u4e2a\u79df\u6237\uff08\u5ba2\u6237\uff09\u5171\u4eab\u6570\u636e\u5e93\u4e14\u4e0d\u540c ",Object(r.b)("inlineCode",{parentName:"p"},"Schema"),"\u3002"),Object(r.b)("h3",{id:"1071-\u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"10.7.1 \u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{6-7} title="Fur.EntityFramework.Core\\DbContexts\\MultiTenantDbContext.cs"',"{6-7}":!0,title:'"Fur.EntityFramework.Core\\DbContexts\\MultiTenantDbContext.cs"'}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class MultiTenantDbContext : AppDbContext\n {\n public MultiTenantDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u591a\u79df\u6237\u64cd\u4f5c\u5efa\u8bae\u5355\u72ec\u4e00\u4e2a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u800c\u4e14\u9700\u6307\u5b9a ",Object(r.b)("inlineCode",{parentName:"p"},"MultiTenantDbContextLocator")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u3002"))),Object(r.b)("h3",{id:"1072-\u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"10.7.2 \u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{14}","{14}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(600)]\n public sealed class FurEntityFrameworkCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddDatabaseAccessor(options =>\n {\n options.AddDbPool(DbProvider.Sqlite);\n options.AddDbPool(DbProvider.Sqlite);\n });\n }\n }\n}\n")),Object(r.b)("h3",{id:"1073-\u6dfb\u52a0-tenant-\u79cd\u5b50\u6570\u636e"},"10.7.3 \u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"h3"},"Tenant")," \u79cd\u5b50\u6570\u636e"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{8,12-30} title="Fur.EntityFramework.Core\\SeedDatas\\TenantSeedData.cs"',"{8,12-30}":!0,title:'"Fur.EntityFramework.Core\\SeedDatas\\TenantSeedData.cs"'}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing System;\nusing System.Collections.Generic;\n\nnamespace Fur.EntityFramework.Core\n{\n public class TenantSeedData : IEntitySeedData\n {\n public IEnumerable HasData(DbContext dbContext, Type dbContextLocator)\n {\n return new List\n {\n new Tenant\n {\n TenantId=Guid.Parse("383AFB88-F519-FFF8-B364-6D563BF3687F"),\n Name="\u9ed8\u8ba4\u79df\u6237",\n Host="localhost:44313",\n CreatedTime=DateTime.Parse("2020-10-06 20:19:07"),\n Schema="dbo" // Schema\n },\n new Tenant\n {\n TenantId=Guid.Parse("C5798CB6-16D6-0F42-EB56-59C695353BC0"),\n Name="\u5176\u4ed6\u79df\u6237",\n Host="localhost:5000",\n CreatedTime=DateTime.Parse("2020-10-06 20:20:32"),\n Schema="fur" // Schema\n }\n };\n }\n }\n}\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u8be5\u6b65\u9aa4\u53ea\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Code First")," \u65b9\u5f0f\u6267\u884c\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Database First")," \u65e0\u9700\u914d\u7f6e\u79cd\u5b50\u6570\u636e\u3002"))),Object(r.b)("h3",{id:"1074-\u6839\u636e\u6a21\u578b\u521b\u5efa-tenant-\u8868"},"10.7.4 \u6839\u636e\u6a21\u578b\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"h3"},"Tenant")," \u8868"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Add-Migration add_tenant_table -Context MultiTenantDbContext\n")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database -Context MultiTenantDbContext\n")),Object(r.b)("h3",{id:"1075-\u5b9e\u73b0-imultitenantonschema-\u63a5\u53e3"},"10.7.5 \u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"h3"},"IMultiTenantOnSchema")," \u63a5\u53e3"),Object(r.b)("p",null,"\u5728\u9700\u8981\u591a\u79df\u6237\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u4e2d\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"p"},"IMultiTenantOnSchema")," \u63a5\u53e3\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{6,12-15}","{6,12-15}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class FurDbContext : AppDbContext, IMultiTenantOnSchema\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n public string GetSchemaName()\n {\n return base.Tenant?.Schema;\n }\n }\n}\n')),Object(r.b)("h3",{id:"1076-\u5173\u4e8e-code-first-\u6570\u636e\u8fc1\u79fb"},"10.7.6 \u5173\u4e8e ",Object(r.b)("inlineCode",{parentName:"h3"},"Code First \u6570\u636e\u8fc1\u79fb")),Object(r.b)("p",null,"\u57fa\u4e8e ",Object(r.b)("inlineCode",{parentName:"p"},"Schema")," \u65b9\u5f0f\u6bd4\u8f83\u7279\u522b\uff0c\u751f\u6210\u6570\u636e\u8fc1\u79fb\u7684\u65f6\u5019\u6ca1\u529e\u6cd5\u83b7\u53d6\u79df\u6237\u4fe1\u606f\uff0c\u6240\u4ee5\u5efa\u8bae",Object(r.b)("strong",{parentName:"p"},"\u5206\u5f00\u591a\u6b21\u8fc1\u79fb"),"\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'public string GetSchemaName()\n{\n return base.Tenant?.Schema?? "\u79df\u6237\u4e00Schema";\n}\n')),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'public string GetSchemaName()\n{\n return base.Tenant?.Schema?? "\u79df\u6237\u4e8cSchema";\n}\n')),Object(r.b)("p",null,"\u8fd9\u6837\u5c31\u53ef\u4ee5\u5728\u8fc1\u79fb\u7684\u65f6\u5019\u751f\u6210\u591a\u6b21\u8fc1\u79fb\u4e86\u3002"),Object(r.b)("h2",{id:"108-\u53cd\u9988\u4e0e\u5efa\u8bae"},"10.8 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/1ea356f4.853d079e.js b/handbook/build/1ea356f4.853d079e.js deleted file mode 100644 index 523fe25bb66..00000000000 --- a/handbook/build/1ea356f4.853d079e.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[14],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return d})),t.d(n,"b",(function(){return m}));var a=t(0),i=t.n(a);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function c(e){for(var n=1;n=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var s=i.a.createContext({}),l=function(e){var n=i.a.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},d=function(e){var n=l(e.components);return i.a.createElement(s.Provider,{value:n},e.children)},p={inlineCode:"code",wrapper:function(e){var n=e.children;return i.a.createElement(i.a.Fragment,{},n)}},u=i.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,r=e.originalType,o=e.parentName,s=b(e,["components","mdxType","originalType","parentName"]),d=l(t),u=a,m=d["".concat(o,".").concat(u)]||d[u]||p[u]||r;return t?i.a.createElement(m,c(c({ref:n},s),{},{components:t})):i.a.createElement(m,c({ref:n},s))}));function m(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var r=t.length,o=new Array(r);o[0]=u;var c={};for(var b in n)hasOwnProperty.call(n,b)&&(c[b]=n[b]);c.originalType=e,c.mdxType="string"==typeof e?e:a,o[1]=c;for(var s=2;sSaaS",id:"101-\u4ec0\u4e48\u662f-saas",children:[]},{value:"10.2 \u4ec0\u4e48\u662f\u591a\u79df\u6237",id:"102-\u4ec0\u4e48\u662f\u591a\u79df\u6237",children:[]},{value:"10.3 \u5b9e\u73b0\u591a\u79df\u6237\u65b9\u6848",id:"103-\u5b9e\u73b0\u591a\u79df\u6237\u65b9\u6848",children:[{value:"10.3.1 \u72ec\u7acb\u6570\u636e\u5e93(\u57fa\u4e8e Database \u7684\u65b9\u5f0f)",id:"1031-\u72ec\u7acb\u6570\u636e\u5e93\u57fa\u4e8e-database-\u7684\u65b9\u5f0f",children:[]},{value:"10.3.2 \u5171\u4eab\u6570\u636e\u5e93\uff0c\u72ec\u7acb Schema (\u57fa\u4e8e Schema \u7684\u65b9\u5f0f)",id:"1032-\u5171\u4eab\u6570\u636e\u5e93\uff0c\u72ec\u7acb-schema-\u57fa\u4e8e-schema-\u7684\u65b9\u5f0f",children:[]},{value:"10.3.3 \u5171\u4eab\u6570\u636e\u5e93\uff0c\u5171\u4eab Schema (\u57fa\u4e8e TenantId \u7684\u65b9\u5f0f)",id:"1033-\u5171\u4eab\u6570\u636e\u5e93\uff0c\u5171\u4eab-schema-\u57fa\u4e8e-tenantid-\u7684\u65b9\u5f0f",children:[]}]},{value:"10.4 \u591a\u79df\u6237\u4f7f\u7528\u65b9\u6848",id:"104-\u591a\u79df\u6237\u4f7f\u7528\u65b9\u6848",children:[]},{value:"10.5 \u57fa\u4e8e TenantId \u7684\u65b9\u5f0f",id:"105-\u57fa\u4e8e-tenantid-\u7684\u65b9\u5f0f",children:[{value:"10.5.1 \u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"1051-\u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"10.5.2 \u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"1052-\u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"10.5.3 \u6dfb\u52a0 Tenant \u79cd\u5b50\u6570\u636e",id:"1053-\u6dfb\u52a0-tenant-\u79cd\u5b50\u6570\u636e",children:[]},{value:"10.5.4 \u6839\u636e\u6a21\u578b\u521b\u5efa Tenant \u8868",id:"1054-\u6839\u636e\u6a21\u578b\u521b\u5efa-tenant-\u8868",children:[]},{value:"10.5.5 \u5b9e\u73b0 IMultiTenantOnTable \u63a5\u53e3",id:"1055-\u5b9e\u73b0-imultitenantontable-\u63a5\u53e3",children:[]},{value:"10.5.6 \u5b9e\u73b0 IModelBuilderFilter \u63a5\u53e3",id:"1056-\u5b9e\u73b0-imodelbuilderfilter-\u63a5\u53e3",children:[]},{value:"10.5.7 \u91cd\u5199 SavingChangesEvent \u4e8b\u4ef6\u65b9\u6cd5",id:"1057-\u91cd\u5199-savingchangesevent-\u4e8b\u4ef6\u65b9\u6cd5",children:[]}]},{value:"10.6 \u57fa\u4e8e Database \u7684\u65b9\u5f0f",id:"106-\u57fa\u4e8e-database-\u7684\u65b9\u5f0f",children:[{value:"10.6.1 \u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"1061-\u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"10.6.2 \u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"1062-\u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"10.6.3 \u6dfb\u52a0 Tenant \u79cd\u5b50\u6570\u636e",id:"1063-\u6dfb\u52a0-tenant-\u79cd\u5b50\u6570\u636e",children:[]},{value:"10.6.4 \u6839\u636e\u6a21\u578b\u521b\u5efa Tenant \u8868",id:"1064-\u6839\u636e\u6a21\u578b\u521b\u5efa-tenant-\u8868",children:[]},{value:"10.6.5 \u5b9e\u73b0 IMultiTenantOnDatabase \u63a5\u53e3",id:"1065-\u5b9e\u73b0-imultitenantondatabase-\u63a5\u53e3",children:[]},{value:"10.6.6 \u91cd\u5199 OnConfiguring \u65b9\u6cd5",id:"1066-\u91cd\u5199-onconfiguring-\u65b9\u6cd5",children:[]}]},{value:"10.7 \u57fa\u4e8e Schema \u7684\u65b9\u5f0f",id:"107-\u57fa\u4e8e-schema-\u7684\u65b9\u5f0f",children:[{value:"10.7.1 \u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"1071-\u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"10.7.2 \u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"1072-\u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"10.7.3 \u6dfb\u52a0 Tenant \u79cd\u5b50\u6570\u636e",id:"1073-\u6dfb\u52a0-tenant-\u79cd\u5b50\u6570\u636e",children:[]},{value:"10.7.4 \u6839\u636e\u6a21\u578b\u521b\u5efa Tenant \u8868",id:"1074-\u6839\u636e\u6a21\u578b\u521b\u5efa-tenant-\u8868",children:[]},{value:"10.7.5 \u5b9e\u73b0 IMultiTenantOnSchema \u63a5\u53e3",id:"1075-\u5b9e\u73b0-imultitenantonschema-\u63a5\u53e3",children:[]},{value:"10.7.6 \u5173\u4e8e Code First \u6570\u636e\u8fc1\u79fb",id:"1076-\u5173\u4e8e-code-first-\u6570\u636e\u8fc1\u79fb",children:[]}]},{value:"10.8 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"108-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],l={rightToc:s};function d(e){var n=e.components,t=Object(i.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},l,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"101-\u4ec0\u4e48\u662f-saas"},"10.1 \u4ec0\u4e48\u662f ",Object(r.b)("inlineCode",{parentName:"h2"},"SaaS")),Object(r.b)("blockquote",null,Object(r.b)("p",{parentName:"blockquote"},"SaaS \u662f Software-as-a-Service\uff08\u8f6f\u4ef6\u5373\u670d\u52a1\uff09\u7684\u7b80\u79f0\uff0c\u968f\u7740\u4e92\u8054\u7f51\u6280\u672f\u7684\u53d1\u5c55\u548c\u5e94\u7528\u8f6f\u4ef6\u7684\u6210\u719f\uff0c \u5728 21 \u4e16\u7eaa\u5f00\u59cb\u5174\u8d77\u7684\u4e00\u79cd\u5b8c\u5168\u521b\u65b0\u7684\u8f6f\u4ef6\u5e94\u7528\u6a21\u5f0f\u3002\u5b83\u4e0e\u201con-demand software\u201d\uff0cthe application service provider(ASP\uff0c\u5e94\u7528\u670d\u52a1\u63d0\u4f9b\u5546)\uff0chosted software(\u6258\u7ba1\u8f6f\u4ef6)\u6240\u5177\u6709\u76f8\u4f3c\u7684\u542b\u4e49\u3002"),Object(r.b)("p",{parentName:"blockquote"},"\u5b83\u662f\u4e00\u79cd\u901a\u8fc7 Internet \u63d0\u4f9b\u8f6f\u4ef6\u7684\u6a21\u5f0f\uff0c\u5382\u5546\u5c06\u5e94\u7528\u8f6f\u4ef6\u7edf\u4e00\u90e8\u7f72\u5728\u81ea\u5df1\u7684\u670d\u52a1\u5668\u4e0a\uff0c\u5ba2\u6237\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u5b9e\u9645\u9700\u6c42\uff0c\u901a\u8fc7\u4e92\u8054\u7f51\u5411\u5382\u5546\u5b9a\u8d2d\u6240\u9700\u7684\u5e94\u7528\u8f6f\u4ef6\u670d\u52a1\uff0c\u6309\u5b9a\u8d2d\u7684\u670d\u52a1\u591a\u5c11\u548c\u65f6\u95f4\u957f\u77ed\u5411\u5382\u5546\u652f\u4ed8\u8d39\u7528\uff0c\u5e76\u901a\u8fc7\u4e92\u8054\u7f51\u83b7\u5f97\u5382\u5546\u63d0\u4f9b\u7684\u670d\u52a1\u3002\u7528\u6237\u4e0d\u7528\u518d\u8d2d\u4e70\u8f6f\u4ef6\uff0c\u800c\u6539\u7528\u5411\u63d0\u4f9b\u5546\u79df\u7528\u57fa\u4e8e Web \u7684\u8f6f\u4ef6\uff0c\u6765\u7ba1\u7406\u4f01\u4e1a\u7ecf\u8425\u6d3b\u52a8\uff0c\u4e14\u65e0\u9700\u5bf9\u8f6f\u4ef6\u8fdb\u884c\u7ef4\u62a4\uff0c\u670d\u52a1\u63d0\u4f9b\u5546\u4f1a\u5168\u6743\u7ba1\u7406\u548c\u7ef4\u62a4\u8f6f\u4ef6\uff0c\u8f6f\u4ef6\u5382\u5546\u5728\u5411\u5ba2\u6237\u63d0\u4f9b\u4e92\u8054\u7f51\u5e94\u7528\u7684\u540c\u65f6\uff0c\u4e5f\u63d0\u4f9b\u8f6f\u4ef6\u7684\u79bb\u7ebf\u64cd\u4f5c\u548c\u672c\u5730\u6570\u636e\u5b58\u50a8\uff0c\u8ba9\u7528\u6237\u968f\u65f6\u968f\u5730\u90fd\u53ef\u4ee5\u4f7f\u7528\u5176\u5b9a\u8d2d\u7684\u8f6f\u4ef6\u548c\u670d\u52a1\u3002"),Object(r.b)("p",{parentName:"blockquote"},"\u5bf9\u4e8e\u8bb8\u591a\u5c0f\u578b\u4f01\u4e1a\u6765\u8bf4\uff0cSaaS \u662f\u91c7\u7528\u5148\u8fdb\u6280\u672f\u7684\u6700\u597d\u9014\u5f84\uff0c\u5b83\u6d88\u9664\u4e86\u4f01\u4e1a\u8d2d\u4e70\u3001\u6784\u5efa\u548c\u7ef4\u62a4\u57fa\u7840\u8bbe\u65bd\u548c\u5e94\u7528\u7a0b\u5e8f\u7684\u9700\u8981\u3002")),Object(r.b)("h2",{id:"102-\u4ec0\u4e48\u662f\u591a\u79df\u6237"},"10.2 \u4ec0\u4e48\u662f\u591a\u79df\u6237"),Object(r.b)("p",null,"\u591a\u79df\u6237\u6280\u672f\u6216\u79f0\u591a\u91cd\u79df\u8d41\u6280\u672f\uff0c\u7b80\u79f0 ",Object(r.b)("inlineCode",{parentName:"p"},"SaaS"),"\uff0c\u662f\u4e00\u79cd\u8f6f\u4ef6\u67b6\u6784\u6280\u672f\uff0c\u662f\u5b9e\u73b0\u5982\u4f55\u5728\u591a\u7528\u6237\u73af\u5883\u4e0b\uff08\u6b64\u5904\u7684\u591a\u7528\u6237\u4e00\u822c\u662f\u9762\u5411\u4f01\u4e1a\u7528\u6237\uff09\u5171\u7528\u76f8\u540c\u7684\u7cfb\u7edf\u6216\u7a0b\u5e8f\u7ec4\u4ef6\uff0c\u5e76\u4e14\u53ef\u786e\u4fdd\u5404\u7528\u6237\u95f4\u6570\u636e\u7684\u9694\u79bb\u6027\u3002"),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"\u7b80\u5355\u8bb2\uff1a\u5728\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u5355\u4e2a\u5e94\u7528\u5b9e\u4f8b\uff0c\u5b83\u4e3a\u591a\u4e2a\u79df\u6237\uff08\u5ba2\u6237\uff09\u63d0\u4f9b\u670d\u52a1\u3002"),"\u4ece\u5b9a\u4e49\u4e2d\u6211\u4eec\u53ef\u4ee5\u7406\u89e3\uff1a\u591a\u79df\u6237\u662f\u4e00\u79cd\u67b6\u6784\uff0c\u76ee\u7684\u662f\u4e3a\u4e86\u8ba9\u591a\u7528\u6237\u73af\u5883\u4e0b\u4f7f\u7528\u540c\u4e00\u5957\u7a0b\u5e8f\uff0c\u4e14\u4fdd\u8bc1\u7528\u6237\u95f4\u6570\u636e\u9694\u79bb\u3002\u90a3\u4e48\u91cd\u70b9\u5c31\u5f88\u6d45\u663e\u6613\u61c2\u4e86\uff0c\u591a\u79df\u6237\u7684\u91cd\u70b9\u5c31\u662f\u540c\u4e00\u5957\u7a0b\u5e8f\u4e0b\u5b9e\u73b0\u591a\u7528\u6237\u6570\u636e\u7684\u9694\u79bb\u3002"),Object(r.b)("h2",{id:"103-\u5b9e\u73b0\u591a\u79df\u6237\u65b9\u6848"},"10.3 \u5b9e\u73b0\u591a\u79df\u6237\u65b9\u6848"),Object(r.b)("h3",{id:"1031-\u72ec\u7acb\u6570\u636e\u5e93\u57fa\u4e8e-database-\u7684\u65b9\u5f0f"},"10.3.1 \u72ec\u7acb\u6570\u636e\u5e93(\u57fa\u4e8e ",Object(r.b)("inlineCode",{parentName:"h3"},"Database")," \u7684\u65b9\u5f0f)"),Object(r.b)("p",null,"\u8fd9\u662f\u7b2c\u4e00\u79cd\u65b9\u6848\uff0c\u5373\u4e00\u4e2a\u79df\u6237\u4e00\u4e2a\u6570\u636e\u5e93\uff0c\u8fd9\u79cd\u65b9\u6848\u7684\u7528\u6237\u6570\u636e\u9694\u79bb\u7ea7\u522b\u6700\u9ad8\uff0c\u5b89\u5168\u6027\u6700\u597d\uff0c\u4f46\u6210\u672c\u8f83\u9ad8\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},Object(r.b)("strong",{parentName:"p"},"\u4f18\u70b9\uff1a"),"\n\u4e3a\u4e0d\u540c\u7684\u79df\u6237\u63d0\u4f9b\u72ec\u7acb\u7684\u6570\u636e\u5e93\uff0c\u6709\u52a9\u4e8e\u7b80\u5316\u6570\u636e\u6a21\u578b\u7684\u6269\u5c55\u8bbe\u8ba1\uff0c\u6ee1\u8db3\u4e0d\u540c\u79df\u6237\u7684\u72ec\u7279\u9700\u6c42\uff1b\u5982\u679c\u51fa\u73b0\u6545\u969c\uff0c\u6062\u590d\u6570\u636e\u6bd4\u8f83\u7b80\u5355\u3002")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},Object(r.b)("strong",{parentName:"p"},"\u7f3a\u70b9\uff1a"),"\n\u589e\u591a\u4e86\u6570\u636e\u5e93\u7684\u5b89\u88c5\u6570\u91cf\uff0c\u968f\u4e4b\u5e26\u6765\u7ef4\u62a4\u6210\u672c\u548c\u8d2d\u7f6e\u6210\u672c\u7684\u589e\u52a0\u3002 \u8fd9\u79cd\u65b9\u6848\u4e0e\u4f20\u7edf\u7684\u4e00\u4e2a\u5ba2\u6237\u3001\u4e00\u5957\u6570\u636e\u3001\u4e00\u5957\u90e8\u7f72\u7c7b\u4f3c\uff0c\u5dee\u522b\u53ea\u5728\u4e8e\u8f6f\u4ef6\u7edf\u4e00\u90e8\u7f72\u5728\u8fd0\u8425\u5546\u90a3\u91cc\u3002\u5982\u679c\u9762\u5bf9\u7684\u662f\u94f6\u884c\u3001\u533b\u9662\u7b49\u9700\u8981\u975e\u5e38\u9ad8\u6570\u636e\u9694\u79bb\u7ea7\u522b\u7684\u79df\u6237\uff0c\u53ef\u4ee5\u9009\u62e9\u8fd9\u79cd\u6a21\u5f0f\uff0c\u63d0\u9ad8\u79df\u7528\u7684\u5b9a\u4ef7\u3002\u5982\u679c\u5b9a\u4ef7\u8f83\u4f4e\uff0c\u4ea7\u54c1\u8d70\u4f4e\u4ef7\u8def\u7ebf\uff0c\u8fd9\u79cd\u65b9\u6848\u4e00\u822c\u5bf9\u8fd0\u8425\u5546\u6765\u8bf4\u662f\u65e0\u6cd5\u627f\u53d7\u7684\u3002"))),Object(r.b)("h3",{id:"1032-\u5171\u4eab\u6570\u636e\u5e93\uff0c\u72ec\u7acb-schema-\u57fa\u4e8e-schema-\u7684\u65b9\u5f0f"},"10.3.2 \u5171\u4eab\u6570\u636e\u5e93\uff0c\u72ec\u7acb ",Object(r.b)("inlineCode",{parentName:"h3"},"Schema")," (\u57fa\u4e8e ",Object(r.b)("inlineCode",{parentName:"h3"},"Schema")," \u7684\u65b9\u5f0f)"),Object(r.b)("p",null,"\u8fd9\u662f\u7b2c\u4e8c\u79cd\u65b9\u6848\uff0c\u5373\u591a\u4e2a\u6216\u6240\u6709\u79df\u6237\u5171\u4eab ",Object(r.b)("inlineCode",{parentName:"p"},"Database"),"\uff0c\u4f46\u662f\u6bcf\u4e2a\u79df\u6237\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"Schema"),"\uff08\u4e5f\u53ef\u53eb\u505a\u4e00\u4e2a user\uff09\u3002\u5e95\u5c42\u5e93\u6bd4\u5982\u662f\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"SqlServer"),"\u3001",Object(r.b)("inlineCode",{parentName:"p"},"Oracle")," \u7b49\uff0c\u4e00\u4e2a\u6570\u636e\u5e93\u4e0b\u53ef\u4ee5\u6709\u591a\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"Schema"),"\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},Object(r.b)("strong",{parentName:"p"},"\u4f18\u70b9\uff1a"),"\n\u4e3a\u5b89\u5168\u6027\u8981\u6c42\u8f83\u9ad8\u7684\u79df\u6237\u63d0\u4f9b\u4e86\u4e00\u5b9a\u7a0b\u5ea6\u7684\u903b\u8f91\u6570\u636e\u9694\u79bb\uff0c\u5e76\u4e0d\u662f\u5b8c\u5168\u9694\u79bb\uff1b\u6bcf\u4e2a\u6570\u636e\u5e93\u53ef\u652f\u6301\u66f4\u591a\u7684\u79df\u6237\u6570\u91cf\u3002")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},Object(r.b)("strong",{parentName:"p"},"\u7f3a\u70b9\uff1a"),"\n\u5982\u679c\u51fa\u73b0\u6545\u969c\uff0c\u6570\u636e\u6062\u590d\u6bd4\u8f83\u56f0\u96be\uff0c\u56e0\u4e3a\u6062\u590d\u6570\u636e\u5e93\u5c06\u7275\u6d89\u5230\u5176\u4ed6\u79df\u6237\u7684\u6570\u636e\uff1b \u5982\u679c\u9700\u8981\u8de8\u79df\u6237\u7edf\u8ba1\u6570\u636e\uff0c\u5b58\u5728\u4e00\u5b9a\u56f0\u96be\u3002"))),Object(r.b)("h3",{id:"1033-\u5171\u4eab\u6570\u636e\u5e93\uff0c\u5171\u4eab-schema-\u57fa\u4e8e-tenantid-\u7684\u65b9\u5f0f"},"10.3.3 \u5171\u4eab\u6570\u636e\u5e93\uff0c\u5171\u4eab ",Object(r.b)("inlineCode",{parentName:"h3"},"Schema")," (\u57fa\u4e8e ",Object(r.b)("inlineCode",{parentName:"h3"},"TenantId")," \u7684\u65b9\u5f0f)"),Object(r.b)("p",null,"\u5171\u4eab\u6570\u636e\u8868 \u8fd9\u662f\u7b2c\u4e09\u79cd\u65b9\u6848\uff0c\u5373\u79df\u6237\u5171\u4eab\u540c\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"Database"),"\u3001\u540c\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"Schema"),"\uff0c\u4f46\u5728\u8868\u4e2d\u589e\u52a0 ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"TenantId"))," \u591a\u79df\u6237\u7684\u6570\u636e\u5b57\u6bb5\u3002\u8fd9\u662f\u5171\u4eab\u7a0b\u5ea6\u6700\u9ad8\u3001\u9694\u79bb\u7ea7\u522b\u6700\u4f4e\u7684\u6a21\u5f0f\u3002 \u5373\u6bcf\u63d2\u5165\u4e00\u6761\u6570\u636e\u65f6\u90fd\u9700\u8981\u6709\u4e00\u4e2a\u5ba2\u6237\u7684\u6807\u8bc6\u3002\u8fd9\u6837\u624d\u80fd\u5728\u540c\u4e00\u5f20\u8868\u4e2d\u533a\u5206\u51fa\u4e0d\u540c\u5ba2\u6237\u7684\u6570\u636e\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},Object(r.b)("strong",{parentName:"p"},"\u4f18\u70b9\uff1a"),"\n\u4e09\u79cd\u65b9\u6848\u6bd4\u8f83\uff0c\u7b2c\u4e09\u79cd\u65b9\u6848\u7684\u7ef4\u62a4\u548c\u8d2d\u7f6e\u6210\u672c\u6700\u4f4e\uff0c\u5141\u8bb8\u6bcf\u4e2a\u6570\u636e\u5e93\u652f\u6301\u7684\u79df\u6237\u6570\u91cf\u6700\u591a\u3002")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},Object(r.b)("strong",{parentName:"p"},"\u7f3a\u70b9\uff1a"),"\n\u9694\u79bb\u7ea7\u522b\u6700\u4f4e\uff0c\u5b89\u5168\u6027\u6700\u4f4e\uff0c\u9700\u8981\u5728\u8bbe\u8ba1\u5f00\u53d1\u65f6\u52a0\u5927\u5bf9\u5b89\u5168\u7684\u5f00\u53d1\u91cf\uff1b \u6570\u636e\u5907\u4efd\u548c\u6062\u590d\u6700\u56f0\u96be\uff0c\u9700\u8981\u9010\u8868\u9010\u6761\u5907\u4efd\u548c\u8fd8\u539f\u3002"))),Object(r.b)("h2",{id:"104-\u591a\u79df\u6237\u4f7f\u7528\u65b9\u6848"},"10.4 \u591a\u79df\u6237\u4f7f\u7528\u65b9\u6848"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u652f\u6301\u4ee5\u4e0a\u4e09\u79cd\u591a\u79df\u6237\u5b9e\u73b0\u65b9\u6848\uff0c\u4f7f\u7528\u7b80\u5355\u4e14\u5bb9\u6613\u7ef4\u62a4\u3002\u4e0b\u9762\u5206\u522b\u4f7f\u7528\u4e09\u79cd\u4e0d\u540c\u65b9\u5f0f\u6f14\u793a\u591a\u79df\u6237\u65b9\u6848\u7528\u6cd5\u3002"),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u8bf4\u660e")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u4e00\u65e6 ",Object(r.b)("inlineCode",{parentName:"p"},"\u6570\u636e\u5e93\u4e0a\u4e0b\u6587")," \u7c7b\u7ee7\u627f\u4e86\u79df\u6237\u4efb\u610f\u63a5\u53e3\uff0c\u5219\u81ea\u52a8\u5f00\u59cb\u591a\u79df\u6237\u529f\u80fd\u652f\u6301\u3002"))),Object(r.b)("h2",{id:"105-\u57fa\u4e8e-tenantid-\u7684\u65b9\u5f0f"},"10.5 \u57fa\u4e8e ",Object(r.b)("inlineCode",{parentName:"h2"},"TenantId")," \u7684\u65b9\u5f0f"),Object(r.b)("p",null,"\u6b64\u65b9\u5f0f\u5728\u4e2d\u5c0f\u578b\u4f01\u4e1a\u7cfb\u7edf\u4e2d\u6700\u4e3a\u5e38\u7528\uff0c\u7ef4\u62a4\u6210\u672c\u4f4e\uff0c\u8d2d\u7f6e\u6210\u672c\u4f4e\u3002"),Object(r.b)("h3",{id:"1051-\u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"10.5.1 \u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{6-7} title="Fur.EntityFramework.Core\\DbContexts\\MultiTenantDbContext.cs"',"{6-7}":!0,title:'"Fur.EntityFramework.Core\\DbContexts\\MultiTenantDbContext.cs"'}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class MultiTenantDbContext : AppDbContext\n {\n public MultiTenantDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u591a\u79df\u6237\u64cd\u4f5c\u5efa\u8bae\u5355\u72ec\u4e00\u4e2a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u800c\u4e14\u9700\u6307\u5b9a ",Object(r.b)("inlineCode",{parentName:"p"},"MultiTenantDbContextLocator")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u3002"))),Object(r.b)("h3",{id:"1052-\u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"10.5.2 \u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{14}","{14}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(600)]\n public sealed class FurEntityFrameworkCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddDatabaseAccessor(options =>\n {\n options.AddDbPool(DbProvider.Sqlite);\n options.AddDbPool(DbProvider.Sqlite);\n });\n }\n }\n}\n")),Object(r.b)("h3",{id:"1053-\u6dfb\u52a0-tenant-\u79cd\u5b50\u6570\u636e"},"10.5.3 \u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"h3"},"Tenant")," \u79cd\u5b50\u6570\u636e"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{8,12-28} title="Fur.EntityFramework.Core\\SeedDatas\\TenantSeedData.cs"',"{8,12-28}":!0,title:'"Fur.EntityFramework.Core\\SeedDatas\\TenantSeedData.cs"'}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing System;\nusing System.Collections.Generic;\n\nnamespace Fur.EntityFramework.Core\n{\n public class TenantSeedData : IEntitySeedData\n {\n public IEnumerable HasData(DbContext dbContext, Type dbContextLocator)\n {\n return new List\n {\n new Tenant\n {\n TenantId=Guid.Parse("383AFB88-F519-FFF8-B364-6D563BF3687F"),\n Name="\u9ed8\u8ba4\u79df\u6237",\n Host="localhost:44313",\n CreatedTime=DateTime.Parse("2020-10-06 20:19:07")\n },\n new Tenant\n {\n TenantId=Guid.Parse("C5798CB6-16D6-0F42-EB56-59C695353BC0"),\n Name="\u5176\u4ed6\u79df\u6237",\n Host="localhost:5000",\n CreatedTime=DateTime.Parse("2020-10-06 20:20:32")\n }\n };\n }\n }\n}\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u8be5\u6b65\u9aa4\u53ea\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Code First")," \u65b9\u5f0f\u6267\u884c\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Database First")," \u65e0\u9700\u914d\u7f6e\u79cd\u5b50\u6570\u636e\u3002"))),Object(r.b)("h3",{id:"1054-\u6839\u636e\u6a21\u578b\u521b\u5efa-tenant-\u8868"},"10.5.4 \u6839\u636e\u6a21\u578b\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"h3"},"Tenant")," \u8868"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Add-Migration add_tenant_table -Context MultiTenantDbContext\n")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database -Context MultiTenantDbContext\n")),Object(r.b)("h3",{id:"1055-\u5b9e\u73b0-imultitenantontable-\u63a5\u53e3"},"10.5.5 \u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"h3"},"IMultiTenantOnTable")," \u63a5\u53e3"),Object(r.b)("p",null,"\u5728\u9700\u8981\u591a\u79df\u6237\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u4e2d\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"p"},"IMultiTenantOnTable")," \u63a5\u53e3\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8,14-17}","{8,14-17}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing System;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class FurDbContext : AppDbContext, IMultiTenantOnTable, IModelBuilderFilter\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n public Guid? GetTenantId()\n {\n return base.Tenant?.TenantId ?? Guid.Empty;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"GetTenantId()")," \u65b9\u6cd5\u4e2d\uff0c\u9996\u5148\u83b7\u53d6\u8bf7\u6c42\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"\u4e3b\u673a\u5730\u5740"),"\uff0c\u7136\u540e\u6839\u636e\u4e3b\u673a\u5730\u5740\u67e5\u8be2\u5bf9\u5e94\u7684\u79df\u6237 ",Object(r.b)("inlineCode",{parentName:"p"},"TenantIdId"),"\uff0c\u907f\u514d\u591a\u6b21\u67e5\u8be2\u6570\u636e\u5e93\uff0c\u8fd9\u91cc\u4f7f\u7528\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"IMemoryCache")," \u5185\u5b58\u7f13\u5b58\u3002"),Object(r.b)("h3",{id:"1056-\u5b9e\u73b0-imodelbuilderfilter-\u63a5\u53e3"},"10.5.6 \u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"h3"},"IModelBuilderFilter")," \u63a5\u53e3"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"IModelBuilderFilter")," \u63a5\u53e3\u662f\u5168\u5c40\u67e5\u8be2\u8fc7\u6ee4\u5668\u5b9e\u73b0\u63a5\u53e3\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u914d\u7f6e\u5b9e\u4f53 ",Object(r.b)("inlineCode",{parentName:"p"},"TenantId")," \u8fc7\u6ee4\u5668"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{9,20-23}","{9,20-23}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class FurDbContext : AppDbContext, IMultiTenantOnTable, IModelBuilderFilter\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n public Guid? GetTenantId()\n {\n base.Tenant?.TenantId ?? Guid.Empty;\n }\n\n public void OnCreating(ModelBuilder modelBuilder, EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasQueryFilter(TenantIdQueryFilterExpression(entityBuilder, GetTenantId().Value));\n }\n }\n}\n')),Object(r.b)("h3",{id:"1057-\u91cd\u5199-savingchangesevent-\u4e8b\u4ef6\u65b9\u6cd5"},"10.5.7 \u91cd\u5199 ",Object(r.b)("inlineCode",{parentName:"h3"},"SavingChangesEvent")," \u4e8b\u4ef6\u65b9\u6cd5"),Object(r.b)("p",null,"\u901a\u8fc7\u4e0a\u9762\u7684\u6b65\u9aa4\uff0c\u6211\u4eec\u5df2\u7ecf\u89e3\u51b3\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"\u67e5\u8be2")," \u79df\u6237\u8fc7\u6ee4\u529f\u80fd\uff0c\u4f46\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"\u65b0\u589e")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"\u66f4\u65b0")," \u8fd8\u672a\u5904\u7406\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u65b0\u589e")," \u6570\u636e\u7684\u65f6\u5019\u81ea\u52a8\u8bbe\u7f6e ",Object(r.b)("inlineCode",{parentName:"li"},"TenantId")," \u7684\u503c"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u66f4\u65b0")," \u6570\u636e\u7684\u65f6\u5019\u6392\u9664 ",Object(r.b)("inlineCode",{parentName:"li"},"TenantId")," \u5c5e\u6027\u66f4\u65b0")),Object(r.b)("p",null,"\u5b9e\u73b0\u4e0a\u9762\u7684\u6b65\u9aa4\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u91cd\u5199 ",Object(r.b)("inlineCode",{parentName:"p"},"SavingChangesEvent")," \u4e8b\u4ef6\u65b9\u6cd5\u5373\u53ef\u3002"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{26-48}","{26-48}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Linq;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class FurDbContext : AppDbContext, IMultiTenantOnTable, IModelBuilderFilter\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n public Guid? GetTenantId()\n {\n base.Tenant?.TenantId ?? Guid.Empty;\n }\n\n public void OnCreating(ModelBuilder modelBuilder, EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasQueryFilter(TenantIdQueryFilterExpression(entityBuilder, GetTenantId().Value));\n }\n\n protected override void SavingChangesEvent(object sender, SavingChangesEventArgs e)\n {\n // \u83b7\u53d6\u5f53\u524d\u4e8b\u4ef6\u5bf9\u5e94\u4e0a\u4e0b\u6587\n var dbContext = sender as FurDbContext;\n\n // \u83b7\u53d6\u6240\u6709\u65b0\u589e\u548c\u66f4\u65b0\u7684\u5b9e\u4f53\n var entities = dbContext.ChangeTracker.Entries().Where(u => u.State == EntityState.Added || u.State == EntityState.Modified);\n\n foreach (var entity in entities)\n {\n switch (entity.State)\n {\n // \u81ea\u52a8\u8bbe\u7f6e\u79df\u6237Id\n case EntityState.Added:\n entity.Property(nameof(Entity.TenantId)).CurrentValue = GetTenantId();\n break;\n // \u6392\u9664\u79df\u6237Id\n case EntityState.Modified:\n entity.Property(nameof(Entity.TenantId)).IsModified = false;\n break;\n }\n }\n }\n }\n}\n')),Object(r.b)("img",{src:Object(o.a)("img/saas1.png")}),Object(r.b)("h2",{id:"106-\u57fa\u4e8e-database-\u7684\u65b9\u5f0f"},"10.6 \u57fa\u4e8e ",Object(r.b)("inlineCode",{parentName:"h2"},"Database")," \u7684\u65b9\u5f0f"),Object(r.b)("p",null,"\u6b64\u65b9\u5f0f\u5728\u4e2d\u5927\u578b\u4f01\u4e1a\u7cfb\u7edf\u4e2d\u6700\u4e3a\u5e38\u7528\uff0c\u4e00\u4e2a\u79df\u6237\uff08\u5ba2\u6237\uff09\u4e00\u4e2a\u72ec\u7acb\u7684\u6570\u636e\u5e93\u3002"),Object(r.b)("h3",{id:"1061-\u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"10.6.1 \u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{6-7} title="Fur.EntityFramework.Core\\DbContexts\\MultiTenantDbContext.cs"',"{6-7}":!0,title:'"Fur.EntityFramework.Core\\DbContexts\\MultiTenantDbContext.cs"'}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class MultiTenantDbContext : AppDbContext\n {\n public MultiTenantDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u591a\u79df\u6237\u64cd\u4f5c\u5efa\u8bae\u5355\u72ec\u4e00\u4e2a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u800c\u4e14\u9700\u6307\u5b9a ",Object(r.b)("inlineCode",{parentName:"p"},"MultiTenantDbContextLocator")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u3002"))),Object(r.b)("h3",{id:"1062-\u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"10.6.2 \u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{13,14}","{13,14}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(600)]\n public sealed class FurEntityFrameworkCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddDatabaseAccessor(options =>\n {\n options.AddDb(DbProvider.Sqlite);\n options.AddDbPool(DbProvider.Sqlite);\n });\n }\n }\n}\n")),Object(r.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u9700\u8981 ",Object(r.b)("inlineCode",{parentName:"p"},"Database")," \u591a\u79df\u6237\u65b9\u6848\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u9700\u8981\u91c7\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"AddDb")," \u6ce8\u518c\uff0c\u800c\u4e0d\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"AddDbPool"),"\u3002\u539f\u56e0\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"AddDbPool")," \u65b9\u5f0f\u6ce8\u518c\u540e\u7eed\u4e0d\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"p"},"OnConfiguring")," \u91cd\u5199\uff01\uff01\uff01"))),Object(r.b)("h3",{id:"1063-\u6dfb\u52a0-tenant-\u79cd\u5b50\u6570\u636e"},"10.6.3 \u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"h3"},"Tenant")," \u79cd\u5b50\u6570\u636e"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{8,12-30} title="Fur.EntityFramework.Core\\SeedDatas\\TenantSeedData.cs"',"{8,12-30}":!0,title:'"Fur.EntityFramework.Core\\SeedDatas\\TenantSeedData.cs"'}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing System;\nusing System.Collections.Generic;\n\nnamespace Fur.EntityFramework.Core\n{\n public class TenantSeedData : IEntitySeedData\n {\n public IEnumerable HasData(DbContext dbContext, Type dbContextLocator)\n {\n return new List\n {\n new Tenant\n {\n TenantId=Guid.Parse("383AFB88-F519-FFF8-B364-6D563BF3687F"),\n Name="\u9ed8\u8ba4\u79df\u6237",\n Host="localhost:44313",\n CreatedTime=DateTime.Parse("2020-10-06 20:19:07"),\n ConnectionString="Data Source=./Fur.db" // \u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32\n },\n new Tenant\n {\n TenantId=Guid.Parse("C5798CB6-16D6-0F42-EB56-59C695353BC0"),\n Name="\u5176\u4ed6\u79df\u6237",\n Host="localhost:5000",\n CreatedTime=DateTime.Parse("2020-10-06 20:20:32"),\n ConnectionString="Data Source=./Fur2.db" // \u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32\n }\n };\n }\n }\n}\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u8be5\u6b65\u9aa4\u53ea\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Code First")," \u65b9\u5f0f\u6267\u884c\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Database First")," \u65e0\u9700\u914d\u7f6e\u79cd\u5b50\u6570\u636e\u3002"))),Object(r.b)("h3",{id:"1064-\u6839\u636e\u6a21\u578b\u521b\u5efa-tenant-\u8868"},"10.6.4 \u6839\u636e\u6a21\u578b\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"h3"},"Tenant")," \u8868"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Add-Migration add_tenant_table -Context MultiTenantDbContext\n")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database -Context MultiTenantDbContext\n")),Object(r.b)("h3",{id:"1065-\u5b9e\u73b0-imultitenantondatabase-\u63a5\u53e3"},"10.6.5 \u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"h3"},"IMultiTenantOnDatabase")," \u63a5\u53e3"),Object(r.b)("p",null,"\u5728\u9700\u8981\u591a\u79df\u6237\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u4e2d\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"p"},"IMultiTenantOnDatabase")," \u63a5\u53e3\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{6,12-15}","{6,12-15}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n public class FurDbContext : AppDbContext, IMultiTenantOnDatabase\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n public string GetDatabaseConnectionString()\n {\n return base.Tenant?.ConnectionString;\n }\n }\n}\n")),Object(r.b)("h3",{id:"1066-\u91cd\u5199-onconfiguring-\u65b9\u6cd5"},"10.6.6 \u91cd\u5199 ",Object(r.b)("inlineCode",{parentName:"h3"},"OnConfiguring")," \u65b9\u6cd5"),Object(r.b)("p",null,"\u5728\u9700\u8981\u591a\u79df\u6237\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u4e2d\u91cd\u5199 ",Object(r.b)("inlineCode",{parentName:"p"},"OnConfiguring")," \u65b9\u6cd5\u5e76\u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{12-17}","{12-17}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n public class FurDbContext : AppDbContext, IMultiTenantOnDatabase\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)\n {\n optionsBuilder.UseSqlite(GetDatabaseConnectionString());\n\n base.OnConfiguring(optionsBuilder);\n }\n\n public string GetDatabaseConnectionString()\n {\n return base.Tenant?.ConnectionString;\n }\n }\n}\n")),Object(r.b)("img",{src:Object(o.a)("img/saas2.png")}),Object(r.b)("h2",{id:"107-\u57fa\u4e8e-schema-\u7684\u65b9\u5f0f"},"10.7 \u57fa\u4e8e ",Object(r.b)("inlineCode",{parentName:"h2"},"Schema")," \u7684\u65b9\u5f0f"),Object(r.b)("p",null,"\u6b64\u65b9\u5f0f\u5728\u4e2d\u5c0f\u578b\u4f01\u4e1a\u7cfb\u7edf\u4e2d\u4e5f\u4e0d\u5c11\u89c1\uff0c\u4e00\u4e2a\u79df\u6237\uff08\u5ba2\u6237\uff09\u5171\u4eab\u6570\u636e\u5e93\u4e14\u4e0d\u540c ",Object(r.b)("inlineCode",{parentName:"p"},"Schema"),"\u3002"),Object(r.b)("h3",{id:"1071-\u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"10.7.1 \u521b\u5efa\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{6-7} title="Fur.EntityFramework.Core\\DbContexts\\MultiTenantDbContext.cs"',"{6-7}":!0,title:'"Fur.EntityFramework.Core\\DbContexts\\MultiTenantDbContext.cs"'}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class MultiTenantDbContext : AppDbContext\n {\n public MultiTenantDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u591a\u79df\u6237\u64cd\u4f5c\u5efa\u8bae\u5355\u72ec\u4e00\u4e2a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u800c\u4e14\u9700\u6307\u5b9a ",Object(r.b)("inlineCode",{parentName:"p"},"MultiTenantDbContextLocator")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u3002"))),Object(r.b)("h3",{id:"1072-\u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"10.7.2 \u6ce8\u518c\u591a\u79df\u6237\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{14}","{14}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(600)]\n public sealed class FurEntityFrameworkCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddDatabaseAccessor(options =>\n {\n options.AddDbPool(DbProvider.Sqlite);\n options.AddDbPool(DbProvider.Sqlite);\n });\n }\n }\n}\n")),Object(r.b)("h3",{id:"1073-\u6dfb\u52a0-tenant-\u79cd\u5b50\u6570\u636e"},"10.7.3 \u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"h3"},"Tenant")," \u79cd\u5b50\u6570\u636e"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{8,12-30} title="Fur.EntityFramework.Core\\SeedDatas\\TenantSeedData.cs"',"{8,12-30}":!0,title:'"Fur.EntityFramework.Core\\SeedDatas\\TenantSeedData.cs"'}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing System;\nusing System.Collections.Generic;\n\nnamespace Fur.EntityFramework.Core\n{\n public class TenantSeedData : IEntitySeedData\n {\n public IEnumerable HasData(DbContext dbContext, Type dbContextLocator)\n {\n return new List\n {\n new Tenant\n {\n TenantId=Guid.Parse("383AFB88-F519-FFF8-B364-6D563BF3687F"),\n Name="\u9ed8\u8ba4\u79df\u6237",\n Host="localhost:44313",\n CreatedTime=DateTime.Parse("2020-10-06 20:19:07"),\n Schema="dbo" // Schema\n },\n new Tenant\n {\n TenantId=Guid.Parse("C5798CB6-16D6-0F42-EB56-59C695353BC0"),\n Name="\u5176\u4ed6\u79df\u6237",\n Host="localhost:5000",\n CreatedTime=DateTime.Parse("2020-10-06 20:20:32"),\n Schema="fur" // Schema\n }\n };\n }\n }\n}\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u8be5\u6b65\u9aa4\u53ea\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Code First")," \u65b9\u5f0f\u6267\u884c\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Database First")," \u65e0\u9700\u914d\u7f6e\u79cd\u5b50\u6570\u636e\u3002"))),Object(r.b)("h3",{id:"1074-\u6839\u636e\u6a21\u578b\u521b\u5efa-tenant-\u8868"},"10.7.4 \u6839\u636e\u6a21\u578b\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"h3"},"Tenant")," \u8868"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Add-Migration add_tenant_table -Context MultiTenantDbContext\n")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database -Context MultiTenantDbContext\n")),Object(r.b)("h3",{id:"1075-\u5b9e\u73b0-imultitenantonschema-\u63a5\u53e3"},"10.7.5 \u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"h3"},"IMultiTenantOnSchema")," \u63a5\u53e3"),Object(r.b)("p",null,"\u5728\u9700\u8981\u591a\u79df\u6237\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u4e2d\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"p"},"IMultiTenantOnSchema")," \u63a5\u53e3\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{6,12-15}","{6,12-15}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class FurDbContext : AppDbContext, IMultiTenantOnSchema\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n public string GetSchemaName()\n {\n return base.Tenant?.Schema;\n }\n }\n}\n')),Object(r.b)("h3",{id:"1076-\u5173\u4e8e-code-first-\u6570\u636e\u8fc1\u79fb"},"10.7.6 \u5173\u4e8e ",Object(r.b)("inlineCode",{parentName:"h3"},"Code First \u6570\u636e\u8fc1\u79fb")),Object(r.b)("p",null,"\u57fa\u4e8e ",Object(r.b)("inlineCode",{parentName:"p"},"Schema")," \u65b9\u5f0f\u6bd4\u8f83\u7279\u522b\uff0c\u751f\u6210\u6570\u636e\u8fc1\u79fb\u7684\u65f6\u5019\u6ca1\u529e\u6cd5\u83b7\u53d6\u79df\u6237\u4fe1\u606f\uff0c\u6240\u4ee5\u5efa\u8bae",Object(r.b)("strong",{parentName:"p"},"\u5206\u5f00\u591a\u6b21\u8fc1\u79fb"),"\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'public string GetSchemaName()\n{\n return base.Tenant?.Schema?? "\u79df\u6237\u4e00Schema";\n}\n')),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'public string GetSchemaName()\n{\n return base.Tenant?.Schema?? "\u79df\u6237\u4e8cSchema";\n}\n')),Object(r.b)("p",null,"\u8fd9\u6837\u5c31\u53ef\u4ee5\u5728\u8fc1\u79fb\u7684\u65f6\u5019\u751f\u6210\u591a\u6b21\u8fc1\u79fb\u4e86\u3002"),Object(r.b)("h2",{id:"108-\u53cd\u9988\u4e0e\u5efa\u8bae"},"10.8 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/23e7023c.5c499293.js b/handbook/build/23e7023c.5c499293.js new file mode 100644 index 00000000000..726fb4e0f8a --- /dev/null +++ b/handbook/build/23e7023c.5c499293.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[15],{71:function(n){n.exports=JSON.parse('{"allTagsPath":"/fur/blog/tags","slug":"net","name":".net","count":1,"permalink":"/fur/blog/tags/net"}')}}]); \ No newline at end of file diff --git a/handbook/build/24dcd402.dad85cd2.js b/handbook/build/24dcd402.931bd557.js similarity index 78% rename from handbook/build/24dcd402.dad85cd2.js rename to handbook/build/24dcd402.931bd557.js index 2a62545a233..46737f2ea2a 100644 --- a/handbook/build/24dcd402.dad85cd2.js +++ b/handbook/build/24dcd402.931bd557.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[15],{142:function(e,r,n){"use strict";n.d(r,"a",(function(){return s})),n.d(r,"b",(function(){return m}));var t=n(0),o=n.n(t);function a(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function c(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function i(e){for(var r=1;r=0||(o[n]=e[n]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var u=o.a.createContext({}),p=function(e){var r=o.a.useContext(u),n=r;return e&&(n="function"==typeof e?e(r):i(i({},r),e)),n},s=function(e){var r=p(e.components);return o.a.createElement(u.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var n=e.components,t=e.mdxType,a=e.originalType,c=e.parentName,u=l(e,["components","mdxType","originalType","parentName"]),s=p(n),d=t,m=s["".concat(c,".").concat(d)]||s[d]||f[d]||a;return n?o.a.createElement(m,i(i({ref:r},u),{},{components:n})):o.a.createElement(m,i({ref:r},u))}));function m(e,r){var n=arguments,t=r&&r.mdxType;if("string"==typeof e||t){var a=n.length,c=new Array(a);c[0]=d;var i={};for(var l in r)hasOwnProperty.call(r,l)&&(i[l]=r[l]);i.originalType=e,i.mdxType="string"==typeof e?e:t,c[1]=i;for(var u=2;u=0||(o[n]=e[n]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var u=o.a.createContext({}),p=function(e){var r=o.a.useContext(u),n=r;return e&&(n="function"==typeof e?e(r):i(i({},r),e)),n},s=function(e){var r=p(e.components);return o.a.createElement(u.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var n=e.components,t=e.mdxType,a=e.originalType,c=e.parentName,u=l(e,["components","mdxType","originalType","parentName"]),s=p(n),d=t,m=s["".concat(c,".").concat(d)]||s[d]||f[d]||a;return n?o.a.createElement(m,i(i({ref:r},u),{},{components:n})):o.a.createElement(m,i({ref:r},u))}));function m(e,r){var n=arguments,t=r&&r.mdxType;if("string"==typeof e||t){var a=n.length,c=new Array(a);c[0]=d;var i={};for(var l in r)hasOwnProperty.call(r,l)&&(i[l]=r[l]);i.originalType=e,i.mdxType="string"==typeof e?e:t,c[1]=i;for(var u=2;u=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var u=o.a.createContext({}),l=function(e){var r=o.a.useContext(u),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},s=function(e){var r=l(e.components);return o.a.createElement(u.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,c=e.originalType,a=e.parentName,u=p(e,["components","mdxType","originalType","parentName"]),s=l(t),d=n,m=s["".concat(a,".").concat(d)]||s[d]||f[d]||c;return t?o.a.createElement(m,i(i({ref:r},u),{},{components:t})):o.a.createElement(m,i({ref:r},u))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var c=t.length,a=new Array(c);a[0]=d;var i={};for(var p in r)hasOwnProperty.call(r,p)&&(i[p]=r[p]);i.originalType=e,i.mdxType="string"==typeof e?e:n,a[1]=i;for(var u=2;u=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var u=o.a.createContext({}),l=function(e){var r=o.a.useContext(u),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},s=function(e){var r=l(e.components);return o.a.createElement(u.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,c=e.originalType,a=e.parentName,u=p(e,["components","mdxType","originalType","parentName"]),s=l(t),d=n,m=s["".concat(a,".").concat(d)]||s[d]||f[d]||c;return t?o.a.createElement(m,i(i({ref:r},u),{},{components:t})):o.a.createElement(m,i({ref:r},u))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var c=t.length,a=new Array(c);a[0]=d;var i={};for(var p in r)hasOwnProperty.call(r,p)&&(i[p]=r[p]);i.originalType=e,i.mdxType="string"==typeof e?e:n,a[1]=i;for(var u=2;u=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var b=r.a.createContext({}),d=function(e){var n=r.a.useContext(b),t=n;return e&&(t="function"==typeof e?e(n):o(o({},n),e)),t},l=function(e){var n=d(e.components);return r.a.createElement(b.Provider,{value:n},e.children)},p={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},m=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,c=e.originalType,i=e.parentName,b=s(e,["components","mdxType","originalType","parentName"]),l=d(t),m=a,u=l["".concat(i,".").concat(m)]||l[m]||p[m]||c;return t?r.a.createElement(u,o(o({ref:n},b),{},{components:t})):r.a.createElement(u,o({ref:n},b))}));function u(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var c=t.length,i=new Array(c);i[0]=m;var o={};for(var s in n)hasOwnProperty.call(n,s)&&(o[s]=n[s]);o.originalType=e,o.mdxType="string"==typeof e?e:a,i[1]=o;for(var b=2;b")," \u4f9d\u8d56\u63a5\u53e3\u53ef\u4ee5\u5feb\u901f\u7684\u6784\u5efa\u79cd\u5b50\u6570\u636e\uff0c\u652f\u6301\u4efb\u4f55\u65e0\u53c2\u6784\u9020\u51fd\u6570\u5bf9\u8c61\u7c7b\u4e2d\u4f7f\u7528\u3002\u5982\u6211\u4eec\u9700\u8981\u4e3a ",Object(c.b)("inlineCode",{parentName:"p"},"Person")," \u8868\u63d2\u5165\u521d\u59cb\u5316\u6570\u636e\uff1a"),Object(c.b)("h3",{id:"92121-\u5728\u5b9e\u4f53\u5b9a\u4e49\u4e2d\u4f7f\u7528"},"9.21.2.1 \u5728\u5b9e\u4f53\u5b9a\u4e49\u4e2d\u4f7f\u7528"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,16-23}","{7,16-23}":!0}),'using Fur.DatabaseAccessor;\nusing System;\nusing System.Collections.Generic;\n\nnamespace Fur.Core\n{\n public class Person : EntityBase, IEntitySeedData\n {\n public string Name { get; set; }\n\n public int Age { get; set; }\n\n public string Address { get; set; }\n\n // \u914d\u7f6e\u79cd\u5b50\u6570\u636e\n public IEnumerable HasData(DbContext dbContext, Type dbContextLocator)\n {\n return new List\n {\n new Person { Id = 1, Name = "\u767e\u5c0f\u50e7", Address = "\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02" },\n new Person { Id = 2, Name = "\u65b0\u751f\u5e1d", Address = "\u5e7f\u4e1c\u7701\u73e0\u6d77\u5e02" }\n };\n }\n }\n}\n')),Object(c.b)("div",{className:"admonition admonition-important alert alert--info"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},Object(c.b)("inlineCode",{parentName:"p"},"\u4e3b\u952e")," \u503c\u5fc5\u987b\u624b\u52a8\u63d2\u5165\uff0c\u56e0\u4e3a\u4f1a\u81ea\u52a8\u5173\u95ed\u4e3b\u952e\u6216\u81ea\u589e\u6807\u8bc6\u68c0\u67e5\u3002"))),Object(c.b)("h3",{id:"92122-\u5728\u4efb\u610f\u5bf9\u8c61\u7c7b\u4e2d\u4f7f\u7528"},"9.21.2.2 \u5728\u4efb\u610f\u5bf9\u8c61\u7c7b\u4e2d\u4f7f\u7528"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{6,9-16}","{6,9-16}":!0}),'using Fur.DatabaseAccessor;\nusing System.Collections.Generic;\n\nnamespace Fur.Application\n{\n public class PersonSeedData : IEntitySeedData\n {\n // \u914d\u7f6e\u79cd\u5b50\u6570\u636e\n public IEnumerable HasData(DbContext dbContext, Type dbContextLocator)\n {\n return new List\n {\n new Person { Id = 1, Name = "\u767e\u5c0f\u50e7", Address = "\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02" },\n new Person { Id = 2, Name = "\u65b0\u751f\u5e1d", Address = "\u5e7f\u4e1c\u7701\u73e0\u6d77\u5e02" }\n };\n }\n }\n}\n')),Object(c.b)("h2",{id:"9213-\u5bfc\u822a\u5c5e\u6027"},"9.21.3 \u5bfc\u822a\u5c5e\u6027"),Object(c.b)("p",null,"\u901a\u5e38\u6211\u4eec\u7684\u5b9e\u4f53\u6709 ",Object(c.b)("inlineCode",{parentName:"p"},"\u4e00\u5bf9\u591a"),"\uff0c",Object(c.b)("inlineCode",{parentName:"p"},"\u591a\u5bf9\u591a"),"\u7b49\u5916\u952e\u5173\u7cfb\uff0c\u90a3\u4e48",Object(c.b)("strong",{parentName:"p"},"\u6211\u4eec\u9700\u8981\u5355\u72ec\u4e3a\u6bcf\u4e00\u4e2a\u5b9e\u4f53\u6dfb\u52a0\u6570\u636e\u79cd\u5b50\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u5199\u5728\u4e3b\u8868\u4e2d\u3002")),Object(c.b)("h2",{id:"9214-\u591a\u4e2a\u6570\u636e\u5e93\u79cd\u5b50\u6570\u636e"},"9.21.4 \u591a\u4e2a\u6570\u636e\u5e93\u79cd\u5b50\u6570\u636e"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u6cdb\u578b\u7684\u65b9\u5f0f\u652f\u6301\u591a\u4e2a\u6570\u636e\u5e93\u79cd\u5b50\u6570\u636e\u8bbe\u5b9a\uff0c\u5982\uff1a"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{6,9-16}","{6,9-16}":!0}),'using Fur.DatabaseAccessor;\nusing System.Collections.Generic;\n\nnamespace Fur.Application\n{\n public class PersonSeedData : IEntitySeedData\n {\n // \u914d\u7f6e\u79cd\u5b50\u6570\u636e\n public IEnumerable HasData(DbContext dbContext, Type dbContextLocator)\n {\n return new List\n {\n new Person { Id = 1, Name = "\u767e\u5c0f\u50e7", Address = "\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02" },\n new Person { Id = 2, Name = "\u65b0\u751f\u5e1d", Address = "\u5e7f\u4e1c\u7701\u73e0\u6d77\u5e02" }\n };\n }\n }\n}\n')),Object(c.b)("p",null,"\u4e0a\u9762\u7684\u4f8b\u5b50\u8868\u793a\u540c\u65f6\u4e3a ",Object(c.b)("inlineCode",{parentName:"p"},"MySqlDbContext")," \u548c ",Object(c.b)("inlineCode",{parentName:"p"},"SqliteDbContext")," \u521b\u5efa\u79cd\u5b50\u6570\u636e\u3002"),Object(c.b)("h2",{id:"9215-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.21.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))),Object(c.b)("hr",null),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(c.b)("inlineCode",{parentName:"p"},"\u6570\u636e\u79cd\u5b50")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/ef/core/modeling/data-seeding"}),"EF Core - \u6570\u636e\u79cd\u5b50\u8bbe\u5b9a")," \u7ae0\u8282\u3002"))))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/2a4cb773.c96e5bb6.js b/handbook/build/2a4cb773.c96e5bb6.js deleted file mode 100644 index d3c60b7d2f3..00000000000 --- a/handbook/build/2a4cb773.c96e5bb6.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[17],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return l})),t.d(n,"b",(function(){return u}));var a=t(0),r=t.n(a);function c(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function o(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var b=r.a.createContext({}),d=function(e){var n=r.a.useContext(b),t=n;return e&&(t="function"==typeof e?e(n):o(o({},n),e)),t},l=function(e){var n=d(e.components);return r.a.createElement(b.Provider,{value:n},e.children)},p={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},m=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,c=e.originalType,i=e.parentName,b=s(e,["components","mdxType","originalType","parentName"]),l=d(t),m=a,u=l["".concat(i,".").concat(m)]||l[m]||p[m]||c;return t?r.a.createElement(u,o(o({ref:n},b),{},{components:t})):r.a.createElement(u,o({ref:n},b))}));function u(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var c=t.length,i=new Array(c);i[0]=m;var o={};for(var s in n)hasOwnProperty.call(n,s)&&(o[s]=n[s]);o.originalType=e,o.mdxType="string"==typeof e?e:a,i[1]=o;for(var b=2;b")," \u4f9d\u8d56\u63a5\u53e3\u53ef\u4ee5\u5feb\u901f\u7684\u6784\u5efa\u79cd\u5b50\u6570\u636e\uff0c\u652f\u6301\u4efb\u4f55\u65e0\u53c2\u6784\u9020\u51fd\u6570\u5bf9\u8c61\u7c7b\u4e2d\u4f7f\u7528\u3002\u5982\u6211\u4eec\u9700\u8981\u4e3a ",Object(c.b)("inlineCode",{parentName:"p"},"Person")," \u8868\u63d2\u5165\u521d\u59cb\u5316\u6570\u636e\uff1a"),Object(c.b)("h3",{id:"92121-\u5728\u5b9e\u4f53\u5b9a\u4e49\u4e2d\u4f7f\u7528"},"9.21.2.1 \u5728\u5b9e\u4f53\u5b9a\u4e49\u4e2d\u4f7f\u7528"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,16-23}","{7,16-23}":!0}),'using Fur.DatabaseAccessor;\nusing System;\nusing System.Collections.Generic;\n\nnamespace Fur.Core\n{\n public class Person : EntityBase, IEntitySeedData\n {\n public string Name { get; set; }\n\n public int Age { get; set; }\n\n public string Address { get; set; }\n\n // \u914d\u7f6e\u79cd\u5b50\u6570\u636e\n public IEnumerable HasData(DbContext dbContext, Type dbContextLocator)\n {\n return new List\n {\n new Person { Id = 1, Name = "\u767e\u5c0f\u50e7", Address = "\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02" },\n new Person { Id = 2, Name = "\u65b0\u751f\u5e1d", Address = "\u5e7f\u4e1c\u7701\u73e0\u6d77\u5e02" }\n };\n }\n }\n}\n')),Object(c.b)("div",{className:"admonition admonition-important alert alert--info"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},Object(c.b)("inlineCode",{parentName:"p"},"\u4e3b\u952e")," \u503c\u5fc5\u987b\u624b\u52a8\u63d2\u5165\uff0c\u56e0\u4e3a\u4f1a\u81ea\u52a8\u5173\u95ed\u4e3b\u952e\u6216\u81ea\u589e\u6807\u8bc6\u68c0\u67e5\u3002"))),Object(c.b)("h3",{id:"92122-\u5728\u4efb\u610f\u5bf9\u8c61\u7c7b\u4e2d\u4f7f\u7528"},"9.21.2.2 \u5728\u4efb\u610f\u5bf9\u8c61\u7c7b\u4e2d\u4f7f\u7528"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{6,9-16}","{6,9-16}":!0}),'using Fur.DatabaseAccessor;\nusing System.Collections.Generic;\n\nnamespace Fur.Application\n{\n public class PersonSeedData : IEntitySeedData\n {\n // \u914d\u7f6e\u79cd\u5b50\u6570\u636e\n public IEnumerable HasData(DbContext dbContext, Type dbContextLocator)\n {\n return new List\n {\n new Person { Id = 1, Name = "\u767e\u5c0f\u50e7", Address = "\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02" },\n new Person { Id = 2, Name = "\u65b0\u751f\u5e1d", Address = "\u5e7f\u4e1c\u7701\u73e0\u6d77\u5e02" }\n };\n }\n }\n}\n')),Object(c.b)("h2",{id:"9213-\u5bfc\u822a\u5c5e\u6027"},"9.21.3 \u5bfc\u822a\u5c5e\u6027"),Object(c.b)("p",null,"\u901a\u5e38\u6211\u4eec\u7684\u5b9e\u4f53\u6709 ",Object(c.b)("inlineCode",{parentName:"p"},"\u4e00\u5bf9\u591a"),"\uff0c",Object(c.b)("inlineCode",{parentName:"p"},"\u591a\u5bf9\u591a"),"\u7b49\u5916\u952e\u5173\u7cfb\uff0c\u90a3\u4e48",Object(c.b)("strong",{parentName:"p"},"\u6211\u4eec\u9700\u8981\u5355\u72ec\u4e3a\u6bcf\u4e00\u4e2a\u5b9e\u4f53\u6dfb\u52a0\u6570\u636e\u79cd\u5b50\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u5199\u5728\u4e3b\u8868\u4e2d\u3002")),Object(c.b)("h2",{id:"9214-\u591a\u4e2a\u6570\u636e\u5e93\u79cd\u5b50\u6570\u636e"},"9.21.4 \u591a\u4e2a\u6570\u636e\u5e93\u79cd\u5b50\u6570\u636e"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u6cdb\u578b\u7684\u65b9\u5f0f\u652f\u6301\u591a\u4e2a\u6570\u636e\u5e93\u79cd\u5b50\u6570\u636e\u8bbe\u5b9a\uff0c\u5982\uff1a"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{6,9-16}","{6,9-16}":!0}),'using Fur.DatabaseAccessor;\nusing System.Collections.Generic;\n\nnamespace Fur.Application\n{\n public class PersonSeedData : IEntitySeedData\n {\n // \u914d\u7f6e\u79cd\u5b50\u6570\u636e\n public IEnumerable HasData(DbContext dbContext, Type dbContextLocator)\n {\n return new List\n {\n new Person { Id = 1, Name = "\u767e\u5c0f\u50e7", Address = "\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02" },\n new Person { Id = 2, Name = "\u65b0\u751f\u5e1d", Address = "\u5e7f\u4e1c\u7701\u73e0\u6d77\u5e02" }\n };\n }\n }\n}\n')),Object(c.b)("p",null,"\u4e0a\u9762\u7684\u4f8b\u5b50\u8868\u793a\u540c\u65f6\u4e3a ",Object(c.b)("inlineCode",{parentName:"p"},"MySqlDbContext")," \u548c ",Object(c.b)("inlineCode",{parentName:"p"},"SqliteDbContext")," \u521b\u5efa\u79cd\u5b50\u6570\u636e\u3002"),Object(c.b)("h2",{id:"9215-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.21.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))),Object(c.b)("hr",null),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(c.b)("inlineCode",{parentName:"p"},"\u6570\u636e\u79cd\u5b50")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/ef/core/modeling/data-seeding"}),"EF Core - \u6570\u636e\u79cd\u5b50\u8bbe\u5b9a")," \u7ae0\u8282\u3002"))))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/2ae73ff4.074eace3.js b/handbook/build/2ae73ff4.074eace3.js new file mode 100644 index 00000000000..2f0bafc7f88 --- /dev/null +++ b/handbook/build/2ae73ff4.074eace3.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[19],{142:function(e,r,t){"use strict";t.d(r,"a",(function(){return f})),t.d(r,"b",(function(){return m}));var n=t(0),o=t.n(n);function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function i(e){for(var r=1;r=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=o.a.createContext({}),l=function(e){var r=o.a.useContext(p),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},f=function(e){var r=l(e.components);return o.a.createElement(p.Provider,{value:r},e.children)},s={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,c=e.originalType,a=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),f=l(t),d=n,m=f["".concat(a,".").concat(d)]||f[d]||s[d]||c;return t?o.a.createElement(m,i(i({ref:r},p),{},{components:t})):o.a.createElement(m,i({ref:r},p))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var c=t.length,a=new Array(c);a[0]=d;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,a[1]=i;for(var p=2;p=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var p=o.a.createContext({}),l=function(e){var t=o.a.useContext(p),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},s=function(e){var t=l(e.components);return o.a.createElement(p.Provider,{value:t},e.children)},f={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},d=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,c=e.originalType,a=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),s=l(r),d=n,m=s["".concat(a,".").concat(d)]||s[d]||f[d]||c;return r?o.a.createElement(m,i(i({ref:t},p),{},{components:r})):o.a.createElement(m,i({ref:t},p))}));function m(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var c=r.length,a=new Array(c);a[0]=d;var i={};for(var u in t)hasOwnProperty.call(t,u)&&(i[u]=t[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,a[1]=i;for(var p=2;p=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var l=o.a.createContext({}),p=function(e){var t=o.a.useContext(l),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},s=function(e){var t=p(e.components);return o.a.createElement(l.Provider,{value:t},e.children)},f={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},b=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,l=u(e,["components","mdxType","originalType","parentName"]),s=p(r),b=n,d=s["".concat(c,".").concat(b)]||s[b]||f[b]||a;return r?o.a.createElement(d,i(i({ref:t},l),{},{components:r})):o.a.createElement(d,i({ref:t},l))}));function d(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var a=r.length,c=new Array(a);c[0]=b;var i={};for(var u in t)hasOwnProperty.call(t,u)&&(i[u]=t[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var l=2;l=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var l=o.a.createContext({}),p=function(e){var t=o.a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},s=function(e){var t=p(e.components);return o.a.createElement(l.Provider,{value:t},e.children)},f={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},b=o.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,a=e.originalType,c=e.parentName,l=u(e,["components","mdxType","originalType","parentName"]),s=p(n),b=r,d=s["".concat(c,".").concat(b)]||s[b]||f[b]||a;return n?o.a.createElement(d,i(i({ref:t},l),{},{components:n})):o.a.createElement(d,i({ref:t},l))}));function d(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var a=n.length,c=new Array(a);c[0]=b;var i={};for(var u in t)hasOwnProperty.call(t,u)&&(i[u]=t[u]);i.originalType=e,i.mdxType="string"==typeof e?e:r,c[1]=i;for(var l=2;l=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var l=i.a.createContext({}),p=function(e){var n=i.a.useContext(l),t=n;return e&&(t="function"==typeof e?e(n):a(a({},n),e)),t},u=function(e){var n=p(e.components);return i.a.createElement(l.Provider,{value:n},e.children)},b={inlineCode:"code",wrapper:function(e){var n=e.children;return i.a.createElement(i.a.Fragment,{},n)}},d=i.a.forwardRef((function(e,n){var t=e.components,r=e.mdxType,s=e.originalType,o=e.parentName,l=c(e,["components","mdxType","originalType","parentName"]),u=p(t),d=r,m=u["".concat(o,".").concat(d)]||u[d]||b[d]||s;return t?i.a.createElement(m,a(a({ref:n},l),{},{components:t})):i.a.createElement(m,a({ref:n},l))}));function m(e,n){var t=arguments,r=n&&n.mdxType;if("string"==typeof e||r){var s=t.length,o=new Array(s);o[0]=d;var a={};for(var c in n)hasOwnProperty.call(n,c)&&(a[c]=n[c]);a.originalType=e,a.mdxType="string"==typeof e?e:r,o[1]=a;for(var l=2;lFur.Tests \u6d4b\u8bd5\u5c42",id:"122-furtests-\u6d4b\u8bd5\u5c42",children:[]},{value:"1.2.3 Solution Items \u89e3\u51b3\u65b9\u6848\u914d\u7f6e\u5c42",id:"123-solution-items-\u89e3\u51b3\u65b9\u6848\u914d\u7f6e\u5c42",children:[]},{value:"1.2.4 Fur \u6838\u5fc3\u5c42",id:"124-fur-\u6838\u5fc3\u5c42",children:[]},{value:"1.2.5 Fur.Application \u4e1a\u52a1\u5e94\u7528\u5c42",id:"125-furapplication-\u4e1a\u52a1\u5e94\u7528\u5c42",children:[]},{value:"1.2.6 Fur.Core \u4ed3\u50a8\u5b9e\u4f53\u5c42",id:"126-furcore-\u4ed3\u50a8\u5b9e\u4f53\u5c42",children:[]},{value:"1.2.7 Fur.Database.Migrations \u6570\u636e\u5e93\u67b6\u6784\u7ef4\u62a4\u5c42",id:"127-furdatabasemigrations-\u6570\u636e\u5e93\u67b6\u6784\u7ef4\u62a4\u5c42",children:[]},{value:"1.2.8 Fur.EntityFramework.Core \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u914d\u7f6e\u5c42",id:"128-furentityframeworkcore-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u914d\u7f6e\u5c42",children:[]},{value:"1.2.9 Fur.Web.Core \u5e94\u7528\u6838\u5fc3\u5c42",id:"129-furwebcore-\u5e94\u7528\u6838\u5fc3\u5c42",children:[]},{value:"1.2.10 Fur.Web.Entry \u5e94\u7528\u5165\u53e3\u5c42",id:"1210-furwebentry-\u5e94\u7528\u5165\u53e3\u5c42",children:[]}],l={rightToc:c};function p(e){var n=e.components,t=Object(i.a)(e,["components"]);return Object(s.b)("wrapper",Object(r.a)({},l,t,{components:n,mdxType:"MDXLayout"}),Object(s.b)("h2",{id:"121-\u6e90\u7801\u67b6\u6784"},"1.2.1 \u6e90\u7801\u67b6\u6784"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur")," \u521b\u5efa\u91c7\u7528\u591a\u5c42\u5206\u5c42\u8bbe\u8ba1\uff0c\u4e3b\u8981\u8bbe\u8ba1\u662f ",Object(s.b)("inlineCode",{parentName:"p"},"\u81ea\u52a8\u62bd\u8c61\u5de5\u5382")," \u548c ",Object(s.b)("inlineCode",{parentName:"p"},"DDD \u9886\u57df\u9a71\u52a8\u8bbe\u8ba1")," \u76f8\u7ed3\u5408\u3002"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u9879\u76ee\u7ed3\u6784\u5982\u4e0b\uff1a"),Object(s.b)("ul",null,Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur.Tests"),"\uff1a\u6d4b\u8bd5\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Solution Items"),"\uff1a\u89e3\u51b3\u65b9\u6848\u914d\u7f6e\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur"),"\uff1a\u6846\u67b6\u6838\u5fc3\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur.Application"),"\uff1a\u4e1a\u52a1\u5e94\u7528\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur.Core"),"\uff1a\u4ed3\u50a8\u5b9e\u4f53\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur.Database.Migrations"),"\uff1a\u67b6\u6784\u7ef4\u62a4\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur.EntityFramework.Core"),"\uff1aEF Core \u914d\u7f6e\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur.Web.Core"),"\uff1aWeb \u6838\u5fc3\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur.Web.Entry"),"\uff1aWeb \u5165\u53e3\u5c42/\u542f\u52a8\u5c42")),Object(s.b)("h2",{id:"122-furtests-\u6d4b\u8bd5\u5c42"},"1.2.2 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur.Tests")," \u6d4b\u8bd5\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur.Tests")," \u662f\u9879\u76ee\u7684\u6d4b\u8bd5\u5c42\uff0c\u76ee\u524d\u8fd8\u672a\u6574\u7406\u5b8c\u6210\u3002"),Object(s.b)("h2",{id:"123-solution-items-\u89e3\u51b3\u65b9\u6848\u914d\u7f6e\u5c42"},"1.2.3 ",Object(s.b)("inlineCode",{parentName:"h2"},"Solution Items")," \u89e3\u51b3\u65b9\u6848\u914d\u7f6e\u5c42"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{}),"Solution Items\n\u2514.editorconfig\n")),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Solution Items")," \u662f\u7528\u6765\u914d\u7f6e\u89e3\u51b3\u65b9\u6848\u4e2d\u4e00\u4e9b\u5168\u5c40\u914d\u7f6e\u7684\uff0c\u5982\u6bcf\u4e2a\u6587\u4ef6\u7684\u9876\u90e8\u7248\u6743\u4fe1\u606f\uff0c\u5982\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// -----------------------------------------------------------------------------\n// Fur \u662f .NET 5 \u5e73\u53f0\u4e0b\u6781\u6613\u5165\u95e8\u3001\u6781\u901f\u5f00\u53d1\u7684 Web \u5e94\u7528\u6846\u67b6\u3002\n// Copyright \xa9 2020 Fur, Baiqian Co.,Ltd.\n//\n// \u6846\u67b6\u540d\u79f0\uff1aFur\n// \u6846\u67b6\u4f5c\u8005\uff1a\u767e\u5c0f\u50e7\n// \u6846\u67b6\u7248\u672c\uff1a1.0.0\n// \u6e90\u7801\u5730\u5740\uff1aGitee\uff1ahttps://gitee.com/monksoul/Fur\n// Github\uff1ahttps://github.com/monksoul/Fur\n// \u5f00\u6e90\u534f\u8bae\uff1aApache-2.0\uff08http://www.apache.org/licenses/LICENSE-2.0\uff09\n// -----------------------------------------------------------------------------\n")),Object(s.b)("p",null,"\u76f8\u5173\u914d\u7f6e\u5728 ",Object(s.b)("inlineCode",{parentName:"p"},".editorconfig")," \u6700\u540e\u9762\u4e00\u884c\uff0c\u5982\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{127}","{127}":!0}),'# Rules in this file were initially inferred by Visual Studio IntelliCode from the D:\\MONK\\Fur\\framework codebase based on best match to current usage at 2020/9/2\n# You can modify the rules from these initially generated values to suit your own policies\n# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference\n[*.cs]\n\n\n#Core editorconfig formatting - indentation\n\n#use soft tabs (spaces) for indentation\nindent_style = space\n\n#Formatting - new line options\n\n#place else statements on a new line\ncsharp_new_line_before_else = true\n#require members of anonymous types to be on separate lines\ncsharp_new_line_before_members_in_anonymous_types = true\n#require members of object intializers to be on separate lines\ncsharp_new_line_before_members_in_object_initializers = true\n#require braces to be on a new line for accessors, methods, control_blocks, types, lambdas, object_collection_array_initializers, anonymous_types, and properties (also known as "Allman" style)\ncsharp_new_line_before_open_brace = accessors, methods, control_blocks, types, lambdas, object_collection_array_initializers, anonymous_types, properties\n\n#Formatting - organize using options\n\n#do not place System.* using directives before other using directives\ndotnet_sort_system_directives_first = false\n\n#Formatting - spacing options\n\n#require a space before the colon for bases or interfaces in a type declaration\ncsharp_space_after_colon_in_inheritance_clause = true\n#require a space after a keyword in a control flow statement such as a for loop\ncsharp_space_after_keywords_in_control_flow_statements = true\n#require a space before the colon for bases or interfaces in a type declaration\ncsharp_space_before_colon_in_inheritance_clause = true\n#remove space within empty argument list parentheses\ncsharp_space_between_method_call_empty_parameter_list_parentheses = false\n#remove space between method call name and opening parenthesis\ncsharp_space_between_method_call_name_and_opening_parenthesis = false\n#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call\ncsharp_space_between_method_call_parameter_list_parentheses = false\n#remove space within empty parameter list parentheses for a method declaration\ncsharp_space_between_method_declaration_empty_parameter_list_parentheses = false\n#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.\ncsharp_space_between_method_declaration_parameter_list_parentheses = false\n\n#Formatting - wrapping options\n\n#leave code block on single line\ncsharp_preserve_single_line_blocks = true\n#leave statements and member declarations on the same line\ncsharp_preserve_single_line_statements = true\n\n#Style - Code block preferences\n\n#prefer no curly braces if allowed\ncsharp_prefer_braces = false:suggestion\n\n#Style - expression bodied member options\n\n#prefer expression-bodied members for accessors\ncsharp_style_expression_bodied_accessors = true:suggestion\n#prefer block bodies for constructors\ncsharp_style_expression_bodied_constructors = false:suggestion\n#prefer block bodies for methods\ncsharp_style_expression_bodied_methods = false:suggestion\n#prefer expression-bodied members for properties\ncsharp_style_expression_bodied_properties = true:suggestion\n\n#Style - expression level options\n\n#prefer out variables to be declared inline in the argument list of a method call when possible\ncsharp_style_inlined_variable_declaration = true:suggestion\n#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them\ndotnet_style_predefined_type_for_member_access = true:suggestion\n\n#Style - Expression-level preferences\n\n#prefer default over default(T)\ncsharp_prefer_simple_default_expression = true:suggestion\n#prefer objects to be initialized using object initializers when possible\ndotnet_style_object_initializer = true:suggestion\n#prefer inferred anonymous type member names\ndotnet_style_prefer_inferred_anonymous_type_member_names = false:suggestion\n#prefer inferred tuple element names\ndotnet_style_prefer_inferred_tuple_names = true:suggestion\n\n#Style - implicit and explicit types\n\n#prefer var over explicit type in all cases, unless overridden by another code style rule\ncsharp_style_var_elsewhere = true:suggestion\n#prefer var is used to declare variables with built-in system types such as int\ncsharp_style_var_for_built_in_types = true:suggestion\n#prefer var when the type is already mentioned on the right-hand side of a declaration expression\ncsharp_style_var_when_type_is_apparent = true:suggestion\n\n#Style - language keyword and framework type options\n\n#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them\ndotnet_style_predefined_type_for_locals_parameters_members = true:suggestion\n\n#Style - Miscellaneous preferences\n\n#prefer local functions over anonymous functions\ncsharp_style_pattern_local_over_anonymous_function = true:suggestion\n\n#Style - modifier options\n\n#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods.\ndotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion\n\n#Style - Modifier preferences\n\n#when this rule is set to a list of modifiers, prefer the specified ordering.\ncsharp_preferred_modifier_order = public,private,internal,protected,virtual,static,async,abstract,readonly,sealed,override:suggestion\n\n#Style - qualification options\n\n#prefer fields not to be prefaced with this. or Me. in Visual Basic\ndotnet_style_qualification_for_field = false:suggestion\n#prefer methods not to be prefaced with this. or Me. in Visual Basic\ndotnet_style_qualification_for_method = false:suggestion\n#prefer properties not to be prefaced with this. or Me. in Visual Basic\ndotnet_style_qualification_for_property = false:suggestion\n\n# Add file header\nfile_header_template = -----------------------------------------------------------------------------\\nFur \u662f .NET 5 \u5e73\u53f0\u4e0b\u6781\u6613\u5165\u95e8\u3001\u6781\u901f\u5f00\u53d1\u7684 Web \u5e94\u7528\u6846\u67b6\u3002\\nCopyright \xa9 2020 Fur, Baiqian Co.,Ltd.\\n\\n\u6846\u67b6\u540d\u79f0\uff1aFur\\n\u6846\u67b6\u4f5c\u8005\uff1a\u767e\u5c0f\u50e7\\n\u6846\u67b6\u7248\u672c\uff1a1.0.0\\n\u6e90\u7801\u5730\u5740\uff1aGitee\uff1ahttps://gitee.com/monksoul/Fur \\n Github\uff1ahttps://github.com/monksoul/Fur \\n\u5f00\u6e90\u534f\u8bae\uff1aApache-2.0\uff08http://www.apache.org/licenses/LICENSE-2.0\uff09\\n-----------------------------------------------------------------------------\n')),Object(s.b)("h2",{id:"124-fur-\u6838\u5fc3\u5c42"},"1.2.4 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur")," \u6838\u5fc3\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur")," \u6838\u5fc3\u5c42\u662f ",Object(s.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u7684\u4e2d\u5fc3\uff0c\u4e5f\u662f ",Object(s.b)("inlineCode",{parentName:"p"},"Fur")," \u80fd\u591f\u652f\u6491\u8d77\u6765\u7684\u5fc5\u5907\u5c42\u3002"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{}),"Fur\n\u251c\u2500Fur.csproj\n\u251c\u2500Fur.csproj.user\n\u251c\u2500FurStartup.cs\n\u251c\u2500ViewEngine\n| \u251c\u2500IViewEngine.cs\n| \u251c\u2500ViewEngine.cs\n| \u251c\u2500Templates\n| | \u251c\u2500IViewEngineCompiledTemplate.cs\n| | \u251c\u2500IViewEngineTemplate.cs\n| | \u251c\u2500ViewEngineCompiledTemplate.cs\n| | \u2514ViewEngineTemplate.cs\n| \u251c\u2500Options\n| | \u2514ViewEngineCompilationOptions.cs\n| \u251c\u2500Models\n| | \u2514AnonymousTypeWrapper.cs\n| \u251c\u2500Exceptions\n| | \u251c\u2500ViewEngineCompilationException.cs\n| | \u2514ViewEngineException.cs\n| \u251c\u2500Compilations\n| | \u251c\u2500IViewEngineCompilationOptionsBuilder.cs\n| | \u2514ViewEngineCompilationOptionsBuilder.cs\n\u251c\u2500UnifyResult\n| \u251c\u2500Providers\n| | \u251c\u2500IUnifyResultProvider.cs\n| | \u2514RESTfulResultProvider.cs\n| \u251c\u2500Models\n| | \u2514RESTfulResult.cs\n| \u251c\u2500Filters\n| | \u2514SuccessUnifyResultFilter.cs\n| \u251c\u2500Extensions\n| | \u2514UnifyResultServiceCollectionExtensions.cs\n\u251c\u2500SpecificationDocument\n| \u251c\u2500Options\n| | \u2514SpecificationDocumentSettingsOptions.cs\n| \u251c\u2500Models\n| | \u251c\u2500GroupOrder.cs\n| | \u251c\u2500SpecificationOpenApiInfo.cs\n| | \u251c\u2500SpecificationOpenApiSecurityRequirementItem.cs\n| | \u2514SpecificationOpenApiSecurityScheme.cs\n| \u251c\u2500Extensions\n| | \u251c\u2500SpecificationDocumentApplicationBuilderExtensions.cs\n| | \u2514SpecificationDocumentServiceCollectionExtensions.cs\n| \u251c\u2500Builders\n| | \u2514SpecificationDocumentBuilder.cs\n| \u251c\u2500Assets\n| | \u2514index-mini-profiler.html\n\u251c\u2500ObjectMapper\n| \u251c\u2500Extensions\n| | \u2514ObjectMapperServiceCollectionExtensions.cs\n| \u251c\u2500Dependencies\n| | \u2514IObjectMapper.cs\n\u251c\u2500LinqBuilder\n| \u251c\u2500Visitors\n| | \u2514ParameterReplaceExpressionVisitor.cs\n| \u251c\u2500Extensions\n| | \u2514LinqExtensions.cs\n| \u251c\u2500Builders\n| | \u2514LinqExpression.cs\n\u251c\u2500FriendlyException\n| \u251c\u2500Oops.cs\n| \u251c\u2500Providers\n| | \u2514IErrorCodeTypeProvider.cs\n| \u251c\u2500Options\n| | \u2514ErrorCodeMessageSettingsOptions.cs\n| \u251c\u2500Models\n| | \u2514MethodIfException.cs\n| \u251c\u2500Filters\n| | \u2514FriendlyExceptionFilter.cs\n| \u251c\u2500Extensions\n| | \u2514FriendlyExceptionServiceCollectionExtensions.cs\n| \u251c\u2500Attributes\n| | \u251c\u2500ErrorCodeItemMetadataAttribute.cs\n| | \u251c\u2500ErrorCodeTypeAttribute.cs\n| | \u2514IfExceptionAttribute.cs\n\u251c\u2500DynamicApiController\n| \u251c\u2500Penetrates.cs\n| \u251c\u2500Providers\n| | \u2514DynamicApiControllerFeatureProvider.cs\n| \u251c\u2500Options\n| | \u2514DynamicApiControllerSettingsOptions.cs\n| \u251c\u2500Models\n| | \u2514ParameterRouteTemplate.cs\n| \u251c\u2500Extensions\n| | \u2514DynamicApiControllerServiceCollectionExtensions.cs\n| \u251c\u2500Enums\n| | \u2514ApiSeats.cs\n| \u251c\u2500Dependencies\n| | \u2514IDynamicApiController.cs\n| \u251c\u2500Conventions\n| | \u2514DynamicApiControllerApplicationModelConvention.cs\n| \u251c\u2500Attributes\n| | \u251c\u2500ApiDescriptionSettingsAttribute.cs\n| | \u251c\u2500ApiSeatAttribute.cs\n| | \u2514DynamicApiControllerAttribute.cs\n\u251c\u2500DependencyInjection\n| \u251c\u2500Options\n| | \u2514DependencyInjectionSettingsOptions.cs\n| \u251c\u2500Models\n| | \u2514ExternalService.cs\n| \u251c\u2500Extensions\n| | \u2514DependencyInjectionServiceCollectionExtensions.cs\n| \u251c\u2500Enums\n| | \u251c\u2500InjectionActions.cs\n| | \u251c\u2500InjectionPatterns.cs\n| | \u2514RegisterType.cs\n| \u251c\u2500Dependencies\n| | \u251c\u2500IPrivateDependency.cs\n| | \u251c\u2500IScoped.cs\n| | \u251c\u2500ISingleton.cs\n| | \u251c\u2500ITransient.cs\n| | \u251c\u2500Proxies\n| | | \u2514IDispatchProxy.cs\n| \u251c\u2500Attributes\n| | \u251c\u2500InjectionAttribute.cs\n| | \u2514SkipScanAttribute.cs\n\u251c\u2500DataValidation\n| \u251c\u2500Validators\n| | \u2514DataValidator.cs\n| \u251c\u2500Providers\n| | \u2514IValidationMessageTypeProvider.cs\n| \u251c\u2500Options\n| | \u2514ValidationTypeMessageSettingsOptions.cs\n| \u251c\u2500Models\n| | \u2514DataValidationResult.cs\n| \u251c\u2500Filters\n| | \u2514DataValidationFilter.cs\n| \u251c\u2500Extensions\n| | \u251c\u2500DataValidationExtensions.cs\n| | \u2514DataValidationServiceCollectionExtensions.cs\n| \u251c\u2500Enums\n| | \u251c\u2500ValidationPattern.cs\n| | \u2514ValidationTypes.cs\n| \u251c\u2500Attributes\n| | \u251c\u2500DataValidationAttribute.cs\n| | \u251c\u2500NonValidationAttribute.cs\n| | \u251c\u2500ValidationItemMetadataAttribute.cs\n| | \u251c\u2500ValidationMessageAttribute.cs\n| | \u251c\u2500ValidationMessageTypeAttribute.cs\n| | \u2514ValidationTypeAttribute.cs\n\u251c\u2500DataEncryption\n| \u251c\u2500AESEncryption.cs\n| \u251c\u2500DESCEncryption.cs\n| \u2514MD5Encryption.cs\n\u251c\u2500DatabaseAccessor\n| \u251c\u2500UnitOfWork\n| | \u251c\u2500Filters\n| | | \u2514UnitOfWorkFilter.cs\n| | \u251c\u2500Attributes\n| | | \u251c\u2500NonTransactAttribute.cs\n| | | \u2514UnitOfWorkAttribute.cs\n| \u251c\u2500Repositories\n| | \u251c\u2500EFCoreRepository.cs\n| | \u251c\u2500IMSRepository.cs\n| | \u251c\u2500IRepository.cs\n| | \u251c\u2500ISqlRepository.cs\n| | \u251c\u2500MSRepository.cs\n| | \u251c\u2500SqlRepository.cs\n| | \u251c\u2500Implantations\n| | | \u251c\u2500DeletableRepository.cs\n| | | \u251c\u2500InsertableRepository.cs\n| | | \u251c\u2500OperableRepository.cs\n| | | \u251c\u2500ReadableRepository.cs\n| | | \u251c\u2500SqlExecutableRepository.cs\n| | | \u251c\u2500SqlReaderRepository.cs\n| | | \u251c\u2500UpdateableRepository.cs\n| | | \u2514WritableRepository.cs\n| | \u251c\u2500Dependencies\n| | | \u251c\u2500IDeletableRepository.cs\n| | | \u251c\u2500IInsertableRepository.cs\n| | | \u251c\u2500IOperableRepository.cs\n| | | \u251c\u2500IReadableRepository.cs\n| | | \u251c\u2500IRepositoryDependency.cs\n| | | \u251c\u2500ISqlExecutableRepository.cs\n| | | \u251c\u2500ISqlReaderRepository.cs\n| | | \u251c\u2500IUpdateableRepository.cs\n| | | \u2514IWritableRepository.cs\n| \u251c\u2500Pools\n| | \u251c\u2500DbContextPool.cs\n| | \u2514IDbContextPool.cs\n| \u251c\u2500MultiTenants\n| | \u251c\u2500Locators\n| | | \u2514MultiTenantDbContextLocator.cs\n| | \u251c\u2500Enums\n| | | \u2514MultiTenantOptions.cs\n| | \u251c\u2500Entities\n| | | \u2514Tenant.cs\n| | \u251c\u2500Dependencies\n| | | \u251c\u2500IMultiTenantOnDatabase.cs\n| | | \u251c\u2500IMultiTenantOnSchema.cs\n| | | \u251c\u2500IMultiTenantOnTable.cs\n| | | \u2514IPrivateMultiTenant.cs\n| \u251c\u2500Models\n| | \u251c\u2500DbProvider.cs\n| | \u251c\u2500PagedList.cs\n| | \u251c\u2500ProcedureOutputResult.cs\n| | \u251c\u2500ProcedureOutputValue.cs\n| | \u251c\u2500SqlTemplate.cs\n| | \u2514SqlTemplateParameter.cs\n| \u251c\u2500Locators\n| | \u251c\u2500IDbContextLocator.cs\n| | \u2514MasterDbContextLocator.cs\n| \u251c\u2500Interceptors\n| | \u251c\u2500DbContextSaveChangesInterceptor.cs\n| | \u251c\u2500SqlCommandProfilerInterceptor.cs\n| | \u2514SqlConnectionProfilerInterceptor.cs\n| \u251c\u2500Helpers\n| | \u2514DbHelpers.cs\n| \u251c\u2500Extensions\n| | \u251c\u2500DatabaseAccessorServiceCollectionExtensions.cs\n| | \u251c\u2500PagedQueryableExtensions.cs\n| | \u251c\u2500Repositories\n| | | \u251c\u2500IEntityExtensions.cs\n| | | \u251c\u2500IEntityWithDbContextLocatorExtensions.cs\n| | | \u2514SqlExtensions.cs\n| | \u251c\u2500DatabaseProvider\n| | | \u251c\u2500DatabaseProviderServiceCollectionExtensions.cs\n| | | \u2514Penetrates.cs\n| | \u251c\u2500DatabaseFacade\n| | | \u251c\u2500DbDataConvertExtensions.cs\n| | | \u251c\u2500DbObjectExtensions.cs\n| | | \u2514SqlAdoNetExtensions.cs\n| \u251c\u2500Enums\n| | \u251c\u2500DbFunctionType.cs\n| | \u251c\u2500EFCoreErrorCodes.cs\n| | \u2514ManualOptions.cs\n| \u251c\u2500Entities\n| | \u251c\u2500Dependencies\n| | | \u251c\u2500Entity.cs\n| | | \u251c\u2500EntityBase.cs\n| | | \u251c\u2500EntityNotKey.cs\n| | | \u251c\u2500IEntity.cs\n| | | \u2514IEntityNotKey.cs\n| | \u251c\u2500Configures\n| | | \u251c\u2500IEntitySeedData.cs\n| | | \u251c\u2500IEntityTypeBuilder.cs\n| | | \u251c\u2500IModelBuilderFilter.cs\n| | | \u2514IPrivateModelBuilder.cs\n| | \u251c\u2500Attributes\n| | | \u251c\u2500FakeDeleteAttribute.cs\n| | | \u251c\u2500NonAutomaticAttribute.cs\n| | | \u2514QueryableFunctionAttribute.cs\n| \u251c\u2500DynamicModels\n| | \u251c\u2500DynamicModelCacheKeyFactory.cs\n| | \u2514IEntityMutableTable.cs\n| \u251c\u2500Contexts\n| | \u251c\u2500AppDbContext.cs\n| | \u251c\u2500Builders\n| | | \u251c\u2500AppDbContextBuilder.cs\n| | | \u251c\u2500Models\n| | | | \u2514DbContextCorrelationType.cs\n| | \u251c\u2500Attributes\n| | | \u2514AppDbContextAttribute.cs\n| \u251c\u2500Attributes\n| | \u2514DbParameterAttribute.cs\n| \u251c\u2500Advances\n| | \u251c\u2500Proxies\n| | | \u2514SqlDispatchProxy.cs\n| | \u251c\u2500Models\n| | | \u2514SqlProxyMethod.cs\n| | \u251c\u2500Dependencies\n| | | \u2514ISqlDispatchProxy.cs\n| | \u251c\u2500Attributes\n| | | \u251c\u2500SqlExecuteAttribute.cs\n| | | \u251c\u2500SqlFunctionAttribute.cs\n| | | \u251c\u2500SqlProcedureAttribute.cs\n| | | \u251c\u2500Basics\n| | | | \u251c\u2500SqlObjectProxyAttribute.cs\n| | | | \u251c\u2500SqlProxyAttribute.cs\n| | | | \u2514SqlSentenceProxyAttribute.cs\n\u251c\u2500CorsAccessor\n| \u251c\u2500Options\n| | \u2514CorsAccessorSettingsOptions.cs\n| \u251c\u2500Extensions\n| | \u251c\u2500CorsAccessorApplicationBuilderExtensions.cs\n| | \u2514CorsAccessorServiceCollectionExtensions.cs\n\u251c\u2500ConfigurableOptions\n| \u251c\u2500Options\n| | \u2514IConfigurableOptions.cs\n| \u251c\u2500Extensions\n| | \u2514ConfigurableOptionsServiceCollectionExtensions.cs\n| \u251c\u2500Attributes\n| | \u2514OptionsSettingsAttribute.cs\n\u251c\u2500Authorization\n| \u251c\u2500Penetrates.cs\n| \u251c\u2500Requirements\n| | \u2514AuthorizePolicyRequirement.cs\n| \u251c\u2500Providers\n| | \u2514AuthorizePolicyProvider.cs\n| \u251c\u2500Options\n| | \u2514JWTSettingsOptions.cs\n| \u251c\u2500Handlers\n| | \u2514AuthorizePolicyHandler.cs\n| \u251c\u2500Extensions\n| | \u2514PolicyAuthorizationServiceCollectionExtensions.cs\n| \u251c\u2500Attributes\n| | \u2514AuthorizePolicyAttribute.cs\n\u251c\u2500App\n| \u251c\u2500App.cs\n| \u251c\u2500Startups\n| | \u251c\u2500AppStartup.cs\n| | \u2514HostingStartup.cs\n| \u251c\u2500Options\n| | \u2514AppSettingsOptions.cs\n| \u251c\u2500Filters\n| | \u2514StartupFilter.cs\n| \u251c\u2500Extensions\n| | \u251c\u2500AppApplicationBuilderExtensions.cs\n| | \u251c\u2500AppServiceCollectionExtensions.cs\n| | \u251c\u2500WebHostBuilderExtensions.cs\n| | \u251c\u2500Types\n| | | \u2514ObjectExtensions.cs\n| \u251c\u2500Attributes\n| | \u2514AppStartupAttribute.cs\n")),Object(s.b)("h2",{id:"125-furapplication-\u4e1a\u52a1\u5e94\u7528\u5c42"},"1.2.5 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur.Application")," \u4e1a\u52a1\u5e94\u7528\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur.Application")," \u4e1a\u52a1\u5e94\u7528\u5c42\u662f\u6700\u5e38\u7528\u7684\u5c42\uff0c\u51e0\u4e4e\u6240\u6709\u7684\u4e1a\u52a1\u4ee3\u7801\u90fd\u5728\u8fd9\u4e2a\u5c42\u4e2d\u7f16\u5199\u3002"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"Fur.Application\n\u251c\u2500Fur.Application.Core.csproj\n\u251c\u2500Fur.Application.Core.xml\n\u2514FurApplicationStartup.cs\n")),Object(s.b)("h2",{id:"126-furcore-\u4ed3\u50a8\u5b9e\u4f53\u5c42"},"1.2.6 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur.Core")," \u4ed3\u50a8\u5b9e\u4f53\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur.Core")," \u4e3b\u8981\u662f\u5b58\u50a8\u81ea\u5b9a\u4e49\u4ed3\u50a8\u548c\u5b9a\u4e49\u5b9e\u4f53\u7684\u5c42\u3002"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"Fur.Core\n\u251c\u2500Fur.Core.csproj\n\u2514FurCoreStartup.cs\n")),Object(s.b)("h2",{id:"127-furdatabasemigrations-\u6570\u636e\u5e93\u67b6\u6784\u7ef4\u62a4\u5c42"},"1.2.7 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur.Database.Migrations")," \u6570\u636e\u5e93\u67b6\u6784\u7ef4\u62a4\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur.Database.Migrations")," \u4e3b\u8981\u662f\u7528\u6765\u5b58\u653e ",Object(s.b)("inlineCode",{parentName:"p"},"Database First")," \u548c ",Object(s.b)("inlineCode",{parentName:"p"},"Code First")," \u751f\u6210\u7684\u7ef4\u62a4\u6587\u4ef6\u3002"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"Fur.Database.Migrations\n\u2514Fur.Database.Migrations.csproj\n")),Object(s.b)("h2",{id:"128-furentityframeworkcore-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u914d\u7f6e\u5c42"},"1.2.8 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur.EntityFramework.Core")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u914d\u7f6e\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u4e3b\u8981\u662f\u7528\u6765\u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u548c\u5176\u4ed6\u6570\u636e\u5e93\u76f8\u5173\u914d\u7f6e\u4fe1\u606f\u7684\u3002"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"Fur.EntityFramework.Core\n\u2514Fur.EntityFramework.Core.csproj\n")),Object(s.b)("h2",{id:"129-furwebcore-\u5e94\u7528\u6838\u5fc3\u5c42"},"1.2.9 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur.Web.Core")," \u5e94\u7528\u6838\u5fc3\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur.Web.Core")," \u4e3b\u8981\u662f\u7528\u6765\u914d\u7f6e Web \u5165\u53e3\u4e00\u4e9b\u4ee3\u7801\uff0c\u5982 ",Object(s.b)("inlineCode",{parentName:"p"},"Filter"),"\uff0c",Object(s.b)("inlineCode",{parentName:"p"},"Middlewares")," \u7b49\u3002"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"Fur.Web.Core\n\u251c\u2500Fur.Web.Core.xml\n\u2514FurWebCoreStartup.cs\n")),Object(s.b)("h2",{id:"1210-furwebentry-\u5e94\u7528\u5165\u53e3\u5c42"},"1.2.10 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur.Web.Entry")," \u5e94\u7528\u5165\u53e3\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur.Web.Entry")," \u662f\u6211\u4eec\u7684\u5e94\u7528\u5c42\uff0c\u4e5f\u5c31\u662f\u6211\u4eec\u7684 ",Object(s.b)("inlineCode",{parentName:"p"},"Web")," \u9879\u76ee\u5c42\uff0c\u53d1\u5e03\u5c42\u3002"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"Fur.Web.Entry\n\u251c\u2500appsettings.Development.json\n\u251c\u2500appsettings.json\n\u251c\u2500Fur.Web.Entry.csproj\n\u251c\u2500Fur.Web.Entry.csproj.user\n\u251c\u2500Fur.Web.Entry.xml\n\u251c\u2500Program.cs\n\u251c\u2500Startup.cs\n\u251c\u2500wwwroot\n| \u2514README.md\n\u251c\u2500Properties\n| \u2514launchSettings.json\n\u251c\u2500Controllers\n")))}p.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/34420422.f54e4fab.js b/handbook/build/34420422.f54e4fab.js new file mode 100644 index 00000000000..892df8dd1c9 --- /dev/null +++ b/handbook/build/34420422.f54e4fab.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[21],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return u})),t.d(n,"b",(function(){return m}));var r=t(0),i=t.n(r);function s(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function a(e){for(var n=1;n=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var l=i.a.createContext({}),p=function(e){var n=i.a.useContext(l),t=n;return e&&(t="function"==typeof e?e(n):a(a({},n),e)),t},u=function(e){var n=p(e.components);return i.a.createElement(l.Provider,{value:n},e.children)},b={inlineCode:"code",wrapper:function(e){var n=e.children;return i.a.createElement(i.a.Fragment,{},n)}},d=i.a.forwardRef((function(e,n){var t=e.components,r=e.mdxType,s=e.originalType,o=e.parentName,l=c(e,["components","mdxType","originalType","parentName"]),u=p(t),d=r,m=u["".concat(o,".").concat(d)]||u[d]||b[d]||s;return t?i.a.createElement(m,a(a({ref:n},l),{},{components:t})):i.a.createElement(m,a({ref:n},l))}));function m(e,n){var t=arguments,r=n&&n.mdxType;if("string"==typeof e||r){var s=t.length,o=new Array(s);o[0]=d;var a={};for(var c in n)hasOwnProperty.call(n,c)&&(a[c]=n[c]);a.originalType=e,a.mdxType="string"==typeof e?e:r,o[1]=a;for(var l=2;lFur.Tests \u6d4b\u8bd5\u5c42",id:"122-furtests-\u6d4b\u8bd5\u5c42",children:[]},{value:"1.2.3 Solution Items \u89e3\u51b3\u65b9\u6848\u914d\u7f6e\u5c42",id:"123-solution-items-\u89e3\u51b3\u65b9\u6848\u914d\u7f6e\u5c42",children:[]},{value:"1.2.4 Fur \u6838\u5fc3\u5c42",id:"124-fur-\u6838\u5fc3\u5c42",children:[]},{value:"1.2.5 Fur.Application \u4e1a\u52a1\u5e94\u7528\u5c42",id:"125-furapplication-\u4e1a\u52a1\u5e94\u7528\u5c42",children:[]},{value:"1.2.6 Fur.Core \u4ed3\u50a8\u5b9e\u4f53\u5c42",id:"126-furcore-\u4ed3\u50a8\u5b9e\u4f53\u5c42",children:[]},{value:"1.2.7 Fur.Database.Migrations \u6570\u636e\u5e93\u67b6\u6784\u7ef4\u62a4\u5c42",id:"127-furdatabasemigrations-\u6570\u636e\u5e93\u67b6\u6784\u7ef4\u62a4\u5c42",children:[]},{value:"1.2.8 Fur.EntityFramework.Core \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u914d\u7f6e\u5c42",id:"128-furentityframeworkcore-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u914d\u7f6e\u5c42",children:[]},{value:"1.2.9 Fur.Web.Core \u5e94\u7528\u6838\u5fc3\u5c42",id:"129-furwebcore-\u5e94\u7528\u6838\u5fc3\u5c42",children:[]},{value:"1.2.10 Fur.Web.Entry \u5e94\u7528\u5165\u53e3\u5c42",id:"1210-furwebentry-\u5e94\u7528\u5165\u53e3\u5c42",children:[]}],l={rightToc:c};function p(e){var n=e.components,t=Object(i.a)(e,["components"]);return Object(s.b)("wrapper",Object(r.a)({},l,t,{components:n,mdxType:"MDXLayout"}),Object(s.b)("h2",{id:"121-\u6e90\u7801\u67b6\u6784"},"1.2.1 \u6e90\u7801\u67b6\u6784"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur")," \u521b\u5efa\u91c7\u7528\u591a\u5c42\u5206\u5c42\u8bbe\u8ba1\uff0c\u4e3b\u8981\u8bbe\u8ba1\u662f ",Object(s.b)("inlineCode",{parentName:"p"},"\u81ea\u52a8\u62bd\u8c61\u5de5\u5382")," \u548c ",Object(s.b)("inlineCode",{parentName:"p"},"DDD \u9886\u57df\u9a71\u52a8\u8bbe\u8ba1")," \u76f8\u7ed3\u5408\u3002"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u9879\u76ee\u7ed3\u6784\u5982\u4e0b\uff1a"),Object(s.b)("ul",null,Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur.Tests"),"\uff1a\u6d4b\u8bd5\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Solution Items"),"\uff1a\u89e3\u51b3\u65b9\u6848\u914d\u7f6e\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur"),"\uff1a\u6846\u67b6\u6838\u5fc3\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur.Application"),"\uff1a\u4e1a\u52a1\u5e94\u7528\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur.Core"),"\uff1a\u4ed3\u50a8\u5b9e\u4f53\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur.Database.Migrations"),"\uff1a\u67b6\u6784\u7ef4\u62a4\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur.EntityFramework.Core"),"\uff1aEF Core \u914d\u7f6e\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur.Web.Core"),"\uff1aWeb \u6838\u5fc3\u5c42"),Object(s.b)("li",{parentName:"ul"},Object(s.b)("inlineCode",{parentName:"li"},"Fur.Web.Entry"),"\uff1aWeb \u5165\u53e3\u5c42/\u542f\u52a8\u5c42")),Object(s.b)("h2",{id:"122-furtests-\u6d4b\u8bd5\u5c42"},"1.2.2 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur.Tests")," \u6d4b\u8bd5\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur.Tests")," \u662f\u9879\u76ee\u7684\u6d4b\u8bd5\u5c42\uff0c\u76ee\u524d\u8fd8\u672a\u6574\u7406\u5b8c\u6210\u3002"),Object(s.b)("h2",{id:"123-solution-items-\u89e3\u51b3\u65b9\u6848\u914d\u7f6e\u5c42"},"1.2.3 ",Object(s.b)("inlineCode",{parentName:"h2"},"Solution Items")," \u89e3\u51b3\u65b9\u6848\u914d\u7f6e\u5c42"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{}),"Solution Items\n\u2514.editorconfig\n")),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Solution Items")," \u662f\u7528\u6765\u914d\u7f6e\u89e3\u51b3\u65b9\u6848\u4e2d\u4e00\u4e9b\u5168\u5c40\u914d\u7f6e\u7684\uff0c\u5982\u6bcf\u4e2a\u6587\u4ef6\u7684\u9876\u90e8\u7248\u6743\u4fe1\u606f\uff0c\u5982\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// -----------------------------------------------------------------------------\n// Fur \u662f .NET 5 \u5e73\u53f0\u4e0b\u6781\u6613\u5165\u95e8\u3001\u6781\u901f\u5f00\u53d1\u7684 Web \u5e94\u7528\u6846\u67b6\u3002\n// Copyright \xa9 2020 Fur, Baiqian Co.,Ltd.\n//\n// \u6846\u67b6\u540d\u79f0\uff1aFur\n// \u6846\u67b6\u4f5c\u8005\uff1a\u767e\u5c0f\u50e7\n// \u6846\u67b6\u7248\u672c\uff1a1.0.0\n// \u6e90\u7801\u5730\u5740\uff1aGitee\uff1ahttps://gitee.com/monksoul/Fur\n// Github\uff1ahttps://github.com/monksoul/Fur\n// \u5f00\u6e90\u534f\u8bae\uff1aApache-2.0\uff08http://www.apache.org/licenses/LICENSE-2.0\uff09\n// -----------------------------------------------------------------------------\n")),Object(s.b)("p",null,"\u76f8\u5173\u914d\u7f6e\u5728 ",Object(s.b)("inlineCode",{parentName:"p"},".editorconfig")," \u6700\u540e\u9762\u4e00\u884c\uff0c\u5982\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{127}","{127}":!0}),'# Rules in this file were initially inferred by Visual Studio IntelliCode from the D:\\MONK\\Fur\\framework codebase based on best match to current usage at 2020/9/2\n# You can modify the rules from these initially generated values to suit your own policies\n# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference\n[*.cs]\n\n\n#Core editorconfig formatting - indentation\n\n#use soft tabs (spaces) for indentation\nindent_style = space\n\n#Formatting - new line options\n\n#place else statements on a new line\ncsharp_new_line_before_else = true\n#require members of anonymous types to be on separate lines\ncsharp_new_line_before_members_in_anonymous_types = true\n#require members of object intializers to be on separate lines\ncsharp_new_line_before_members_in_object_initializers = true\n#require braces to be on a new line for accessors, methods, control_blocks, types, lambdas, object_collection_array_initializers, anonymous_types, and properties (also known as "Allman" style)\ncsharp_new_line_before_open_brace = accessors, methods, control_blocks, types, lambdas, object_collection_array_initializers, anonymous_types, properties\n\n#Formatting - organize using options\n\n#do not place System.* using directives before other using directives\ndotnet_sort_system_directives_first = false\n\n#Formatting - spacing options\n\n#require a space before the colon for bases or interfaces in a type declaration\ncsharp_space_after_colon_in_inheritance_clause = true\n#require a space after a keyword in a control flow statement such as a for loop\ncsharp_space_after_keywords_in_control_flow_statements = true\n#require a space before the colon for bases or interfaces in a type declaration\ncsharp_space_before_colon_in_inheritance_clause = true\n#remove space within empty argument list parentheses\ncsharp_space_between_method_call_empty_parameter_list_parentheses = false\n#remove space between method call name and opening parenthesis\ncsharp_space_between_method_call_name_and_opening_parenthesis = false\n#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call\ncsharp_space_between_method_call_parameter_list_parentheses = false\n#remove space within empty parameter list parentheses for a method declaration\ncsharp_space_between_method_declaration_empty_parameter_list_parentheses = false\n#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.\ncsharp_space_between_method_declaration_parameter_list_parentheses = false\n\n#Formatting - wrapping options\n\n#leave code block on single line\ncsharp_preserve_single_line_blocks = true\n#leave statements and member declarations on the same line\ncsharp_preserve_single_line_statements = true\n\n#Style - Code block preferences\n\n#prefer no curly braces if allowed\ncsharp_prefer_braces = false:suggestion\n\n#Style - expression bodied member options\n\n#prefer expression-bodied members for accessors\ncsharp_style_expression_bodied_accessors = true:suggestion\n#prefer block bodies for constructors\ncsharp_style_expression_bodied_constructors = false:suggestion\n#prefer block bodies for methods\ncsharp_style_expression_bodied_methods = false:suggestion\n#prefer expression-bodied members for properties\ncsharp_style_expression_bodied_properties = true:suggestion\n\n#Style - expression level options\n\n#prefer out variables to be declared inline in the argument list of a method call when possible\ncsharp_style_inlined_variable_declaration = true:suggestion\n#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them\ndotnet_style_predefined_type_for_member_access = true:suggestion\n\n#Style - Expression-level preferences\n\n#prefer default over default(T)\ncsharp_prefer_simple_default_expression = true:suggestion\n#prefer objects to be initialized using object initializers when possible\ndotnet_style_object_initializer = true:suggestion\n#prefer inferred anonymous type member names\ndotnet_style_prefer_inferred_anonymous_type_member_names = false:suggestion\n#prefer inferred tuple element names\ndotnet_style_prefer_inferred_tuple_names = true:suggestion\n\n#Style - implicit and explicit types\n\n#prefer var over explicit type in all cases, unless overridden by another code style rule\ncsharp_style_var_elsewhere = true:suggestion\n#prefer var is used to declare variables with built-in system types such as int\ncsharp_style_var_for_built_in_types = true:suggestion\n#prefer var when the type is already mentioned on the right-hand side of a declaration expression\ncsharp_style_var_when_type_is_apparent = true:suggestion\n\n#Style - language keyword and framework type options\n\n#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them\ndotnet_style_predefined_type_for_locals_parameters_members = true:suggestion\n\n#Style - Miscellaneous preferences\n\n#prefer local functions over anonymous functions\ncsharp_style_pattern_local_over_anonymous_function = true:suggestion\n\n#Style - modifier options\n\n#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods.\ndotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion\n\n#Style - Modifier preferences\n\n#when this rule is set to a list of modifiers, prefer the specified ordering.\ncsharp_preferred_modifier_order = public,private,internal,protected,virtual,static,async,abstract,readonly,sealed,override:suggestion\n\n#Style - qualification options\n\n#prefer fields not to be prefaced with this. or Me. in Visual Basic\ndotnet_style_qualification_for_field = false:suggestion\n#prefer methods not to be prefaced with this. or Me. in Visual Basic\ndotnet_style_qualification_for_method = false:suggestion\n#prefer properties not to be prefaced with this. or Me. in Visual Basic\ndotnet_style_qualification_for_property = false:suggestion\n\n# Add file header\nfile_header_template = -----------------------------------------------------------------------------\\nFur \u662f .NET 5 \u5e73\u53f0\u4e0b\u6781\u6613\u5165\u95e8\u3001\u6781\u901f\u5f00\u53d1\u7684 Web \u5e94\u7528\u6846\u67b6\u3002\\nCopyright \xa9 2020 Fur, Baiqian Co.,Ltd.\\n\\n\u6846\u67b6\u540d\u79f0\uff1aFur\\n\u6846\u67b6\u4f5c\u8005\uff1a\u767e\u5c0f\u50e7\\n\u6846\u67b6\u7248\u672c\uff1a1.0.0\\n\u6e90\u7801\u5730\u5740\uff1aGitee\uff1ahttps://gitee.com/monksoul/Fur \\n Github\uff1ahttps://github.com/monksoul/Fur \\n\u5f00\u6e90\u534f\u8bae\uff1aApache-2.0\uff08http://www.apache.org/licenses/LICENSE-2.0\uff09\\n-----------------------------------------------------------------------------\n')),Object(s.b)("h2",{id:"124-fur-\u6838\u5fc3\u5c42"},"1.2.4 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur")," \u6838\u5fc3\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur")," \u6838\u5fc3\u5c42\u662f ",Object(s.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u7684\u4e2d\u5fc3\uff0c\u4e5f\u662f ",Object(s.b)("inlineCode",{parentName:"p"},"Fur")," \u80fd\u591f\u652f\u6491\u8d77\u6765\u7684\u5fc5\u5907\u5c42\u3002"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{}),"Fur\n\u251c\u2500Fur.csproj\n\u251c\u2500Fur.csproj.user\n\u251c\u2500FurStartup.cs\n\u251c\u2500ViewEngine\n| \u251c\u2500IViewEngine.cs\n| \u251c\u2500ViewEngine.cs\n| \u251c\u2500Templates\n| | \u251c\u2500IViewEngineCompiledTemplate.cs\n| | \u251c\u2500IViewEngineTemplate.cs\n| | \u251c\u2500ViewEngineCompiledTemplate.cs\n| | \u2514ViewEngineTemplate.cs\n| \u251c\u2500Options\n| | \u2514ViewEngineCompilationOptions.cs\n| \u251c\u2500Models\n| | \u2514AnonymousTypeWrapper.cs\n| \u251c\u2500Exceptions\n| | \u251c\u2500ViewEngineCompilationException.cs\n| | \u2514ViewEngineException.cs\n| \u251c\u2500Compilations\n| | \u251c\u2500IViewEngineCompilationOptionsBuilder.cs\n| | \u2514ViewEngineCompilationOptionsBuilder.cs\n\u251c\u2500UnifyResult\n| \u251c\u2500Providers\n| | \u251c\u2500IUnifyResultProvider.cs\n| | \u2514RESTfulResultProvider.cs\n| \u251c\u2500Models\n| | \u2514RESTfulResult.cs\n| \u251c\u2500Filters\n| | \u2514SuccessUnifyResultFilter.cs\n| \u251c\u2500Extensions\n| | \u2514UnifyResultServiceCollectionExtensions.cs\n\u251c\u2500SpecificationDocument\n| \u251c\u2500Options\n| | \u2514SpecificationDocumentSettingsOptions.cs\n| \u251c\u2500Models\n| | \u251c\u2500GroupOrder.cs\n| | \u251c\u2500SpecificationOpenApiInfo.cs\n| | \u251c\u2500SpecificationOpenApiSecurityRequirementItem.cs\n| | \u2514SpecificationOpenApiSecurityScheme.cs\n| \u251c\u2500Extensions\n| | \u251c\u2500SpecificationDocumentApplicationBuilderExtensions.cs\n| | \u2514SpecificationDocumentServiceCollectionExtensions.cs\n| \u251c\u2500Builders\n| | \u2514SpecificationDocumentBuilder.cs\n| \u251c\u2500Assets\n| | \u2514index-mini-profiler.html\n\u251c\u2500ObjectMapper\n| \u251c\u2500Extensions\n| | \u2514ObjectMapperServiceCollectionExtensions.cs\n| \u251c\u2500Dependencies\n| | \u2514IObjectMapper.cs\n\u251c\u2500LinqBuilder\n| \u251c\u2500Visitors\n| | \u2514ParameterReplaceExpressionVisitor.cs\n| \u251c\u2500Extensions\n| | \u2514LinqExtensions.cs\n| \u251c\u2500Builders\n| | \u2514LinqExpression.cs\n\u251c\u2500FriendlyException\n| \u251c\u2500Oops.cs\n| \u251c\u2500Providers\n| | \u2514IErrorCodeTypeProvider.cs\n| \u251c\u2500Options\n| | \u2514ErrorCodeMessageSettingsOptions.cs\n| \u251c\u2500Models\n| | \u2514MethodIfException.cs\n| \u251c\u2500Filters\n| | \u2514FriendlyExceptionFilter.cs\n| \u251c\u2500Extensions\n| | \u2514FriendlyExceptionServiceCollectionExtensions.cs\n| \u251c\u2500Attributes\n| | \u251c\u2500ErrorCodeItemMetadataAttribute.cs\n| | \u251c\u2500ErrorCodeTypeAttribute.cs\n| | \u2514IfExceptionAttribute.cs\n\u251c\u2500DynamicApiController\n| \u251c\u2500Penetrates.cs\n| \u251c\u2500Providers\n| | \u2514DynamicApiControllerFeatureProvider.cs\n| \u251c\u2500Options\n| | \u2514DynamicApiControllerSettingsOptions.cs\n| \u251c\u2500Models\n| | \u2514ParameterRouteTemplate.cs\n| \u251c\u2500Extensions\n| | \u2514DynamicApiControllerServiceCollectionExtensions.cs\n| \u251c\u2500Enums\n| | \u2514ApiSeats.cs\n| \u251c\u2500Dependencies\n| | \u2514IDynamicApiController.cs\n| \u251c\u2500Conventions\n| | \u2514DynamicApiControllerApplicationModelConvention.cs\n| \u251c\u2500Attributes\n| | \u251c\u2500ApiDescriptionSettingsAttribute.cs\n| | \u251c\u2500ApiSeatAttribute.cs\n| | \u2514DynamicApiControllerAttribute.cs\n\u251c\u2500DependencyInjection\n| \u251c\u2500Options\n| | \u2514DependencyInjectionSettingsOptions.cs\n| \u251c\u2500Models\n| | \u2514ExternalService.cs\n| \u251c\u2500Extensions\n| | \u2514DependencyInjectionServiceCollectionExtensions.cs\n| \u251c\u2500Enums\n| | \u251c\u2500InjectionActions.cs\n| | \u251c\u2500InjectionPatterns.cs\n| | \u2514RegisterType.cs\n| \u251c\u2500Dependencies\n| | \u251c\u2500IPrivateDependency.cs\n| | \u251c\u2500IScoped.cs\n| | \u251c\u2500ISingleton.cs\n| | \u251c\u2500ITransient.cs\n| | \u251c\u2500Proxies\n| | | \u2514IDispatchProxy.cs\n| \u251c\u2500Attributes\n| | \u251c\u2500InjectionAttribute.cs\n| | \u2514SkipScanAttribute.cs\n\u251c\u2500DataValidation\n| \u251c\u2500Validators\n| | \u2514DataValidator.cs\n| \u251c\u2500Providers\n| | \u2514IValidationMessageTypeProvider.cs\n| \u251c\u2500Options\n| | \u2514ValidationTypeMessageSettingsOptions.cs\n| \u251c\u2500Models\n| | \u2514DataValidationResult.cs\n| \u251c\u2500Filters\n| | \u2514DataValidationFilter.cs\n| \u251c\u2500Extensions\n| | \u251c\u2500DataValidationExtensions.cs\n| | \u2514DataValidationServiceCollectionExtensions.cs\n| \u251c\u2500Enums\n| | \u251c\u2500ValidationPattern.cs\n| | \u2514ValidationTypes.cs\n| \u251c\u2500Attributes\n| | \u251c\u2500DataValidationAttribute.cs\n| | \u251c\u2500NonValidationAttribute.cs\n| | \u251c\u2500ValidationItemMetadataAttribute.cs\n| | \u251c\u2500ValidationMessageAttribute.cs\n| | \u251c\u2500ValidationMessageTypeAttribute.cs\n| | \u2514ValidationTypeAttribute.cs\n\u251c\u2500DataEncryption\n| \u251c\u2500AESEncryption.cs\n| \u251c\u2500DESCEncryption.cs\n| \u2514MD5Encryption.cs\n\u251c\u2500DatabaseAccessor\n| \u251c\u2500UnitOfWork\n| | \u251c\u2500Filters\n| | | \u2514UnitOfWorkFilter.cs\n| | \u251c\u2500Attributes\n| | | \u251c\u2500NonTransactAttribute.cs\n| | | \u2514UnitOfWorkAttribute.cs\n| \u251c\u2500Repositories\n| | \u251c\u2500EFCoreRepository.cs\n| | \u251c\u2500IMSRepository.cs\n| | \u251c\u2500IRepository.cs\n| | \u251c\u2500ISqlRepository.cs\n| | \u251c\u2500MSRepository.cs\n| | \u251c\u2500SqlRepository.cs\n| | \u251c\u2500Implantations\n| | | \u251c\u2500DeletableRepository.cs\n| | | \u251c\u2500InsertableRepository.cs\n| | | \u251c\u2500OperableRepository.cs\n| | | \u251c\u2500ReadableRepository.cs\n| | | \u251c\u2500SqlExecutableRepository.cs\n| | | \u251c\u2500SqlReaderRepository.cs\n| | | \u251c\u2500UpdateableRepository.cs\n| | | \u2514WritableRepository.cs\n| | \u251c\u2500Dependencies\n| | | \u251c\u2500IDeletableRepository.cs\n| | | \u251c\u2500IInsertableRepository.cs\n| | | \u251c\u2500IOperableRepository.cs\n| | | \u251c\u2500IReadableRepository.cs\n| | | \u251c\u2500IRepositoryDependency.cs\n| | | \u251c\u2500ISqlExecutableRepository.cs\n| | | \u251c\u2500ISqlReaderRepository.cs\n| | | \u251c\u2500IUpdateableRepository.cs\n| | | \u2514IWritableRepository.cs\n| \u251c\u2500Pools\n| | \u251c\u2500DbContextPool.cs\n| | \u2514IDbContextPool.cs\n| \u251c\u2500MultiTenants\n| | \u251c\u2500Locators\n| | | \u2514MultiTenantDbContextLocator.cs\n| | \u251c\u2500Enums\n| | | \u2514MultiTenantOptions.cs\n| | \u251c\u2500Entities\n| | | \u2514Tenant.cs\n| | \u251c\u2500Dependencies\n| | | \u251c\u2500IMultiTenantOnDatabase.cs\n| | | \u251c\u2500IMultiTenantOnSchema.cs\n| | | \u251c\u2500IMultiTenantOnTable.cs\n| | | \u2514IPrivateMultiTenant.cs\n| \u251c\u2500Models\n| | \u251c\u2500DbProvider.cs\n| | \u251c\u2500PagedList.cs\n| | \u251c\u2500ProcedureOutputResult.cs\n| | \u251c\u2500ProcedureOutputValue.cs\n| | \u251c\u2500SqlTemplate.cs\n| | \u2514SqlTemplateParameter.cs\n| \u251c\u2500Locators\n| | \u251c\u2500IDbContextLocator.cs\n| | \u2514MasterDbContextLocator.cs\n| \u251c\u2500Interceptors\n| | \u251c\u2500DbContextSaveChangesInterceptor.cs\n| | \u251c\u2500SqlCommandProfilerInterceptor.cs\n| | \u2514SqlConnectionProfilerInterceptor.cs\n| \u251c\u2500Helpers\n| | \u2514DbHelpers.cs\n| \u251c\u2500Extensions\n| | \u251c\u2500DatabaseAccessorServiceCollectionExtensions.cs\n| | \u251c\u2500PagedQueryableExtensions.cs\n| | \u251c\u2500Repositories\n| | | \u251c\u2500IEntityExtensions.cs\n| | | \u251c\u2500IEntityWithDbContextLocatorExtensions.cs\n| | | \u2514SqlExtensions.cs\n| | \u251c\u2500DatabaseProvider\n| | | \u251c\u2500DatabaseProviderServiceCollectionExtensions.cs\n| | | \u2514Penetrates.cs\n| | \u251c\u2500DatabaseFacade\n| | | \u251c\u2500DbDataConvertExtensions.cs\n| | | \u251c\u2500DbObjectExtensions.cs\n| | | \u2514SqlAdoNetExtensions.cs\n| \u251c\u2500Enums\n| | \u251c\u2500DbFunctionType.cs\n| | \u251c\u2500EFCoreErrorCodes.cs\n| | \u2514ManualOptions.cs\n| \u251c\u2500Entities\n| | \u251c\u2500Dependencies\n| | | \u251c\u2500Entity.cs\n| | | \u251c\u2500EntityBase.cs\n| | | \u251c\u2500EntityNotKey.cs\n| | | \u251c\u2500IEntity.cs\n| | | \u2514IEntityNotKey.cs\n| | \u251c\u2500Configures\n| | | \u251c\u2500IEntitySeedData.cs\n| | | \u251c\u2500IEntityTypeBuilder.cs\n| | | \u251c\u2500IModelBuilderFilter.cs\n| | | \u2514IPrivateModelBuilder.cs\n| | \u251c\u2500Attributes\n| | | \u251c\u2500FakeDeleteAttribute.cs\n| | | \u251c\u2500NonAutomaticAttribute.cs\n| | | \u2514QueryableFunctionAttribute.cs\n| \u251c\u2500DynamicModels\n| | \u251c\u2500DynamicModelCacheKeyFactory.cs\n| | \u2514IEntityMutableTable.cs\n| \u251c\u2500Contexts\n| | \u251c\u2500AppDbContext.cs\n| | \u251c\u2500Builders\n| | | \u251c\u2500AppDbContextBuilder.cs\n| | | \u251c\u2500Models\n| | | | \u2514DbContextCorrelationType.cs\n| | \u251c\u2500Attributes\n| | | \u2514AppDbContextAttribute.cs\n| \u251c\u2500Attributes\n| | \u2514DbParameterAttribute.cs\n| \u251c\u2500Advances\n| | \u251c\u2500Proxies\n| | | \u2514SqlDispatchProxy.cs\n| | \u251c\u2500Models\n| | | \u2514SqlProxyMethod.cs\n| | \u251c\u2500Dependencies\n| | | \u2514ISqlDispatchProxy.cs\n| | \u251c\u2500Attributes\n| | | \u251c\u2500SqlExecuteAttribute.cs\n| | | \u251c\u2500SqlFunctionAttribute.cs\n| | | \u251c\u2500SqlProcedureAttribute.cs\n| | | \u251c\u2500Basics\n| | | | \u251c\u2500SqlObjectProxyAttribute.cs\n| | | | \u251c\u2500SqlProxyAttribute.cs\n| | | | \u2514SqlSentenceProxyAttribute.cs\n\u251c\u2500CorsAccessor\n| \u251c\u2500Options\n| | \u2514CorsAccessorSettingsOptions.cs\n| \u251c\u2500Extensions\n| | \u251c\u2500CorsAccessorApplicationBuilderExtensions.cs\n| | \u2514CorsAccessorServiceCollectionExtensions.cs\n\u251c\u2500ConfigurableOptions\n| \u251c\u2500Options\n| | \u2514IConfigurableOptions.cs\n| \u251c\u2500Extensions\n| | \u2514ConfigurableOptionsServiceCollectionExtensions.cs\n| \u251c\u2500Attributes\n| | \u2514OptionsSettingsAttribute.cs\n\u251c\u2500Authorization\n| \u251c\u2500Penetrates.cs\n| \u251c\u2500Requirements\n| | \u2514AuthorizePolicyRequirement.cs\n| \u251c\u2500Providers\n| | \u2514AuthorizePolicyProvider.cs\n| \u251c\u2500Options\n| | \u2514JWTSettingsOptions.cs\n| \u251c\u2500Handlers\n| | \u2514AuthorizePolicyHandler.cs\n| \u251c\u2500Extensions\n| | \u2514PolicyAuthorizationServiceCollectionExtensions.cs\n| \u251c\u2500Attributes\n| | \u2514AuthorizePolicyAttribute.cs\n\u251c\u2500App\n| \u251c\u2500App.cs\n| \u251c\u2500Startups\n| | \u251c\u2500AppStartup.cs\n| | \u2514HostingStartup.cs\n| \u251c\u2500Options\n| | \u2514AppSettingsOptions.cs\n| \u251c\u2500Filters\n| | \u2514StartupFilter.cs\n| \u251c\u2500Extensions\n| | \u251c\u2500AppApplicationBuilderExtensions.cs\n| | \u251c\u2500AppServiceCollectionExtensions.cs\n| | \u251c\u2500WebHostBuilderExtensions.cs\n| | \u251c\u2500Types\n| | | \u2514ObjectExtensions.cs\n| \u251c\u2500Attributes\n| | \u2514AppStartupAttribute.cs\n")),Object(s.b)("h2",{id:"125-furapplication-\u4e1a\u52a1\u5e94\u7528\u5c42"},"1.2.5 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur.Application")," \u4e1a\u52a1\u5e94\u7528\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur.Application")," \u4e1a\u52a1\u5e94\u7528\u5c42\u662f\u6700\u5e38\u7528\u7684\u5c42\uff0c\u51e0\u4e4e\u6240\u6709\u7684\u4e1a\u52a1\u4ee3\u7801\u90fd\u5728\u8fd9\u4e2a\u5c42\u4e2d\u7f16\u5199\u3002"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"Fur.Application\n\u251c\u2500Fur.Application.Core.csproj\n\u251c\u2500Fur.Application.Core.xml\n\u2514FurApplicationStartup.cs\n")),Object(s.b)("h2",{id:"126-furcore-\u4ed3\u50a8\u5b9e\u4f53\u5c42"},"1.2.6 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur.Core")," \u4ed3\u50a8\u5b9e\u4f53\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur.Core")," \u4e3b\u8981\u662f\u5b58\u50a8\u81ea\u5b9a\u4e49\u4ed3\u50a8\u548c\u5b9a\u4e49\u5b9e\u4f53\u7684\u5c42\u3002"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"Fur.Core\n\u251c\u2500Fur.Core.csproj\n\u2514FurCoreStartup.cs\n")),Object(s.b)("h2",{id:"127-furdatabasemigrations-\u6570\u636e\u5e93\u67b6\u6784\u7ef4\u62a4\u5c42"},"1.2.7 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur.Database.Migrations")," \u6570\u636e\u5e93\u67b6\u6784\u7ef4\u62a4\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur.Database.Migrations")," \u4e3b\u8981\u662f\u7528\u6765\u5b58\u653e ",Object(s.b)("inlineCode",{parentName:"p"},"Database First")," \u548c ",Object(s.b)("inlineCode",{parentName:"p"},"Code First")," \u751f\u6210\u7684\u7ef4\u62a4\u6587\u4ef6\u3002"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"Fur.Database.Migrations\n\u2514Fur.Database.Migrations.csproj\n")),Object(s.b)("h2",{id:"128-furentityframeworkcore-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u914d\u7f6e\u5c42"},"1.2.8 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur.EntityFramework.Core")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u914d\u7f6e\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u4e3b\u8981\u662f\u7528\u6765\u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u548c\u5176\u4ed6\u6570\u636e\u5e93\u76f8\u5173\u914d\u7f6e\u4fe1\u606f\u7684\u3002"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"Fur.EntityFramework.Core\n\u2514Fur.EntityFramework.Core.csproj\n")),Object(s.b)("h2",{id:"129-furwebcore-\u5e94\u7528\u6838\u5fc3\u5c42"},"1.2.9 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur.Web.Core")," \u5e94\u7528\u6838\u5fc3\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur.Web.Core")," \u4e3b\u8981\u662f\u7528\u6765\u914d\u7f6e Web \u5165\u53e3\u4e00\u4e9b\u4ee3\u7801\uff0c\u5982 ",Object(s.b)("inlineCode",{parentName:"p"},"Filter"),"\uff0c",Object(s.b)("inlineCode",{parentName:"p"},"Middlewares")," \u7b49\u3002"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"Fur.Web.Core\n\u251c\u2500Fur.Web.Core.xml\n\u2514FurWebCoreStartup.cs\n")),Object(s.b)("h2",{id:"1210-furwebentry-\u5e94\u7528\u5165\u53e3\u5c42"},"1.2.10 ",Object(s.b)("inlineCode",{parentName:"h2"},"Fur.Web.Entry")," \u5e94\u7528\u5165\u53e3\u5c42"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"Fur.Web.Entry")," \u662f\u6211\u4eec\u7684\u5e94\u7528\u5c42\uff0c\u4e5f\u5c31\u662f\u6211\u4eec\u7684 ",Object(s.b)("inlineCode",{parentName:"p"},"Web")," \u9879\u76ee\u5c42\uff0c\u53d1\u5e03\u5c42\u3002"),Object(s.b)("p",null,"\u6e90\u7801\u7ed3\u6784\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"Fur.Web.Entry\n\u251c\u2500appsettings.Development.json\n\u251c\u2500appsettings.json\n\u251c\u2500Fur.Web.Entry.csproj\n\u251c\u2500Fur.Web.Entry.csproj.user\n\u251c\u2500Fur.Web.Entry.xml\n\u251c\u2500Program.cs\n\u251c\u2500Startup.cs\n\u251c\u2500wwwroot\n| \u2514README.md\n\u251c\u2500Properties\n| \u2514launchSettings.json\n\u251c\u2500Controllers\n")))}p.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/36793c62.d48973ba.js b/handbook/build/36793c62.81252910.js similarity index 56% rename from handbook/build/36793c62.d48973ba.js rename to handbook/build/36793c62.81252910.js index 1702540d192..a9038967530 100644 --- a/handbook/build/36793c62.d48973ba.js +++ b/handbook/build/36793c62.81252910.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[21],{142:function(e,t,r){"use strict";r.d(t,"a",(function(){return s})),r.d(t,"b",(function(){return m}));var n=r(0),o=r.n(n);function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var u=o.a.createContext({}),l=function(e){var t=o.a.useContext(u),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},s=function(e){var t=l(e.components);return o.a.createElement(u.Provider,{value:t},e.children)},f={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},d=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,u=p(e,["components","mdxType","originalType","parentName"]),s=l(r),d=n,m=s["".concat(c,".").concat(d)]||s[d]||f[d]||a;return r?o.a.createElement(m,i(i({ref:t},u),{},{components:r})):o.a.createElement(m,i({ref:t},u))}));function m(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var a=r.length,c=new Array(a);c[0]=d;var i={};for(var p in t)hasOwnProperty.call(t,p)&&(i[p]=t[p]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var u=2;u=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var p=o.a.createContext({}),l=function(e){var t=o.a.useContext(p),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},s=function(e){var t=l(e.components);return o.a.createElement(p.Provider,{value:t},e.children)},f={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},d=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),s=l(r),d=n,m=s["".concat(c,".").concat(d)]||s[d]||f[d]||a;return r?o.a.createElement(m,i(i({ref:t},p),{},{components:r})):o.a.createElement(m,i({ref:t},p))}));function m(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var a=r.length,c=new Array(a);c[0]=d;var i={};for(var u in t)hasOwnProperty.call(t,u)&&(i[u]=t[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var p=2;p=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var p=o.a.createContext({}),l=function(e){var t=o.a.useContext(p),r=t;return e&&(r="function"==typeof e?e(t):c(c({},t),e)),r},s=function(e){var t=l(e.components);return o.a.createElement(p.Provider,{value:t},e.children)},f={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},d=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,a=e.originalType,i=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),s=l(r),d=n,m=s["".concat(i,".").concat(d)]||s[d]||f[d]||a;return r?o.a.createElement(m,c(c({ref:t},p),{},{components:r})):o.a.createElement(m,c({ref:t},p))}));function m(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var a=r.length,i=new Array(a);i[0]=d;var c={};for(var u in t)hasOwnProperty.call(t,u)&&(c[u]=t[u]);c.originalType=e,c.mdxType="string"==typeof e?e:n,i[1]=c;for(var p=2;p=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var p=o.a.createContext({}),l=function(e){var t=o.a.useContext(p),r=t;return e&&(r="function"==typeof e?e(t):c(c({},t),e)),r},s=function(e){var t=l(e.components);return o.a.createElement(p.Provider,{value:t},e.children)},f={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},d=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,a=e.originalType,i=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),s=l(r),d=n,m=s["".concat(i,".").concat(d)]||s[d]||f[d]||a;return r?o.a.createElement(m,c(c({ref:t},p),{},{components:r})):o.a.createElement(m,c({ref:t},p))}));function m(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var a=r.length,i=new Array(a);i[0]=d;var c={};for(var u in t)hasOwnProperty.call(t,u)&&(c[u]=t[u]);c.originalType=e,c.mdxType="string"==typeof e?e:n,i[1]=c;for(var p=2;p=0||(n[a]=e[a]);return n}(e,t);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}var p=n.a.createContext({}),o=function(e){var t=n.a.useContext(p),a=t;return e&&(a="function"==typeof e?e(t):l(l({},t),e)),a},u=function(e){var t=o(e.components);return n.a.createElement(p.Provider,{value:t},e.children)},O={inlineCode:"code",wrapper:function(e){var t=e.children;return n.a.createElement(n.a.Fragment,{},t)}},m=n.a.forwardRef((function(e,t){var a=e.components,r=e.mdxType,b=e.originalType,c=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),u=o(a),m=r,g=u["".concat(c,".").concat(m)]||u[m]||O[m]||b;return a?n.a.createElement(g,l(l({ref:t},p),{},{components:a})):n.a.createElement(g,l({ref:t},p))}));function g(e,t){var a=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var b=a.length,c=new Array(b);c[0]=m;var l={};for(var i in t)hasOwnProperty.call(t,i)&&(l[i]=t[i]);l.originalType=e,l.mdxType="string"==typeof e?e:r,c[1]=l;for(var p=2;p=0||(n[a]=e[a]);return n}(e,t);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}var p=n.a.createContext({}),o=function(e){var t=n.a.useContext(p),a=t;return e&&(a="function"==typeof e?e(t):l(l({},t),e)),a},u=function(e){var t=o(e.components);return n.a.createElement(p.Provider,{value:t},e.children)},O={inlineCode:"code",wrapper:function(e){var t=e.children;return n.a.createElement(n.a.Fragment,{},t)}},m=n.a.forwardRef((function(e,t){var a=e.components,r=e.mdxType,b=e.originalType,c=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),u=o(a),m=r,g=u["".concat(c,".").concat(m)]||u[m]||O[m]||b;return a?n.a.createElement(g,l(l({ref:t},p),{},{components:a})):n.a.createElement(g,l({ref:t},p))}));function g(e,t){var a=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var b=a.length,c=new Array(b);c[0]=m;var l={};for(var i in t)hasOwnProperty.call(t,i)&&(l[i]=t[i]);l.originalType=e,l.mdxType="string"==typeof e?e:r,c[1]=l;for(var p=2;p=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var p=i.a.createContext({}),l=function(e){var t=i.a.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):b(b({},t),e)),n},s=function(e){var t=l(e.components);return i.a.createElement(p.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return i.a.createElement(i.a.Fragment,{},t)}},m=i.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,o=e.originalType,r=e.parentName,p=c(e,["components","mdxType","originalType","parentName"]),s=l(n),m=a,O=s["".concat(r,".").concat(m)]||s[m]||d[m]||o;return n?i.a.createElement(O,b(b({ref:t},p),{},{components:n})):i.a.createElement(O,b({ref:t},p))}));function O(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=n.length,r=new Array(o);r[0]=m;var b={};for(var c in t)hasOwnProperty.call(t,c)&&(b[c]=t[c]);b.originalType=e,b.mdxType="string"==typeof e?e:a,r[1]=b;for(var p=2;pAppDbContext",id:"912-appdbcontext",children:[]},{value:"9.1.3 AppDbContext \u548c DbContext \u533a\u522b",id:"913-appdbcontext-\u548c-dbcontext-\u533a\u522b",children:[]},{value:"9.1.4 \u5982\u4f55\u5b9a\u4e49\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"914-\u5982\u4f55\u5b9a\u4e49\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[{value:"9.1.4.1 \u521b\u5efa\u9ed8\u8ba4\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"9141-\u521b\u5efa\u9ed8\u8ba4\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"9.1.4.2 \u521b\u5efa\u5176\u4ed6\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"9142-\u521b\u5efa\u5176\u4ed6\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]}]},{value:"9.1.5 \u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32",id:"915-\u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32",children:[{value:"9.1.5.1 \u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e",id:"9151-\u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e",children:[]},{value:"9.1.5.2 [AppDbContext] \u65b9\u5f0f\u914d\u7f6e",id:"9152-appdbcontext-\u65b9\u5f0f\u914d\u7f6e",children:[]},{value:"9.1.5.3 OnConfiguring \u65b9\u5f0f\u914d\u7f6e",id:"9153-onconfiguring-\u65b9\u5f0f\u914d\u7f6e",children:[]}]},{value:"9.1.6 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4e49\u4f4d\u7f6e",id:"916-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4e49\u4f4d\u7f6e",children:[]},{value:"9.1.7 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u6ce8\u518c",id:"917-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u6ce8\u518c",children:[]},{value:"9.1.8 \u52a8\u6001\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5bf9\u8c61",id:"918-\u52a8\u6001\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5bf9\u8c61",children:[]},{value:"9.1.9 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"919-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],p={rightToc:c};function l(e){var t=e.components,n=Object(i.a)(e,["components"]);return Object(o.b)("wrapper",Object(a.a)({},p,n,{components:t,mdxType:"MDXLayout"}),Object(o.b)("h2",{id:"911-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"9.1.1 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(o.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u662f\u8d1f\u8d23\u548c\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u5bf9\u8c61\uff0c\u63d0\u4f9b\u7a0b\u5e8f\u5bf9\u6570\u636e\u5e93\u5b58\u53d6\u63d0\u4f9b\u4e86\u5927\u91cf\u7684\u65b9\u6cd5\u3002"),Object(o.b)("p",null,"\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u9ed8\u8ba4\u96c6\u6210\u4e86\u5fae\u8f6f\u4eb2\u513f\u5b50\uff1a",Object(o.b)("inlineCode",{parentName:"p"},"EntityFramework Core")," \uff0c\u4e5f\u5c31\u662f\u901a\u5e38\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u6307\u7684\u662f ",Object(o.b)("inlineCode",{parentName:"p"},"DbContext")," \u7c7b\u6216\u5b83\u7684\u5b9e\u73b0\u7c7b\u3002"),Object(o.b)("h2",{id:"912-appdbcontext"},"9.1.2 ",Object(o.b)("inlineCode",{parentName:"h2"},"AppDbContext")),Object(o.b)("p",null,"\u5728\u6211\u4eec\u5b9e\u9645\u9879\u76ee\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"EFCore")," \u63d0\u4f9b\u7684 ",Object(o.b)("inlineCode",{parentName:"p"},"DbContext")," \u64cd\u4f5c\u5bf9\u8c61\u64cd\u4f5c\u6570\u636e\u5e93\u6709\u4e9b\u7e41\u7410\u548c\u590d\u6742\uff0c\u4e14\u9ed8\u8ba4\u4e0d\u5177\u5907\u8bfb\u5199\u5206\u79bb\u3001\u591a\u5e93\u7b49\u64cd\u4f5c\u529f\u80fd\u3002"),Object(o.b)("p",null,"\u6240\u4ee5\uff0c",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86 ",Object(o.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u8be5\u4e0a\u4e0b\u6587\u7ee7\u627f\u81ea ",Object(o.b)("inlineCode",{parentName:"p"},"DbContext"),"\u3002"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u540e\u7eed\u7ae0\u8282\uff0c\u7686\u91c7\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"EFCore")," \u4ee3\u66ff ",Object(o.b)("inlineCode",{parentName:"p"},"EntityFramework Core"),"\u3002"))),Object(o.b)("h2",{id:"913-appdbcontext-\u548c-dbcontext-\u533a\u522b"},"9.1.3 ",Object(o.b)("inlineCode",{parentName:"h2"},"AppDbContext")," \u548c ",Object(o.b)("inlineCode",{parentName:"h2"},"DbContext")," \u533a\u522b"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u7ee7\u627f\u81ea ",Object(o.b)("inlineCode",{parentName:"li"},"DbContext"),"\uff0c\u5177\u5907 ",Object(o.b)("inlineCode",{parentName:"li"},"DbContext")," \u6240\u6709\u529f\u80fd\u3002"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u652f\u6301\u591a\u6570\u636e\u5e93\u64cd\u4f5c\u6cdb\u578b\u7248\u672c\uff0c\u5982\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u81ea\u52a8\u914d\u7f6e\u5b9e\u4f53\u4fe1\u606f\uff0c\u65e0\u9700\u5728 ",Object(o.b)("inlineCode",{parentName:"li"},"OnModelCreating")," \u4e2d\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u652f\u6301\u5185\u7f6e\u591a\u79df\u6237\u652f\u6301"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u652f\u6301\u5168\u5c40\u6a21\u578b\u914d\u7f6e\u62e6\u622a\u5668"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u652f\u6301\u6570\u636e\u63d0\u4ea4\u66f4\u6539\u591a\u4e2a\u4e8b\u4ef6"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u63d0\u4f9b\u66f4\u52a0\u5f3a\u5927\u7684\u6a21\u578b\u64cd\u4f5c\u80fd\u529b\uff0c\u5982\u679c ",Object(o.b)("inlineCode",{parentName:"li"},"Sql")," \u64cd\u4f5c\uff0c\u8bfb\u5199\u5206\u79bb\u7b49"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u80fd\u591f\u5f97\u5230 ",Object(o.b)("inlineCode",{parentName:"li"},"Fur")," \u6846\u67b6\u66f4\u591a\u7684\u529f\u80fd\u652f\u6301")),Object(o.b)("h2",{id:"914-\u5982\u4f55\u5b9a\u4e49\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"9.1.4 \u5982\u4f55\u5b9a\u4e49\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(o.b)("p",null,"\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u4e86\uff0c\u63d0\u4f9b\u4e86\u4e24\u79cd ",Object(o.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u5b9a\u4e49\u65b9\u5f0f\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u64cd\u4f5c\u9ed8\u8ba4\u6570\u636e\u5e93"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u64cd\u4f5c N \u4e2a\u6570\u636e\u5e93")),Object(o.b)("p",null,"\u5176\u4e2d ",Object(o.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u9ed8\u8ba4\u7ee7\u627f\u81ea ",Object(o.b)("inlineCode",{parentName:"p"},"AppDbContext"),"\u3002"),Object(o.b)("p",null,"\u4e0b\u9762\u662f\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u521b\u5efa\u7684\u591a\u4e2a\u4f8b\u5b50\uff1a"),Object(o.b)("h3",{id:"9141-\u521b\u5efa\u9ed8\u8ba4\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"9.1.4.1 \u521b\u5efa\u9ed8\u8ba4\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,6,12}","{1,6,12}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("\u8fde\u63a5\u5b57\u7b26\u4e32\u6216appsetting.json \u952e")]\n public class FurDbContext : AppDbContext // \u7ee7\u627f AppDbContext<> \u7c7b\n {\n /// \n /// \u7ee7\u627f\u7236\u7c7b\u6784\u9020\u51fd\u6570\n /// \n /// \n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(o.b)("h3",{id:"9142-\u521b\u5efa\u5176\u4ed6\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"9.1.4.2 \u521b\u5efa\u5176\u4ed6\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,6,12}","{1,6,12}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("\u8fde\u63a5\u5b57\u7b26\u4e32\u6216appsetting.json \u952e")]\n public class FurOtherDbContext : AppDbContext // \u7ee7\u627f AppDbContext<> \u7c7b\n {\n /// \n /// \u7ee7\u627f\u7236\u7c7b\u6784\u9020\u51fd\u6570\n /// \n /// \n public FurOtherDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(o.b)("div",{className:"admonition admonition-important alert alert--info"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u6240\u6709\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u90fd\u5e94\u8be5\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u9879\u76ee\u4e2d\u521b\u5efa\u3002\u5173\u4e8e ",Object(o.b)("inlineCode",{parentName:"p"},"TDbContextLocator")," \u5c06\u5728\u4e0b\u4e00\u7ae0\u8282 \u300a",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"dbcontext-locator"}),"9.2 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668"),"\u300b\u9610\u8ff0\u3002"))),Object(o.b)("h2",{id:"915-\u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32"},"9.1.5 \u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32"),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u591a\u79cd\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\u914d\u7f6e\u65b9\u5f0f\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e\uff1a",Object(o.b)("inlineCode",{parentName:"li"},'AddSqlServerPool("\u8fde\u63a5\u5b57\u7b26\u4e32")')," \u65b9\u5f0f"),Object(o.b)("li",{parentName:"ul"},"\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"li"},'[AppDbContext("\u8fde\u63a5\u5b57\u7b26\u4e32/Key")]')," \u7279\u6027\u65b9\u5f0f\uff08\u53ea\u5728 ",Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext \u5b9e\u73b0\u7c7b\u6709\u6548"),"\uff09",Object(o.b)("strong",{parentName:"li"},"\u63a8\u8350")),Object(o.b)("li",{parentName:"ul"},"\u901a\u8fc7\u91cd\u5199 ",Object(o.b)("inlineCode",{parentName:"li"},"OnConfiguring(DbContextOptionsBuilder optionsBuilder)")," \u914d\u7f6e")),Object(o.b)("h3",{id:"9151-\u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e"},"9.1.5.1 \u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{12-19} title="Fur.EntityFramework.Core\\FurEntityFrameworkCoreStartup.cs"',"{12-19}":!0,title:'"Fur.EntityFramework.Core\\FurEntityFrameworkCoreStartup.cs"'}),'using Fur.DependencyInjection;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(600)]\n public sealed class FurEntityFrameworkCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n // \u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u652f\u6301N\u4e2a\u6570\u636e\u5e93\n services.AddDatabaseAccessor(options =>\n {\n // \u914d\u7f6e\u9ed8\u8ba4\u6570\u636e\u5e93\n options.AddDbPool(DbProvider.SqlServer, "\u8fde\u63a5\u5b57\u7b26\u4e32");\n\n // \u914d\u7f6e\u591a\u4e2a\u6570\u636e\u5e93\uff0c\u591a\u4e2a\u6570\u636e\u5e93\u5fc5\u987b\u6307\u5b9a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\n options.AddDbPool(DbProvider.Sqlite, "\u8fde\u63a5\u5b57\u7b26\u4e32");\n });\n }\n }\n}\n')),Object(o.b)("h3",{id:"9152-appdbcontext-\u65b9\u5f0f\u914d\u7f6e"},"9.1.5.2 ",Object(o.b)("inlineCode",{parentName:"h3"},"[AppDbContext]")," \u65b9\u5f0f\u914d\u7f6e"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,6}","{1,6}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("DbConnectionString")] // \u652f\u6301 `appsetting.json` \u540d\u6216 \u8fde\u63a5\u5b57\u7b26\u4e32\n public class FurDbContext : AppDbContext\n {\n /// \n /// \u7ee7\u627f\u7236\u7c7b\u6784\u9020\u51fd\u6570\n /// \n /// \n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(o.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u63d0\u793a")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u63a8\u8350\u4f7f\u7528\u6b64\u65b9\u5f0f\u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\u3002"))),Object(o.b)("p",null,Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"[AppDbContext]"))," \u5185\u7f6e\u5c5e\u6027\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"ConnectionString"),"\uff1a\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u6216\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u8def\u5f84\uff08\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e\u67e5\u627e\uff09\uff0c\u6216 ",Object(o.b)("inlineCode",{parentName:"li"},"appsetting.json")," \u7684 ",Object(o.b)("inlineCode",{parentName:"li"},"ConnectionStrings")," \u914d\u7f6e\u5b57\u7b26\u4e32"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"TablePrefix"),"\uff1a\u5f53\u524d\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u8868\u7edf\u4e00\u524d\u7f00"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"TableSuffix"),"\uff1a\u5f53\u524d\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u8868\u7edf\u4e00\u540e\u7f00")),Object(o.b)("h3",{id:"9153-onconfiguring-\u65b9\u5f0f\u914d\u7f6e"},"9.1.5.3 ",Object(o.b)("inlineCode",{parentName:"h3"},"OnConfiguring")," \u65b9\u5f0f\u914d\u7f6e"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{16-20}","{16-20}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n public class FurDbContext : AppDbContext\n {\n /// \n /// \u7ee7\u627f\u7236\u7c7b\u6784\u9020\u51fd\u6570\n /// \n /// \n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)\n {\n base.OnConfiguring(optionsBuilder);\n\n optionsBuilder.UseSqlServer("\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32");\n }\n }\n}\n')),Object(o.b)("div",{className:"admonition admonition-important alert alert--info"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u8fd9\u4e09\u79cd\u65b9\u5f0f\u53ef\u4ee5\u540c\u65f6\u4f7f\u7528\uff0c\u4f46\u662f\u6709\u4f18\u5148\u7ea7\uff1a",Object(o.b)("inlineCode",{parentName:"p"},"[AppDbContext]")," -> ",Object(o.b)("inlineCode",{parentName:"p"},"\u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e")," -> ",Object(o.b)("inlineCode",{parentName:"p"},"OnConfiguring"),"\uff08\u4f4e\u5230\u9ad8\uff09"),Object(o.b)("p",{parentName:"div"},"\u4e5f\u5c31\u662f ",Object(o.b)("inlineCode",{parentName:"p"},"OnConfiguring")," \u914d\u7f6e\u4f1a\u8986\u76d6 ",Object(o.b)("inlineCode",{parentName:"p"},"\u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e")," \u914d\u7f6e\uff0c",Object(o.b)("inlineCode",{parentName:"p"},"\u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e")," \u914d\u7f6e\u4f1a\u8986\u76d6 ",Object(o.b)("inlineCode",{parentName:"p"},"[AppDbContext]")," \u914d\u7f6e\u6240\u914d\u7f6e\u7684\u8fde\u63a5\u5b57\u7b26\u4e32\u3002"))),Object(o.b)("h2",{id:"916-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4e49\u4f4d\u7f6e"},"9.1.6 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4e49\u4f4d\u7f6e"),Object(o.b)("div",{className:"admonition admonition-important alert alert--info"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u9700\u5b9a\u4e49\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u4e2d\uff0c\u4e14\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u90fd\u5fc5\u987b\u62e5\u6709\u552f\u4e00\u7684 ",Object(o.b)("inlineCode",{parentName:"p"},"DbContextLocator")," \u5b9a\u4f4d\u5668"))),Object(o.b)("h2",{id:"917-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u6ce8\u518c"},"9.1.7 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u6ce8\u518c"),Object(o.b)("p",null,"\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u914d\u7f6e\u597d\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\u540e\uff0c\u9700\u8981\u6ce8\u518c\u8be5\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u5e76\u6307\u5b9a\u6570\u636e\u5e93\u7c7b\u578b\uff0c\u5982\uff1a"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{11-13} title="Fur\\framework\\Fur.EntityFramework.Core\\FurEntityFrameworkCoreStartup.cs"',"{11-13}":!0,title:'"Fur\\framework\\Fur.EntityFramework.Core\\FurEntityFrameworkCoreStartup.cs"'}),"using Fur.DatabaseAccessor;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(600)]\n public sealed class FurEntityFrameworkCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddDatabaseAccessor(options =>\n {\n options.AddDbPool(DbProvider.Sqlite);\n });\n }\n }\n}\n")),Object(o.b)("p",null,"\u5982\u679c\u6709\u591a\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\uff0c",Object(o.b)("strong",{parentName:"p"},"\u90a3\u4e48\u4ece\u7b2c\u4e8c\u4e2a\u8d77\uff0c\u5c31\u9700\u8981\u7ed1\u5b9a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668"),"\uff0c\u5982\uff1a"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"options.AddDbPool(DbProvider.Sqlite); // \u7b2c\u4e00\u4e2a\u6570\u636e\u5e93\n\noptions.AddDbPool(DbProvider.SqlServer); // \u7b2c\u4e8c\u4e2a\u6570\u636e\u5e93\n\noptions.AddDbPool(DbProvider.SqlServer); // \u7b2c\u4e09\u4e2a\u6570\u636e\u5e93\n")),Object(o.b)("h2",{id:"918-\u52a8\u6001\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5bf9\u8c61"},"9.1.8 \u52a8\u6001\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5bf9\u8c61"),Object(o.b)("p",null,"\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u662f\u5b9a\u4e49\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u9879\u76ee\u5c42\uff0c\u5e76\u4e14\u8be5\u5c42\u4e0d\u88ab ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.Application")," \u548c ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.Core")," \u7b49\u5c42\u5f15\u7528\u3002"),Object(o.b)("p",null,"\u6240\u4ee5\u5c31\u4e0d\u80fd\u76f4\u63a5\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.Application")," \u9879\u76ee\u5c42\u76f4\u63a5\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u5b9a\u4e49\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u3002"),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u63d0\u4f9b\u4e86\u4e24\u79cd\u65b9\u5f0f\u5904\u7406\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"respository.DbContext")," \uff1a\u5f53\u524d\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5bf9\u8c61\uff0c\u8fd4\u56de\u662f ",Object(o.b)("inlineCode",{parentName:"li"},"DbContext")," \u62bd\u8c61\u7c7b\u578b"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"respository.DynamicDbContext"),"\uff1a\u5f53\u524d\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5bf9\u8c61\uff0c\u8fd4\u56de\u7684\u662f ",Object(o.b)("inlineCode",{parentName:"li"},"dynamic")," \u7c7b\u578b")),Object(o.b)("p",null,"\u5982\u679c\u4f60\u53ea\u662f\u60f3\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"DbContext")," \u7684\u529f\u80fd\uff0c\u76f4\u63a5\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"respository.DbContext")," \u5373\u53ef\uff0c\u5982\uff1a"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"respository.DbContext.SaveChanges();\n")),Object(o.b)("p",null,"\u5982\u679c\u4f60\u60f3\u80fd\u591f\u83b7\u53d6\u5177\u4f53\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u7c7b\u578b\uff0c\u5982 ",Object(o.b)("inlineCode",{parentName:"p"},"MyDbContext"),"\uff0c\u90a3\u4e48\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"respository.DynamicDbContext")," \u5c31\u53ef\u4ee5\u83b7\u53d6\u5230\u5177\u4f53\u7684 ",Object(o.b)("inlineCode",{parentName:"p"},"MyDbContext")," \u7c7b\u578b\u3002\u5982\uff1a"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var persons = respository.DynamicDbContext.Persons.Find(1);\nvar users = respository.DynamicDbContext.Users;\n")),Object(o.b)("p",null,"\u8fd9\u6837\u5c31\u53ef\u4ee5\u76f4\u63a5\u64cd\u4f5c ",Object(o.b)("inlineCode",{parentName:"p"},"MyDbContext")," \u5b9a\u4e49\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u4e86\u3002"),Object(o.b)("h2",{id:"919-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.1.9 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))),Object(o.b)("hr",null),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(o.b)("inlineCode",{parentName:"p"},"\u6570\u636e\u5e93\u4e0a\u4e0b\u6587")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/ef/core/miscellaneous/configuring-dbcontext"}),"EF Core - \u914d\u7f6e DbContext")," \u7ae0\u8282\u3002"))))}l.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/3e869f93.8686d66c.js b/handbook/build/3e869f93.8686d66c.js deleted file mode 100644 index 8f216eca327..00000000000 --- a/handbook/build/3e869f93.8686d66c.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[24],{142:function(e,t,n){"use strict";n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return O}));var a=n(0),i=n.n(a);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e){for(var t=1;t=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var p=i.a.createContext({}),l=function(e){var t=i.a.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):b(b({},t),e)),n},s=function(e){var t=l(e.components);return i.a.createElement(p.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return i.a.createElement(i.a.Fragment,{},t)}},m=i.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,o=e.originalType,r=e.parentName,p=c(e,["components","mdxType","originalType","parentName"]),s=l(n),m=a,O=s["".concat(r,".").concat(m)]||s[m]||d[m]||o;return n?i.a.createElement(O,b(b({ref:t},p),{},{components:n})):i.a.createElement(O,b({ref:t},p))}));function O(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=n.length,r=new Array(o);r[0]=m;var b={};for(var c in t)hasOwnProperty.call(t,c)&&(b[c]=t[c]);b.originalType=e,b.mdxType="string"==typeof e?e:a,r[1]=b;for(var p=2;pAppDbContext",id:"912-appdbcontext",children:[]},{value:"9.1.3 AppDbContext \u548c DbContext \u533a\u522b",id:"913-appdbcontext-\u548c-dbcontext-\u533a\u522b",children:[]},{value:"9.1.4 \u5982\u4f55\u5b9a\u4e49\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"914-\u5982\u4f55\u5b9a\u4e49\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[{value:"9.1.4.1 \u521b\u5efa\u9ed8\u8ba4\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"9141-\u521b\u5efa\u9ed8\u8ba4\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"9.1.4.2 \u521b\u5efa\u5176\u4ed6\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"9142-\u521b\u5efa\u5176\u4ed6\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]}]},{value:"9.1.5 \u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32",id:"915-\u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32",children:[{value:"9.1.5.1 \u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e",id:"9151-\u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e",children:[]},{value:"9.1.5.2 [AppDbContext] \u65b9\u5f0f\u914d\u7f6e",id:"9152-appdbcontext-\u65b9\u5f0f\u914d\u7f6e",children:[]},{value:"9.1.5.3 OnConfiguring \u65b9\u5f0f\u914d\u7f6e",id:"9153-onconfiguring-\u65b9\u5f0f\u914d\u7f6e",children:[]}]},{value:"9.1.6 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4e49\u4f4d\u7f6e",id:"916-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4e49\u4f4d\u7f6e",children:[]},{value:"9.1.7 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u6ce8\u518c",id:"917-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u6ce8\u518c",children:[]},{value:"9.1.8 \u52a8\u6001\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5bf9\u8c61",id:"918-\u52a8\u6001\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5bf9\u8c61",children:[]},{value:"9.1.9 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"919-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],p={rightToc:c};function l(e){var t=e.components,n=Object(i.a)(e,["components"]);return Object(o.b)("wrapper",Object(a.a)({},p,n,{components:t,mdxType:"MDXLayout"}),Object(o.b)("h2",{id:"911-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"9.1.1 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(o.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u662f\u8d1f\u8d23\u548c\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u5bf9\u8c61\uff0c\u63d0\u4f9b\u7a0b\u5e8f\u5bf9\u6570\u636e\u5e93\u5b58\u53d6\u63d0\u4f9b\u4e86\u5927\u91cf\u7684\u65b9\u6cd5\u3002"),Object(o.b)("p",null,"\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u9ed8\u8ba4\u96c6\u6210\u4e86\u5fae\u8f6f\u4eb2\u513f\u5b50\uff1a",Object(o.b)("inlineCode",{parentName:"p"},"EntityFramework Core")," \uff0c\u4e5f\u5c31\u662f\u901a\u5e38\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u6307\u7684\u662f ",Object(o.b)("inlineCode",{parentName:"p"},"DbContext")," \u7c7b\u6216\u5b83\u7684\u5b9e\u73b0\u7c7b\u3002"),Object(o.b)("h2",{id:"912-appdbcontext"},"9.1.2 ",Object(o.b)("inlineCode",{parentName:"h2"},"AppDbContext")),Object(o.b)("p",null,"\u5728\u6211\u4eec\u5b9e\u9645\u9879\u76ee\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"EFCore")," \u63d0\u4f9b\u7684 ",Object(o.b)("inlineCode",{parentName:"p"},"DbContext")," \u64cd\u4f5c\u5bf9\u8c61\u64cd\u4f5c\u6570\u636e\u5e93\u6709\u4e9b\u7e41\u7410\u548c\u590d\u6742\uff0c\u4e14\u9ed8\u8ba4\u4e0d\u5177\u5907\u8bfb\u5199\u5206\u79bb\u3001\u591a\u5e93\u7b49\u64cd\u4f5c\u529f\u80fd\u3002"),Object(o.b)("p",null,"\u6240\u4ee5\uff0c",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86 ",Object(o.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u8be5\u4e0a\u4e0b\u6587\u7ee7\u627f\u81ea ",Object(o.b)("inlineCode",{parentName:"p"},"DbContext"),"\u3002"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u540e\u7eed\u7ae0\u8282\uff0c\u7686\u91c7\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"EFCore")," \u4ee3\u66ff ",Object(o.b)("inlineCode",{parentName:"p"},"EntityFramework Core"),"\u3002"))),Object(o.b)("h2",{id:"913-appdbcontext-\u548c-dbcontext-\u533a\u522b"},"9.1.3 ",Object(o.b)("inlineCode",{parentName:"h2"},"AppDbContext")," \u548c ",Object(o.b)("inlineCode",{parentName:"h2"},"DbContext")," \u533a\u522b"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u7ee7\u627f\u81ea ",Object(o.b)("inlineCode",{parentName:"li"},"DbContext"),"\uff0c\u5177\u5907 ",Object(o.b)("inlineCode",{parentName:"li"},"DbContext")," \u6240\u6709\u529f\u80fd\u3002"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u652f\u6301\u591a\u6570\u636e\u5e93\u64cd\u4f5c\u6cdb\u578b\u7248\u672c\uff0c\u5982\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u81ea\u52a8\u914d\u7f6e\u5b9e\u4f53\u4fe1\u606f\uff0c\u65e0\u9700\u5728 ",Object(o.b)("inlineCode",{parentName:"li"},"OnModelCreating")," \u4e2d\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u652f\u6301\u5185\u7f6e\u591a\u79df\u6237\u652f\u6301"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u652f\u6301\u5168\u5c40\u6a21\u578b\u914d\u7f6e\u62e6\u622a\u5668"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u652f\u6301\u6570\u636e\u63d0\u4ea4\u66f4\u6539\u591a\u4e2a\u4e8b\u4ef6"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u63d0\u4f9b\u66f4\u52a0\u5f3a\u5927\u7684\u6a21\u578b\u64cd\u4f5c\u80fd\u529b\uff0c\u5982\u679c ",Object(o.b)("inlineCode",{parentName:"li"},"Sql")," \u64cd\u4f5c\uff0c\u8bfb\u5199\u5206\u79bb\u7b49"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u80fd\u591f\u5f97\u5230 ",Object(o.b)("inlineCode",{parentName:"li"},"Fur")," \u6846\u67b6\u66f4\u591a\u7684\u529f\u80fd\u652f\u6301")),Object(o.b)("h2",{id:"914-\u5982\u4f55\u5b9a\u4e49\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"9.1.4 \u5982\u4f55\u5b9a\u4e49\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(o.b)("p",null,"\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u4e86\uff0c\u63d0\u4f9b\u4e86\u4e24\u79cd ",Object(o.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u5b9a\u4e49\u65b9\u5f0f\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u64cd\u4f5c\u9ed8\u8ba4\u6570\u636e\u5e93"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext")," \u64cd\u4f5c N \u4e2a\u6570\u636e\u5e93")),Object(o.b)("p",null,"\u5176\u4e2d ",Object(o.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u9ed8\u8ba4\u7ee7\u627f\u81ea ",Object(o.b)("inlineCode",{parentName:"p"},"AppDbContext"),"\u3002"),Object(o.b)("p",null,"\u4e0b\u9762\u662f\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u521b\u5efa\u7684\u591a\u4e2a\u4f8b\u5b50\uff1a"),Object(o.b)("h3",{id:"9141-\u521b\u5efa\u9ed8\u8ba4\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"9.1.4.1 \u521b\u5efa\u9ed8\u8ba4\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,6,12}","{1,6,12}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("\u8fde\u63a5\u5b57\u7b26\u4e32\u6216appsetting.json \u952e")]\n public class FurDbContext : AppDbContext // \u7ee7\u627f AppDbContext<> \u7c7b\n {\n /// \n /// \u7ee7\u627f\u7236\u7c7b\u6784\u9020\u51fd\u6570\n /// \n /// \n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(o.b)("h3",{id:"9142-\u521b\u5efa\u5176\u4ed6\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"9.1.4.2 \u521b\u5efa\u5176\u4ed6\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,6,12}","{1,6,12}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("\u8fde\u63a5\u5b57\u7b26\u4e32\u6216appsetting.json \u952e")]\n public class FurOtherDbContext : AppDbContext // \u7ee7\u627f AppDbContext<> \u7c7b\n {\n /// \n /// \u7ee7\u627f\u7236\u7c7b\u6784\u9020\u51fd\u6570\n /// \n /// \n public FurOtherDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(o.b)("div",{className:"admonition admonition-important alert alert--info"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u6240\u6709\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u90fd\u5e94\u8be5\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u9879\u76ee\u4e2d\u521b\u5efa\u3002\u5173\u4e8e ",Object(o.b)("inlineCode",{parentName:"p"},"TDbContextLocator")," \u5c06\u5728\u4e0b\u4e00\u7ae0\u8282 \u300a",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"dbcontext-locator"}),"9.2 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668"),"\u300b\u9610\u8ff0\u3002"))),Object(o.b)("h2",{id:"915-\u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32"},"9.1.5 \u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32"),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u591a\u79cd\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\u914d\u7f6e\u65b9\u5f0f\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e\uff1a",Object(o.b)("inlineCode",{parentName:"li"},'AddSqlServerPool("\u8fde\u63a5\u5b57\u7b26\u4e32")')," \u65b9\u5f0f"),Object(o.b)("li",{parentName:"ul"},"\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"li"},'[AppDbContext("\u8fde\u63a5\u5b57\u7b26\u4e32/Key")]')," \u7279\u6027\u65b9\u5f0f\uff08\u53ea\u5728 ",Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext \u5b9e\u73b0\u7c7b\u6709\u6548"),"\uff09",Object(o.b)("strong",{parentName:"li"},"\u63a8\u8350")),Object(o.b)("li",{parentName:"ul"},"\u901a\u8fc7\u91cd\u5199 ",Object(o.b)("inlineCode",{parentName:"li"},"OnConfiguring(DbContextOptionsBuilder optionsBuilder)")," \u914d\u7f6e")),Object(o.b)("h3",{id:"9151-\u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e"},"9.1.5.1 \u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{12-19} title="Fur.EntityFramework.Core\\FurEntityFrameworkCoreStartup.cs"',"{12-19}":!0,title:'"Fur.EntityFramework.Core\\FurEntityFrameworkCoreStartup.cs"'}),'using Fur.DependencyInjection;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(600)]\n public sealed class FurEntityFrameworkCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n // \u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u652f\u6301N\u4e2a\u6570\u636e\u5e93\n services.AddDatabaseAccessor(options =>\n {\n // \u914d\u7f6e\u9ed8\u8ba4\u6570\u636e\u5e93\n options.AddDbPool(DbProvider.SqlServer, "\u8fde\u63a5\u5b57\u7b26\u4e32");\n\n // \u914d\u7f6e\u591a\u4e2a\u6570\u636e\u5e93\uff0c\u591a\u4e2a\u6570\u636e\u5e93\u5fc5\u987b\u6307\u5b9a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\n options.AddDbPool(DbProvider.Sqlite, "\u8fde\u63a5\u5b57\u7b26\u4e32");\n });\n }\n }\n}\n')),Object(o.b)("h3",{id:"9152-appdbcontext-\u65b9\u5f0f\u914d\u7f6e"},"9.1.5.2 ",Object(o.b)("inlineCode",{parentName:"h3"},"[AppDbContext]")," \u65b9\u5f0f\u914d\u7f6e"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,6}","{1,6}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("DbConnectionString")] // \u652f\u6301 `appsetting.json` \u540d\u6216 \u8fde\u63a5\u5b57\u7b26\u4e32\n public class FurDbContext : AppDbContext\n {\n /// \n /// \u7ee7\u627f\u7236\u7c7b\u6784\u9020\u51fd\u6570\n /// \n /// \n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(o.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u63d0\u793a")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u63a8\u8350\u4f7f\u7528\u6b64\u65b9\u5f0f\u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\u3002"))),Object(o.b)("p",null,Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"[AppDbContext]"))," \u5185\u7f6e\u5c5e\u6027\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"ConnectionString"),"\uff1a\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u6216\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u8def\u5f84\uff08\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e\u67e5\u627e\uff09\uff0c\u6216 ",Object(o.b)("inlineCode",{parentName:"li"},"appsetting.json")," \u7684 ",Object(o.b)("inlineCode",{parentName:"li"},"ConnectionStrings")," \u914d\u7f6e\u5b57\u7b26\u4e32"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"TablePrefix"),"\uff1a\u5f53\u524d\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u8868\u7edf\u4e00\u524d\u7f00"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"TableSuffix"),"\uff1a\u5f53\u524d\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u8868\u7edf\u4e00\u540e\u7f00")),Object(o.b)("h3",{id:"9153-onconfiguring-\u65b9\u5f0f\u914d\u7f6e"},"9.1.5.3 ",Object(o.b)("inlineCode",{parentName:"h3"},"OnConfiguring")," \u65b9\u5f0f\u914d\u7f6e"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{16-20}","{16-20}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n public class FurDbContext : AppDbContext\n {\n /// \n /// \u7ee7\u627f\u7236\u7c7b\u6784\u9020\u51fd\u6570\n /// \n /// \n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)\n {\n base.OnConfiguring(optionsBuilder);\n\n optionsBuilder.UseSqlServer("\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32");\n }\n }\n}\n')),Object(o.b)("div",{className:"admonition admonition-important alert alert--info"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u8fd9\u4e09\u79cd\u65b9\u5f0f\u53ef\u4ee5\u540c\u65f6\u4f7f\u7528\uff0c\u4f46\u662f\u6709\u4f18\u5148\u7ea7\uff1a",Object(o.b)("inlineCode",{parentName:"p"},"[AppDbContext]")," -> ",Object(o.b)("inlineCode",{parentName:"p"},"\u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e")," -> ",Object(o.b)("inlineCode",{parentName:"p"},"OnConfiguring"),"\uff08\u4f4e\u5230\u9ad8\uff09"),Object(o.b)("p",{parentName:"div"},"\u4e5f\u5c31\u662f ",Object(o.b)("inlineCode",{parentName:"p"},"OnConfiguring")," \u914d\u7f6e\u4f1a\u8986\u76d6 ",Object(o.b)("inlineCode",{parentName:"p"},"\u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e")," \u914d\u7f6e\uff0c",Object(o.b)("inlineCode",{parentName:"p"},"\u5728\u6ce8\u518c\u6570\u636e\u5e93\u670d\u52a1\u65f6\u914d\u7f6e")," \u914d\u7f6e\u4f1a\u8986\u76d6 ",Object(o.b)("inlineCode",{parentName:"p"},"[AppDbContext]")," \u914d\u7f6e\u6240\u914d\u7f6e\u7684\u8fde\u63a5\u5b57\u7b26\u4e32\u3002"))),Object(o.b)("h2",{id:"916-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4e49\u4f4d\u7f6e"},"9.1.6 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4e49\u4f4d\u7f6e"),Object(o.b)("div",{className:"admonition admonition-important alert alert--info"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u9700\u5b9a\u4e49\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u4e2d\uff0c\u4e14\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u90fd\u5fc5\u987b\u62e5\u6709\u552f\u4e00\u7684 ",Object(o.b)("inlineCode",{parentName:"p"},"DbContextLocator")," \u5b9a\u4f4d\u5668"))),Object(o.b)("h2",{id:"917-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u6ce8\u518c"},"9.1.7 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u6ce8\u518c"),Object(o.b)("p",null,"\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u914d\u7f6e\u597d\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\u540e\uff0c\u9700\u8981\u6ce8\u518c\u8be5\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u5e76\u6307\u5b9a\u6570\u636e\u5e93\u7c7b\u578b\uff0c\u5982\uff1a"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{11-13} title="Fur\\framework\\Fur.EntityFramework.Core\\FurEntityFrameworkCoreStartup.cs"',"{11-13}":!0,title:'"Fur\\framework\\Fur.EntityFramework.Core\\FurEntityFrameworkCoreStartup.cs"'}),"using Fur.DatabaseAccessor;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(600)]\n public sealed class FurEntityFrameworkCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddDatabaseAccessor(options =>\n {\n options.AddDbPool(DbProvider.Sqlite);\n });\n }\n }\n}\n")),Object(o.b)("p",null,"\u5982\u679c\u6709\u591a\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\uff0c",Object(o.b)("strong",{parentName:"p"},"\u90a3\u4e48\u4ece\u7b2c\u4e8c\u4e2a\u8d77\uff0c\u5c31\u9700\u8981\u7ed1\u5b9a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668"),"\uff0c\u5982\uff1a"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"options.AddDbPool(DbProvider.Sqlite); // \u7b2c\u4e00\u4e2a\u6570\u636e\u5e93\n\noptions.AddDbPool(DbProvider.SqlServer); // \u7b2c\u4e8c\u4e2a\u6570\u636e\u5e93\n\noptions.AddDbPool(DbProvider.SqlServer); // \u7b2c\u4e09\u4e2a\u6570\u636e\u5e93\n")),Object(o.b)("h2",{id:"918-\u52a8\u6001\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5bf9\u8c61"},"9.1.8 \u52a8\u6001\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5bf9\u8c61"),Object(o.b)("p",null,"\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u662f\u5b9a\u4e49\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u9879\u76ee\u5c42\uff0c\u5e76\u4e14\u8be5\u5c42\u4e0d\u88ab ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.Application")," \u548c ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.Core")," \u7b49\u5c42\u5f15\u7528\u3002"),Object(o.b)("p",null,"\u6240\u4ee5\u5c31\u4e0d\u80fd\u76f4\u63a5\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.Application")," \u9879\u76ee\u5c42\u76f4\u63a5\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u5b9a\u4e49\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u3002"),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u63d0\u4f9b\u4e86\u4e24\u79cd\u65b9\u5f0f\u5904\u7406\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"respository.DbContext")," \uff1a\u5f53\u524d\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5bf9\u8c61\uff0c\u8fd4\u56de\u662f ",Object(o.b)("inlineCode",{parentName:"li"},"DbContext")," \u62bd\u8c61\u7c7b\u578b"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"respository.DynamicDbContext"),"\uff1a\u5f53\u524d\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5bf9\u8c61\uff0c\u8fd4\u56de\u7684\u662f ",Object(o.b)("inlineCode",{parentName:"li"},"dynamic")," \u7c7b\u578b")),Object(o.b)("p",null,"\u5982\u679c\u4f60\u53ea\u662f\u60f3\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"DbContext")," \u7684\u529f\u80fd\uff0c\u76f4\u63a5\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"respository.DbContext")," \u5373\u53ef\uff0c\u5982\uff1a"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"respository.DbContext.SaveChanges();\n")),Object(o.b)("p",null,"\u5982\u679c\u4f60\u60f3\u80fd\u591f\u83b7\u53d6\u5177\u4f53\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u7c7b\u578b\uff0c\u5982 ",Object(o.b)("inlineCode",{parentName:"p"},"MyDbContext"),"\uff0c\u90a3\u4e48\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"respository.DynamicDbContext")," \u5c31\u53ef\u4ee5\u83b7\u53d6\u5230\u5177\u4f53\u7684 ",Object(o.b)("inlineCode",{parentName:"p"},"MyDbContext")," \u7c7b\u578b\u3002\u5982\uff1a"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var persons = respository.DynamicDbContext.Persons.Find(1);\nvar users = respository.DynamicDbContext.Users;\n")),Object(o.b)("p",null,"\u8fd9\u6837\u5c31\u53ef\u4ee5\u76f4\u63a5\u64cd\u4f5c ",Object(o.b)("inlineCode",{parentName:"p"},"MyDbContext")," \u5b9a\u4e49\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u4e86\u3002"),Object(o.b)("h2",{id:"919-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.1.9 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))),Object(o.b)("hr",null),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(o.b)("inlineCode",{parentName:"p"},"\u6570\u636e\u5e93\u4e0a\u4e0b\u6587")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/ef/core/miscellaneous/configuring-dbcontext"}),"EF Core - \u914d\u7f6e DbContext")," \u7ae0\u8282\u3002"))))}l.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/404.html b/handbook/build/404.html index 5b024d62798..9b7c4d65886 100644 --- a/handbook/build/404.html +++ b/handbook/build/404.html @@ -4,16 +4,16 @@ -Page Not Found | Fur - - - +Page Not Found | Fur + + +
-

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

- - - +

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

+ + + \ No newline at end of file diff --git a/handbook/build/408ae89d.0e87c449.js b/handbook/build/408ae89d.0e87c449.js deleted file mode 100644 index 71eecbfb948..00000000000 --- a/handbook/build/408ae89d.0e87c449.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[25],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return p})),t.d(n,"b",(function(){return u}));var a=t(0),r=t.n(a);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function o(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var b=r.a.createContext({}),l=function(e){var n=r.a.useContext(b),t=n;return e&&(t="function"==typeof e?e(n):o(o({},n),e)),t},p=function(e){var n=l(e.components);return r.a.createElement(b.Provider,{value:n},e.children)},d={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},m=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,i=e.originalType,c=e.parentName,b=s(e,["components","mdxType","originalType","parentName"]),p=l(t),m=a,u=p["".concat(c,".").concat(m)]||p[m]||d[m]||i;return t?r.a.createElement(u,o(o({ref:n},b),{},{components:t})):r.a.createElement(u,o({ref:n},b))}));function u(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var i=t.length,c=new Array(i);c[0]=m;var o={};for(var s in n)hasOwnProperty.call(n,s)&&(o[s]=n[s]);o.originalType=e,o.mdxType="string"==typeof e?e:a,c[1]=o;for(var b=2;bSQL",id:"91221-\u521b\u5efa\u89c6\u56fe-sql",children:[]},{value:"9.12.2.2 \u89c6\u56fe\u6a21\u578b",id:"91222-\u89c6\u56fe\u6a21\u578b",children:[]}]},{value:"9.12.3 \u89c6\u56fe\u4f7f\u7528",id:"9123-\u89c6\u56fe\u4f7f\u7528",children:[]},{value:"9.12.4 \u89c6\u56fe\u6700\u4f73\u8bfb\u53d6\u65b9\u5f0f \u2714",id:"9124-\u89c6\u56fe\u6700\u4f73\u8bfb\u53d6\u65b9\u5f0f-",children:[]},{value:"9.12.5 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9125-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],b={rightToc:s};function l(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},b,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"9121-\u5173\u4e8e\u89c6\u56fe"},"9.12.1 \u5173\u4e8e\u89c6\u56fe"),Object(i.b)("p",null,"\u89c6\u56fe\u662f\u6570\u636e\u5e93\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u5bf9\u8c61\uff0c\u662f\u4e00\u5f20\u865a\u62df\u8868\uff0c\u901a\u8fc7\u89c6\u56fe\u6211\u4eec\u53ef\u4ee5\u5bf9\u7ed3\u679c\u8fdb\u884c\u7b5b\u9009\u7f13\u5b58\uff0c\u540c\u65f6\u8fd8\u80fd\u5b9e\u73b0\u9897\u7c92\u5316\u6743\u9650\u63a7\u5236\uff0c\u5982\u63a7\u5236\u6307\u5b9a\u884c\uff0c\u6307\u5b9a\u5217\u3002"),Object(i.b)("h2",{id:"9122-\u89c6\u56fe\u7684\u4f7f\u7528"},"9.12.2 \u89c6\u56fe\u7684\u4f7f\u7528"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u4e2d\u5b9e\u73b0\u89c6\u56fe\u7684\u64cd\u4f5c\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u521b\u5efa\u89c6\u56fe\u6a21\u578b\uff0c\u5e76\u7ee7\u627f ",Object(i.b)("inlineCode",{parentName:"p"},"EntityNotKey")," \u57fa\u7c7b\u5373\u53ef\u3002\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(i.b)("h3",{id:"91221-\u521b\u5efa\u89c6\u56fe-sql"},"9.12.2.1 \u521b\u5efa\u89c6\u56fe ",Object(i.b)("inlineCode",{parentName:"h3"},"SQL")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql"}),"CREATE VIEW V_Person AS\nSELECT Id,Name,Age,Address FROM person\n")),Object(i.b)("h3",{id:"91222-\u89c6\u56fe\u6a21\u578b"},"9.12.2.2 \u89c6\u56fe\u6a21\u578b"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,10}","{5,10}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Core\n{\n public class V_Person : EntityNotKey\n {\n /// \n /// \u914d\u7f6e\u89c6\u56fe\u540d\n /// \n public V_Person() : base("V_Person")\n {\n }\n\n /// \n /// \u4e3b\u952eId\n /// \n public int Id { get; set; }\n\n /// \n /// \u59d3\u540d\n /// \n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n\n /// \n /// \u4f4f\u5740\n /// \n public string Address { get; set; }\n }\n}\n')),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u89c6\u56fe\u540d\u79f0")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u89c6\u56fe\u5b9e\u4f53\u53ea\u9700\u8981\u7ee7\u627f ",Object(i.b)("inlineCode",{parentName:"p"},"EntityNotKey")," \u57fa\u7c7b\u5e76\u7f16\u5199\u65e0\u53c2\u6784\u9020\u51fd\u6570\u7ee7\u627f ",Object(i.b)("inlineCode",{parentName:"p"},'base("\u89c6\u56fe\u540d\u79f0")')," \u5373\u53ef\u3002"))),Object(i.b)("h2",{id:"9123-\u89c6\u56fe\u4f7f\u7528"},"9.12.3 \u89c6\u56fe\u4f7f\u7528"),Object(i.b)("p",null,"\u89c6\u56fe\u9664\u4e86\u4e0d\u80fd\u64cd\u4f5c\uff08\u5199\uff09\u4ee5\u5916\uff0c\u5176\u4ed6\u64cd\u4f5c\u548c\u8868\u64cd\u4f5c\u65e0\u5f02\u3002"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var vEntities = v_repository.Where(u => u.Id >10).ToList();\n")),Object(i.b)("h2",{id:"9124-\u89c6\u56fe\u6700\u4f73\u8bfb\u53d6\u65b9\u5f0f-"},"9.12.4 \u89c6\u56fe\u6700\u4f73\u8bfb\u53d6\u65b9\u5f0f \u2714"),Object(i.b)("p",null,"\u7531\u4e8e\u89c6\u56fe\u662f\u865a\u62df\u8868\uff0c\u4e0d\u5e94\u8be5\u5bf9\u5176\u8fdb\u884c\u5199\u64cd\u4f5c\uff0c\u6240\u4ee5\u5e94\u8be5\u91c7\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"\u53ea\u8bfb\u4ed3\u50a8\u521d\u59cb\u5316\u89c6\u56fe"),"\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{11,13,16}","{11,13,16}":!0}),"using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing Fur.DynamicApiController;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\n\nnamespace Fur.Application.Persons\n{\n public class FurService : IDynamicApiController\n {\n private readonly IReadableRepository _readableRepository;\n\n public FurService(IRepository repository)\n {\n // \u521d\u59cb\u5316\u53ea\u8bfb\u4ed3\u50a8\n _readableRepository = repository.Constraint>();\n }\n\n /// \n /// \u8bfb\u53d6\u89c6\u56fe\n /// \n /// \n public async Task> GetVPerson()\n {\n var list = await _readableRepository.AsAsyncEnumerable();\n return list;\n }\n }\n}\n")),Object(i.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},".Constraint")," \u65b9\u6cd5\u53ef\u4ee5\u5c06\u4ed3\u50a8\u7ea6\u675f\u4e3a\u7279\u5b9a\u4ed3\u50a8\uff0c\u5982\u53ea\u8bfb\u4ed3\u50a8\uff0c\u53ef\u8bfb\u53ef\u5199\u4ed3\u50a8\uff0c\u53ea\u65b0\u589e\u4ed3\u50a8\u7b49\u3002"))),Object(i.b)("h2",{id:"9125-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.12.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}l.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/408ae89d.fa344557.js b/handbook/build/408ae89d.fa344557.js new file mode 100644 index 00000000000..6dc6b06b31f --- /dev/null +++ b/handbook/build/408ae89d.fa344557.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[26],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return p})),t.d(n,"b",(function(){return u}));var a=t(0),r=t.n(a);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function o(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var b=r.a.createContext({}),l=function(e){var n=r.a.useContext(b),t=n;return e&&(t="function"==typeof e?e(n):o(o({},n),e)),t},p=function(e){var n=l(e.components);return r.a.createElement(b.Provider,{value:n},e.children)},d={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},m=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,i=e.originalType,c=e.parentName,b=s(e,["components","mdxType","originalType","parentName"]),p=l(t),m=a,u=p["".concat(c,".").concat(m)]||p[m]||d[m]||i;return t?r.a.createElement(u,o(o({ref:n},b),{},{components:t})):r.a.createElement(u,o({ref:n},b))}));function u(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var i=t.length,c=new Array(i);c[0]=m;var o={};for(var s in n)hasOwnProperty.call(n,s)&&(o[s]=n[s]);o.originalType=e,o.mdxType="string"==typeof e?e:a,c[1]=o;for(var b=2;bSQL",id:"91221-\u521b\u5efa\u89c6\u56fe-sql",children:[]},{value:"9.12.2.2 \u89c6\u56fe\u6a21\u578b",id:"91222-\u89c6\u56fe\u6a21\u578b",children:[]}]},{value:"9.12.3 \u89c6\u56fe\u4f7f\u7528",id:"9123-\u89c6\u56fe\u4f7f\u7528",children:[]},{value:"9.12.4 \u89c6\u56fe\u6700\u4f73\u8bfb\u53d6\u65b9\u5f0f \u2714",id:"9124-\u89c6\u56fe\u6700\u4f73\u8bfb\u53d6\u65b9\u5f0f-",children:[]},{value:"9.12.5 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9125-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],b={rightToc:s};function l(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},b,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"9121-\u5173\u4e8e\u89c6\u56fe"},"9.12.1 \u5173\u4e8e\u89c6\u56fe"),Object(i.b)("p",null,"\u89c6\u56fe\u662f\u6570\u636e\u5e93\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u5bf9\u8c61\uff0c\u662f\u4e00\u5f20\u865a\u62df\u8868\uff0c\u901a\u8fc7\u89c6\u56fe\u6211\u4eec\u53ef\u4ee5\u5bf9\u7ed3\u679c\u8fdb\u884c\u7b5b\u9009\u7f13\u5b58\uff0c\u540c\u65f6\u8fd8\u80fd\u5b9e\u73b0\u9897\u7c92\u5316\u6743\u9650\u63a7\u5236\uff0c\u5982\u63a7\u5236\u6307\u5b9a\u884c\uff0c\u6307\u5b9a\u5217\u3002"),Object(i.b)("h2",{id:"9122-\u89c6\u56fe\u7684\u4f7f\u7528"},"9.12.2 \u89c6\u56fe\u7684\u4f7f\u7528"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u4e2d\u5b9e\u73b0\u89c6\u56fe\u7684\u64cd\u4f5c\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u521b\u5efa\u89c6\u56fe\u6a21\u578b\uff0c\u5e76\u7ee7\u627f ",Object(i.b)("inlineCode",{parentName:"p"},"EntityNotKey")," \u57fa\u7c7b\u5373\u53ef\u3002\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(i.b)("h3",{id:"91221-\u521b\u5efa\u89c6\u56fe-sql"},"9.12.2.1 \u521b\u5efa\u89c6\u56fe ",Object(i.b)("inlineCode",{parentName:"h3"},"SQL")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql"}),"CREATE VIEW V_Person AS\nSELECT Id,Name,Age,Address FROM person\n")),Object(i.b)("h3",{id:"91222-\u89c6\u56fe\u6a21\u578b"},"9.12.2.2 \u89c6\u56fe\u6a21\u578b"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,10}","{5,10}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Core\n{\n public class V_Person : EntityNotKey\n {\n /// \n /// \u914d\u7f6e\u89c6\u56fe\u540d\n /// \n public V_Person() : base("V_Person")\n {\n }\n\n /// \n /// \u4e3b\u952eId\n /// \n public int Id { get; set; }\n\n /// \n /// \u59d3\u540d\n /// \n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n\n /// \n /// \u4f4f\u5740\n /// \n public string Address { get; set; }\n }\n}\n')),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u89c6\u56fe\u540d\u79f0")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u89c6\u56fe\u5b9e\u4f53\u53ea\u9700\u8981\u7ee7\u627f ",Object(i.b)("inlineCode",{parentName:"p"},"EntityNotKey")," \u57fa\u7c7b\u5e76\u7f16\u5199\u65e0\u53c2\u6784\u9020\u51fd\u6570\u7ee7\u627f ",Object(i.b)("inlineCode",{parentName:"p"},'base("\u89c6\u56fe\u540d\u79f0")')," \u5373\u53ef\u3002"))),Object(i.b)("h2",{id:"9123-\u89c6\u56fe\u4f7f\u7528"},"9.12.3 \u89c6\u56fe\u4f7f\u7528"),Object(i.b)("p",null,"\u89c6\u56fe\u9664\u4e86\u4e0d\u80fd\u64cd\u4f5c\uff08\u5199\uff09\u4ee5\u5916\uff0c\u5176\u4ed6\u64cd\u4f5c\u548c\u8868\u64cd\u4f5c\u65e0\u5f02\u3002"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var vEntities = v_repository.Where(u => u.Id >10).ToList();\n")),Object(i.b)("h2",{id:"9124-\u89c6\u56fe\u6700\u4f73\u8bfb\u53d6\u65b9\u5f0f-"},"9.12.4 \u89c6\u56fe\u6700\u4f73\u8bfb\u53d6\u65b9\u5f0f \u2714"),Object(i.b)("p",null,"\u7531\u4e8e\u89c6\u56fe\u662f\u865a\u62df\u8868\uff0c\u4e0d\u5e94\u8be5\u5bf9\u5176\u8fdb\u884c\u5199\u64cd\u4f5c\uff0c\u6240\u4ee5\u5e94\u8be5\u91c7\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"\u53ea\u8bfb\u4ed3\u50a8\u521d\u59cb\u5316\u89c6\u56fe"),"\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{11,13,16}","{11,13,16}":!0}),"using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing Fur.DynamicApiController;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\n\nnamespace Fur.Application.Persons\n{\n public class FurService : IDynamicApiController\n {\n private readonly IReadableRepository _readableRepository;\n\n public FurService(IRepository repository)\n {\n // \u521d\u59cb\u5316\u53ea\u8bfb\u4ed3\u50a8\n _readableRepository = repository.Constraint>();\n }\n\n /// \n /// \u8bfb\u53d6\u89c6\u56fe\n /// \n /// \n public async Task> GetVPerson()\n {\n var list = await _readableRepository.AsAsyncEnumerable();\n return list;\n }\n }\n}\n")),Object(i.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},".Constraint")," \u65b9\u6cd5\u53ef\u4ee5\u5c06\u4ed3\u50a8\u7ea6\u675f\u4e3a\u7279\u5b9a\u4ed3\u50a8\uff0c\u5982\u53ea\u8bfb\u4ed3\u50a8\uff0c\u53ef\u8bfb\u53ef\u5199\u4ed3\u50a8\uff0c\u53ea\u65b0\u589e\u4ed3\u50a8\u7b49\u3002"))),Object(i.b)("h2",{id:"9125-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.12.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}l.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/409819e6.14b77875.js b/handbook/build/409819e6.14b77875.js new file mode 100644 index 00000000000..3c7ec8dfeb5 --- /dev/null +++ b/handbook/build/409819e6.14b77875.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[27],{83:function(n){n.exports=JSON.parse('{"allTagsPath":"/fur/blog/tags","slug":"net-5","name":".net5","count":1,"permalink":"/fur/blog/tags/net-5"}')}}]); \ No newline at end of file diff --git a/handbook/build/4930ce4d.867af8f3.js b/handbook/build/4930ce4d.867af8f3.js new file mode 100644 index 00000000000..38af6b6bef1 --- /dev/null +++ b/handbook/build/4930ce4d.867af8f3.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[28],{142:function(e,t,n){"use strict";n.d(t,"a",(function(){return b})),n.d(t,"b",(function(){return m}));var r=n(0),a=n.n(r);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var l=a.a.createContext({}),p=function(e){var t=a.a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},b=function(e){var t=p(e.components);return a.a.createElement(l.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},u=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,o=e.parentName,l=s(e,["components","mdxType","originalType","parentName"]),b=p(n),u=r,m=b["".concat(o,".").concat(u)]||b[u]||d[u]||i;return n?a.a.createElement(m,c(c({ref:t},l),{},{components:n})):a.a.createElement(m,c({ref:t},l))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,o=new Array(i);o[0]=u;var c={};for(var s in t)hasOwnProperty.call(t,s)&&(c[s]=t[s]);c.originalType=e,c.mdxType="string"==typeof e?e:r,o[1]=c;for(var l=2;l")," \u63a5\u53e3\u5e76\u5b9e\u73b0\u5373\u53ef\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{8,24}","{8,24}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\n\nnamespace Fur.Core\n{\n public class Person : Entity, IEntityTypeBuilder\n {\n public Person()\n {\n CreatedTime = DateTime.Now;\n IsDeleted = false;\n }\n\n public string Name { get; set; }\n\n public int Age { get; set; }\n\n public string Address { get; set; }\n\n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasQueryFilter(u => !u.IsDeleted);\n }\n }\n}\n")),Object(i.b)("h3",{id:"92322-\u5168\u5c40\u7b5b\u9009\u5668"},"9.23.2.2 \u5168\u5c40\u7b5b\u9009\u5668"),Object(i.b)("p",null,"\u5168\u5c40\u7b5b\u9009\u5668\u53ef\u4ee5\u914d\u7f6e\u6240\u6709\u5b9e\u4f53\u5e94\u7528\u7b5b\u9009\u5668\u4e2d\uff0c\u65e0\u9700\u4e00\u4e2a\u4e00\u4e2a\u53bb\u914d\u7f6e\u3002\u4f7f\u7528\u65b9\u6cd5\u7a0d\u5fae\u6709\u4e9b\u590d\u6742\uff0c\u9700\u8981\u52a8\u6001\u6784\u5efa ",Object(i.b)("inlineCode",{parentName:"p"},"Lambda")," \u8868\u8fbe\u5f0f\u3002"),Object(i.b)("p",null,"\u5b9e\u73b0\u5168\u5c40\u7b5b\u9009\u5668\u4f9d\u8d56\u4e8e ",Object(i.b)("inlineCode",{parentName:"p"},"IModelBuilderFilter")," \u63a5\u53e3\uff0c\u8be5\u63a5\u53e3\u63d0\u4f9b\u4e24\u4e2a\u65b9\u6cd5\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"OnCreating"),"\uff1a\u5b9e\u4f53\u6784\u5efa\u4e4b\u524d"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"OnCreated"),"\uff1a\u5b9e\u4f53\u6784\u5efa\u4e4b\u540e")),Object(i.b)("p",null,"\u901a\u8fc7\u5b9e\u73b0\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u5373\u53ef\u914d\u7f6e\u5168\u5c40\u8fc7\u6ee4\u5668\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{10,18-19,21,24}","{10,18-19,21,24}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Linq.Expressions;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class FurDbContext : AppDbContext, IModelBuilderFilter\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n public void OnCreated(ModelBuilder modelBuilder, EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n var expression = BuilderIsDeleteLambdaExpression(entityBuilder);\n if (expression == null) return;\n\n entityBuilder.HasQueryFilter(expression);\n }\n\n public void OnCreating(ModelBuilder modelBuilder, EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n }\n\n /// \n /// \u6784\u5efa u => EF.Property(u, "IsDeleted") == false \u8868\u8fbe\u5f0f\n /// \n /// \n /// \n private LambdaExpression BuilderIsDeleteLambdaExpression(EntityTypeBuilder entityBuilder)\n {\n // \u83b7\u53d6\u5b9e\u4f53\u6784\u5efa\u5668\u5143\u6570\u636e\n var metadata = entityBuilder.Metadata;\n if (metadata.FindProperty(nameof(Entity.IsDeleted)) == null) return default;\n\n // \u521b\u5efa\u8868\u8fbe\u5f0f\u5143\u7d20\n var parameter = Expression.Parameter(metadata.ClrType, "u");\n var properyName = Expression.Constant(nameof(Entity.IsDeleted));\n var propertyValue = Expression.Constant(false);\n\n // \u6784\u5efa\u8868\u8fbe\u5f0f u => EF.Property(u, "IsDeleted") == false\n var expressionBody = Expression.Equal(Expression.Call(typeof(EF), nameof(EF.Property), new[] { typeof(bool) }, parameter, properyName), propertyValue);\n var expression = Expression.Lambda(expressionBody, parameter);\n return expression;\n }\n }\n}\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5c0f\u5efa\u8bae")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u5982\u679c\u5bf9\u52a8\u6001\u6784\u5efa ",Object(i.b)("inlineCode",{parentName:"p"},"LambdaExpression")," \u4e0d\u719f\u6089\u7684\u670b\u53cb\uff0c\u53ef\u4ee5\u4f7f\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"System.Linq.Dynamic.Core")," \u5305 ",Object(i.b)("a",Object(r.a)({parentName:"p"},{href:"https://github.com/zzzprojects/System.Linq.Dynamic.Core"}),"https://github.com/zzzprojects/System.Linq.Dynamic.Core")))),Object(i.b)("h2",{id:"9233-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.23.3 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(r.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/4930ce4d.e8539812.js b/handbook/build/4930ce4d.e8539812.js deleted file mode 100644 index 4404669f30c..00000000000 --- a/handbook/build/4930ce4d.e8539812.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[26],{142:function(e,t,n){"use strict";n.d(t,"a",(function(){return b})),n.d(t,"b",(function(){return m}));var r=n(0),a=n.n(r);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var l=a.a.createContext({}),p=function(e){var t=a.a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},b=function(e){var t=p(e.components);return a.a.createElement(l.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},u=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,o=e.parentName,l=s(e,["components","mdxType","originalType","parentName"]),b=p(n),u=r,m=b["".concat(o,".").concat(u)]||b[u]||d[u]||i;return n?a.a.createElement(m,c(c({ref:t},l),{},{components:n})):a.a.createElement(m,c({ref:t},l))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,o=new Array(i);o[0]=u;var c={};for(var s in t)hasOwnProperty.call(t,s)&&(c[s]=t[s]);c.originalType=e,c.mdxType="string"==typeof e?e:r,o[1]=c;for(var l=2;l")," \u63a5\u53e3\u5e76\u5b9e\u73b0\u5373\u53ef\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{8,24}","{8,24}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\n\nnamespace Fur.Core\n{\n public class Person : Entity, IEntityTypeBuilder\n {\n public Person()\n {\n CreatedTime = DateTime.Now;\n IsDeleted = false;\n }\n\n public string Name { get; set; }\n\n public int Age { get; set; }\n\n public string Address { get; set; }\n\n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasQueryFilter(u => !u.IsDeleted);\n }\n }\n}\n")),Object(i.b)("h3",{id:"92322-\u5168\u5c40\u7b5b\u9009\u5668"},"9.23.2.2 \u5168\u5c40\u7b5b\u9009\u5668"),Object(i.b)("p",null,"\u5168\u5c40\u7b5b\u9009\u5668\u53ef\u4ee5\u914d\u7f6e\u6240\u6709\u5b9e\u4f53\u5e94\u7528\u7b5b\u9009\u5668\u4e2d\uff0c\u65e0\u9700\u4e00\u4e2a\u4e00\u4e2a\u53bb\u914d\u7f6e\u3002\u4f7f\u7528\u65b9\u6cd5\u7a0d\u5fae\u6709\u4e9b\u590d\u6742\uff0c\u9700\u8981\u52a8\u6001\u6784\u5efa ",Object(i.b)("inlineCode",{parentName:"p"},"Lambda")," \u8868\u8fbe\u5f0f\u3002"),Object(i.b)("p",null,"\u5b9e\u73b0\u5168\u5c40\u7b5b\u9009\u5668\u4f9d\u8d56\u4e8e ",Object(i.b)("inlineCode",{parentName:"p"},"IModelBuilderFilter")," \u63a5\u53e3\uff0c\u8be5\u63a5\u53e3\u63d0\u4f9b\u4e24\u4e2a\u65b9\u6cd5\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"OnCreating"),"\uff1a\u5b9e\u4f53\u6784\u5efa\u4e4b\u524d"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"OnCreated"),"\uff1a\u5b9e\u4f53\u6784\u5efa\u4e4b\u540e")),Object(i.b)("p",null,"\u901a\u8fc7\u5b9e\u73b0\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u5373\u53ef\u914d\u7f6e\u5168\u5c40\u8fc7\u6ee4\u5668\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{10,18-19,21,24}","{10,18-19,21,24}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Linq.Expressions;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class FurDbContext : AppDbContext, IModelBuilderFilter\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n public void OnCreated(ModelBuilder modelBuilder, EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n var expression = BuilderIsDeleteLambdaExpression(entityBuilder);\n if (expression == null) return;\n\n entityBuilder.HasQueryFilter(expression);\n }\n\n public void OnCreating(ModelBuilder modelBuilder, EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n }\n\n /// \n /// \u6784\u5efa u => EF.Property(u, "IsDeleted") == false \u8868\u8fbe\u5f0f\n /// \n /// \n /// \n private LambdaExpression BuilderIsDeleteLambdaExpression(EntityTypeBuilder entityBuilder)\n {\n // \u83b7\u53d6\u5b9e\u4f53\u6784\u5efa\u5668\u5143\u6570\u636e\n var metadata = entityBuilder.Metadata;\n if (metadata.FindProperty(nameof(Entity.IsDeleted)) == null) return default;\n\n // \u521b\u5efa\u8868\u8fbe\u5f0f\u5143\u7d20\n var parameter = Expression.Parameter(metadata.ClrType, "u");\n var properyName = Expression.Constant(nameof(Entity.IsDeleted));\n var propertyValue = Expression.Constant(false);\n\n // \u6784\u5efa\u8868\u8fbe\u5f0f u => EF.Property(u, "IsDeleted") == false\n var expressionBody = Expression.Equal(Expression.Call(typeof(EF), nameof(EF.Property), new[] { typeof(bool) }, parameter, properyName), propertyValue);\n var expression = Expression.Lambda(expressionBody, parameter);\n return expression;\n }\n }\n}\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5c0f\u5efa\u8bae")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u5982\u679c\u5bf9\u52a8\u6001\u6784\u5efa ",Object(i.b)("inlineCode",{parentName:"p"},"LambdaExpression")," \u4e0d\u719f\u6089\u7684\u670b\u53cb\uff0c\u53ef\u4ee5\u4f7f\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"System.Linq.Dynamic.Core")," \u5305 ",Object(i.b)("a",Object(r.a)({parentName:"p"},{href:"https://github.com/zzzprojects/System.Linq.Dynamic.Core"}),"https://github.com/zzzprojects/System.Linq.Dynamic.Core")))),Object(i.b)("h2",{id:"9233-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.23.3 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(r.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/4bfcf3ee.09b86c5e.js b/handbook/build/4bfcf3ee.09b86c5e.js new file mode 100644 index 00000000000..53e0ea5d21f --- /dev/null +++ b/handbook/build/4bfcf3ee.09b86c5e.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[29],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return b})),t.d(n,"b",(function(){return p}));var a=t(0),r=t.n(a);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function s(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var l=r.a.createContext({}),u=function(e){var n=r.a.useContext(l),t=n;return e&&(t="function"==typeof e?e(n):s(s({},n),e)),t},b=function(e){var n=u(e.components);return r.a.createElement(l.Provider,{value:n},e.children)},m={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},d=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,i=e.originalType,o=e.parentName,l=c(e,["components","mdxType","originalType","parentName"]),b=u(t),d=a,p=b["".concat(o,".").concat(d)]||b[d]||m[d]||i;return t?r.a.createElement(p,s(s({ref:n},l),{},{components:t})):r.a.createElement(p,s({ref:n},l))}));function p(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var i=t.length,o=new Array(i);o[0]=d;var s={};for(var c in n)hasOwnProperty.call(n,c)&&(s[c]=n[c]);s.originalType=e,s.mdxType="string"==typeof e?e:a,o[1]=s;for(var l=2;lInner Join",id:"91151-\u5185\u8fde\u63a5-inner-join",children:[]},{value:"9.11.5.2 \u5de6\u8fde\u63a5 Left Join",id:"91152-\u5de6\u8fde\u63a5-left-join",children:[]},{value:"9.11.5.2 \u53f3\u8fde\u63a5 Right Join",id:"91152-\u53f3\u8fde\u63a5-right-join",children:[]}]},{value:"9.11.6 \u5206\u7ec4\u67e5\u8be2",id:"9116-\u5206\u7ec4\u67e5\u8be2",children:[]},{value:"9.11.7 \u5408\u5e76\u7ed3\u679c\u96c6",id:"9117-\u5408\u5e76\u7ed3\u679c\u96c6",children:[]},{value:"9.11.8 \u67e5\u8be2\u6392\u5e8f",id:"9118-\u67e5\u8be2\u6392\u5e8f",children:[{value:"9.11.8.1 \u6b63\u5e8f",id:"91181-\u6b63\u5e8f",children:[]},{value:"9.11.8.2 \u5012\u5e8f",id:"91182-\u5012\u5e8f",children:[]},{value:"9.11.8.3 \u6df7\u5408\u5012\u5e8f",id:"91183-\u6df7\u5408\u5012\u5e8f",children:[]}]},{value:"9.11.9 \u9012\u5f52\u67e5\u8be2",id:"9119-\u9012\u5f52\u67e5\u8be2",children:[]},{value:"9.11.10 \u52a8\u6001 Sql \u67e5\u8be2",id:"91110-\u52a8\u6001-sql-\u67e5\u8be2",children:[{value:"9.11.10.1 \u52a8\u6001 Sql",id:"911101-\u52a8\u6001-sql",children:[]},{value:"9.11.10.2 \u52a8\u6001 Lambda",id:"911102-\u52a8\u6001-lambda",children:[]}]},{value:"9.11.11 \u6027\u80fd\u4f18\u5316",id:"91111-\u6027\u80fd\u4f18\u5316",children:[]},{value:"9.11.12 \u5206\u8868\u67e5\u8be2\u5c0f\u4f8b\u5b50",id:"91112-\u5206\u8868\u67e5\u8be2\u5c0f\u4f8b\u5b50",children:[]},{value:"9.11.12 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"91112-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],b={rightToc:u};function m(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},b,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"9111-\u5173\u8054\u6570\u636e\u6a21\u578b"},"9.11.1 \u5173\u8054\u6570\u636e\u6a21\u578b"),Object(i.b)(o.a,{defaultValue:"person",values:[{label:"Person",value:"person"},{label:"PersonDetail",value:"person-detail"},{label:"Children",value:"children"},{label:"Post",value:"post"}],mdxType:"Tabs"},Object(i.b)(s.a,{value:"person",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{38,43,48}","{38,43,48}":!0}),"using Fur.DatabaseAccessor;\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Core\n{\n public class Person : Entity\n {\n /// \n /// \u6784\u9020\u51fd\u6570\n /// \n public Person()\n {\n CreatedTime = DateTime.Now;\n IsDeleted = false;\n }\n\n /// \n /// \u59d3\u540d\n /// \n [MaxLength(32)]\n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n\n /// \n /// \u4f4f\u5740\n /// \n public string Address { get; set; }\n\n /// \n /// \u4ece\u8868\n /// \n public PersonDetail PersonDetail { get; set; }\n\n /// \n /// \u4e00\u5bf9\u591a\n /// \n public ICollection Childrens { get; set; }\n\n /// \n /// \u591a\u5bf9\u591a\n /// \n public ICollection Posts { get; set; }\n }\n}\n"))),Object(i.b)(s.a,{value:"person-detail",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{25}","{25}":!0}),"using Fur.DatabaseAccessor;\n\nnamespace Fur.Core\n{\n public class PersonDetail : EntityBase\n {\n /// \n /// \u7535\u8bdd\u53f7\u7801\n /// \n public string PhoneNumber { get; set; }\n\n /// \n /// QQ \u53f7\u7801\n /// \n public string QQ { get; set; }\n\n /// \n /// \u5916\u952e\n /// \n public int PersonId { get; set; }\n\n /// \n /// \u4e3b\u8868\n /// \n public Person Person { get; set; }\n }\n}\n"))),Object(i.b)(s.a,{value:"children",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{35}","{35}":!0}),"using Fur.DatabaseAccessor;\nusing System;\n\nnamespace Fur.Core\n{\n public class Children : Entity\n {\n /// \n /// \u6784\u9020\u51fd\u6570\n /// \n public Children()\n {\n CreatedTime = DateTime.Now;\n IsDeleted = false;\n }\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n\n /// \n /// \u6027\u522b\n /// \n public Gender Gender { get; set; }\n\n /// \n /// \u5916\u952e\n /// \n public int PersonId { get; set; }\n\n /// \n /// \u4e3b\u8868\n /// \n public Person Person { get; set; }\n }\n}\n"))),Object(i.b)(s.a,{value:"post",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{26}","{26}":!0}),"using Fur.DatabaseAccessor;\nusing System;\nusing System.Collections.Generic;\n\nnamespace Fur.Core\n{\n public class Post : Entity\n {\n /// \n /// \u6784\u9020\u51fd\u6570\n /// \n public Post()\n {\n CreatedTime = DateTime.Now;\n IsDeleted = false;\n }\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n\n /// \n /// Person \u96c6\u5408\n /// \n public ICollection Persons { get; set; }\n }\n}\n")))),Object(i.b)("h2",{id:"9112-\u4e00\u5bf9\u4e00\u67e5\u8be2"},"9.11.2 \u4e00\u5bf9\u4e00\u67e5\u8be2"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u793a\u4f8b\u4e00\nvar person = repository.Include(u => u.Detail);\n\n// \u793a\u4f8b\u4e8c\nvar person = repository.Include(u => u.Detail)\n .Include(u => u.Post);\n\n// \u793a\u4f8b\u4e09\nvar person = repository.Include(u => u.Detail)\n .ThenInclude(d => d.Review)\n .Include(u => u.Post);\n\n// \u793a\u4f8b\u56db\nvar person = repository.Include(u => u.Detail.Where(d => d.Id > 10).OrderBy(d => d.Name))\n .ThenInclude(d => d.Review)\n .Include(u => u.Post);\n\n// \u793a\u4f8b\u4e94\nvar person = repository.IncludeIf(!string.IsNullOrEmpty(keyword), u => u.Detail);\n\n// \u793a\u4f8b\u516d\nvar person = repository.IncludeIf(!string.IsNullOrEmpty(keyword), u => u.Detail)\n .IncludeIf(age > 18), u => u.Detail.Where(d => d.Id > 10).OrderBy(d => d.Name))\n .ThenInclude(d => d.Review)\n .Include(u => u.Post);\n")),Object(i.b)("h2",{id:"9113-\u4e00\u5bf9\u591a\u67e5\u8be2"},"9.11.3 \u4e00\u5bf9\u591a\u67e5\u8be2"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u793a\u4f8b\u4e00\nvar person = repository.Include(u => u.Childrens);\n\n// \u53c2\u8003 \u4e00\u5bf9\u4e00 \u4f8b\u5b50\n")),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u8bf4\u660e")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"\u4e00\u5bf9\u4e00")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"\u4e00\u5bf9\u591a")," \u67e5\u8be2\u65b9\u6cd5\u4e00\u6837\uff0c\u552f\u4e00\u7684\u533a\u522b\u662f\uff1a",Object(i.b)("inlineCode",{parentName:"p"},"\u4e00\u5bf9\u591a")," \u91c7\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"ICollection")," \u5b9a\u4e49\u5c5e\u6027\u3002"))),Object(i.b)("h2",{id:"9114-\u591a\u5bf9\u591a\u67e5\u8be2"},"9.11.4 \u591a\u5bf9\u591a\u67e5\u8be2"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u793a\u4f8b\u4e00\nvar person = repository.Include(u => u.Posts);\n\n// \u53c2\u8003 \u4e00\u5bf9\u4e00 \u4f8b\u5b50\n")),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u8bf4\u660e")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"\u4e00\u5bf9\u4e00")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"\u591a\u5bf9\u591a")," \u67e5\u8be2\u65b9\u6cd5\u4e00\u6837\uff0c\u552f\u4e00\u7684\u533a\u522b\u662f\uff1a",Object(i.b)("inlineCode",{parentName:"p"},"\u591a\u5bf9\u591a")," \u91c7\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"ICollection")," \u5b9a\u4e49\u5c5e\u6027\u3002"))),Object(i.b)("h2",{id:"9115-\u8054\u8868\u67e5\u8be2"},"9.11.5 \u8054\u8868\u67e5\u8be2"),Object(i.b)("h3",{id:"91151-\u5185\u8fde\u63a5-inner-join"},"9.11.5.1 \u5185\u8fde\u63a5 ",Object(i.b)("inlineCode",{parentName:"h3"},"Inner Join")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var query = from p in _personRepository.AsQueryable()\n join d in _personDetailRepository.AsQueryable() on p.Id equals d.PersonId\n select new PersonDto\n {\n PhoneNumber = p.PersonDetail.PhoneNumber,\n Address = p.Address,\n Age = p.Age,\n Name = p.Name,\n Id = p.Id,\n QQ = p.PersonDetail.QQ\n };\n")),Object(i.b)("h3",{id:"91152-\u5de6\u8fde\u63a5-left-join"},"9.11.5.2 \u5de6\u8fde\u63a5 ",Object(i.b)("inlineCode",{parentName:"h3"},"Left Join")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,3}","{2,3}":!0}),"var query = from p in _personRepository.AsQueryable()\n join d in _personDetailRepository.AsQueryable() on p.Id equals d.PersonId into results\n from d in results.DefaultIfEmpty()\n select new PersonDto\n {\n PhoneNumber = p.PersonDetail.PhoneNumber,\n Address = p.Address,\n Age = p.Age,\n Name = p.Name,\n Id = p.Id,\n QQ = p.PersonDetail.QQ\n };\n")),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5c0f\u63d0\u793a")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("strong",{parentName:"p"},Object(i.b)("inlineCode",{parentName:"strong"},"Left Join"))," \u548c ",Object(i.b)("strong",{parentName:"p"},Object(i.b)("inlineCode",{parentName:"strong"},"Inner Join"))," \u4e0d\u540c\u7684\u662f\uff0c",Object(i.b)("strong",{parentName:"p"},Object(i.b)("inlineCode",{parentName:"strong"},"Left Join"))," \u4f1a\u5148\u5c06\u7ed3\u679c ",Object(i.b)("strong",{parentName:"p"},Object(i.b)("inlineCode",{parentName:"strong"},"into"))," \u5230\u65b0\u7684\u7ed3\u679c\u96c6\u7136\u540e\u518d\u67e5\u8be2\uff0c\u5e76\u8c03\u7528 ",Object(i.b)("strong",{parentName:"p"},Object(i.b)("inlineCode",{parentName:"strong"},"DefaultIfEmpty()"))," \u65b9\u6cd5\u3002"))),Object(i.b)("h3",{id:"91152-\u53f3\u8fde\u63a5-right-join"},"9.11.5.2 \u53f3\u8fde\u63a5 ",Object(i.b)("inlineCode",{parentName:"h3"},"Right Join")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Right Join")," \u53ea\u9700\u8981\u5c06 ",Object(i.b)("inlineCode",{parentName:"p"},"Left Join")," \u4e3b\u4ece\u8868\u4f4d\u7f6e\u66f4\u6362\u5373\u53ef\u3002"),Object(i.b)("h2",{id:"9116-\u5206\u7ec4\u67e5\u8be2"},"9.11.6 \u5206\u7ec4\u67e5\u8be2"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u793a\u4f8b\u4e00\nvar query = repository.AsQueryable().GroupBy(x => new { x.Column1, x.Column2 });\n\n// \u793a\u4f8b\u4e8c\nvar query = from student in repository.AsQueryable()\n group student by repository2.AsQueryable() into dateGroup\n select new ResultData()\n {\n Key = dateGroup.Key,\n Value = dateGroup.Count()\n };\n\n// \u793a\u4f8b\u4e09\nvar query = from a in repository.AsQueryable()\n join b in repository2.AsQueryable() on a.Id equals b.Aid\n join c in repository3.AsQueryable() on c.id equals b.Bid\n group emp by new { emp.Age, emp.Sex } into g\n select new {\n Peo = g.Key,\n Count = g.Count()\n };\n")),Object(i.b)("h2",{id:"9117-\u5408\u5e76\u7ed3\u679c\u96c6"},"9.11.7 \u5408\u5e76\u7ed3\u679c\u96c6"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var query = repository.AsQueryable(u => u.Id > 10)\n .Union(\n repository2.AsQueryable(u => u.Id <= 10)\n );\n")),Object(i.b)("h2",{id:"9118-\u67e5\u8be2\u6392\u5e8f"},"9.11.8 \u67e5\u8be2\u6392\u5e8f"),Object(i.b)("h3",{id:"91181-\u6b63\u5e8f"},"9.11.8.1 \u6b63\u5e8f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u793a\u4f8b\u4e00\nvar query = repository.AsQueryable()\n .OrderBy(u => u.Id);\n\n// \u793a\u4f8b\u4e8c\nvar query =repository.AsQueryable()\n .OrderBy(u => u.Id)\n .ThenBy(u => u.Name);\n")),Object(i.b)("h3",{id:"91182-\u5012\u5e8f"},"9.11.8.2 \u5012\u5e8f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u793a\u4f8b\u4e00\nvar query = repository.AsQueryable()\n .OrderByDescending(u => u.Id);\n\n// \u793a\u4f8b\u4e8c\nvar query =repository.AsQueryable()\n .OrderByDescending(u => u.Id)\n .ThenByDescending(u => u.Name);\n")),Object(i.b)("h3",{id:"91183-\u6df7\u5408\u5012\u5e8f"},"9.11.8.3 \u6df7\u5408\u5012\u5e8f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u793a\u4f8b\u4e00\nvar query = repository.AsQueryable()\n .OrderBy(u => u.Id)\n .OrderByDescending(u => u.Name)\n .ThenBy(u => u.Age);\n")),Object(i.b)("h2",{id:"9119-\u9012\u5f52\u67e5\u8be2"},"9.11.9 \u9012\u5f52\u67e5\u8be2"),Object(i.b)(o.a,{defaultValue:"city",values:[{label:"City",value:"city"},{label:"CityDto",value:"citydto"}],mdxType:"Tabs"},Object(i.b)(s.a,{value:"city",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{12,36,41,49-55}","{12,36,41,49-55}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Collections.Generic;\n\nnamespace Fur.Core\n{\n /// \n /// \u57ce\u5e02\n /// \n public class City : Entity, IEntityTypeBuilder, IEntitySeedData\n {\n /// \n /// \u6784\u9020\u51fd\u6570\n /// \n public City()\n {\n CreatedTime = DateTime.Now;\n IsDeleted = false;\n }\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n\n /// \n /// \u4e0a\u7ea7Id\n /// \n public int? ParentId { get; set; }\n\n /// \n /// \u4e0a\u7ea7\n /// \n public virtual City Parent { get; set; }\n\n /// \n /// \u5b50\u96c6\n /// \n public virtual ICollection Childrens { get; set; }\n\n /// \n /// \u914d\u7f6e\u5b9e\u4f53\u5173\u7cfb\n /// \n /// \n /// \n /// \n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder\n .HasMany(x => x.Childrens)\n .WithOne(x => x.Parent)\n .HasForeignKey(x => x.ParentId)\n .OnDelete(DeleteBehavior.ClientSetNull); // \u5fc5\u987b\u8bbe\u7f6e\u8fd9\u4e00\u884c\n }\n\n /// \n /// \u79cd\u5b50\u6570\u636e\n /// \n /// \n /// \n /// \n public IEnumerable HasData(DbContext dbContext, Type dbContextLocator)\n {\n return new List\n {\n new City { Id=1,CreatedTime =DateTime.Parse("2020-08-20 15:30:20"),IsDeleted=false,Name="\u4e2d\u56fd" },\n new City { Id=2,CreatedTime =DateTime.Parse("2020-08-20 15:30:20"),IsDeleted=false,Name="\u5e7f\u4e1c\u7701",ParentId=1 },\n new City { Id=3,CreatedTime =DateTime.Parse("2020-08-20 15:30:20"),IsDeleted=false,Name="\u4e2d\u5c71\u5e02",ParentId=2 },\n new City { Id=4,CreatedTime =DateTime.Parse("2020-08-20 15:30:20"),IsDeleted=false,Name="\u73e0\u6d77\u5e02",ParentId=2 },\n new City { Id=5,CreatedTime =DateTime.Parse("2020-08-20 15:30:20"),IsDeleted=false,Name="\u6d59\u6c5f\u7701",ParentId=1 },\n };\n }\n }\n}\n'))),Object(i.b)(s.a,{value:"citydto",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"using System.Collections.Generic;\n\nnamespace Fur.Application.Persons\n{\n public class CityDto\n {\n /// \n /// \u9010\u6e10\n /// \n public int Id { get; set; }\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n\n /// \n /// \u5b50\u96c6\n /// \n public ICollection Childrens { get; set; }\n }\n}\n")))),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var cities = await repository.AsQueryable()\n .Include(u => u.Childrens)\n .Where(u => u.Id == 1)\n .ToListAsync();\n\nvar dtos = cities.Adapt>();\n")),Object(i.b)("h2",{id:"91110-\u52a8\u6001-sql-\u67e5\u8be2"},"9.11.10 \u52a8\u6001 ",Object(i.b)("inlineCode",{parentName:"h2"},"Sql")," \u67e5\u8be2"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u9ed8\u8ba4\u4e0d\u652f\u6301 \u52a8\u6001 ",Object(i.b)("inlineCode",{parentName:"p"},"Sql")," \u67e5\u8be2\u529f\u80fd\uff0c\u4e0d\u8fc7\u53ef\u4ee5\u901a\u8fc7\u7b2c\u4e09\u65b9\u5b9e\u73b0\uff1a"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u9879\u76ee\u5c42\u5b89\u88c5 ",Object(i.b)("inlineCode",{parentName:"p"},"System.Linq.Dynamic.Core")," \u5305 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/zzzprojects/System.Linq.Dynamic.Core"}),"https://github.com/zzzprojects/System.Linq.Dynamic.Core")),Object(i.b)("h3",{id:"911101-\u52a8\u6001-sql"},"9.11.10.1 \u52a8\u6001 ",Object(i.b)("inlineCode",{parentName:"h3"},"Sql")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// \u793a\u4f8b\u4e00\nvar query = repository.AsQueryable()\n .Where("City == @0 and Orders.Count >= @1", "China", 10)\n .OrderBy("CompanyName")\n .Select("new(CompanyName as Name, Phone)");\n\n// \u793a\u4f8b\u4e8c\nvar list = repository.AsQueryable()\n .Where("Name.Contains(@0)","Fur")\n .ToList();\n\n// \u793a\u4f8b\u4e09\uff0c\u652f\u6301 ? \u8bed\u6cd5\nvar customers = repository.AsQueryable()\n .Include(c => c.Location)\n .Where(c => c.Location?.Name == "test") // \u6ce8\u610f Location?.Name\n .ToList();\n')),Object(i.b)("h3",{id:"911102-\u52a8\u6001-lambda"},"9.11.10.2 \u52a8\u6001 ",Object(i.b)("inlineCode",{parentName:"h3"},"Lambda")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// \u793a\u4f8b\u4e00\nvar x = Expression.Parameter(typeof(int), "x");\nvar y = Expression.Parameter(typeof(int), "y");\nvar e = DynamicExpressionParser\n .ParseLambda(new ParameterExpression[] { x, y }, null, "(x + y) * 2");\n\n// \u793a\u4f8b\u4e8c\nvar e = DynamicExpressionParser.ParseLambda(\n typeof(Customer), typeof(bool),\n "City = @0 and Orders.Count >= @1",\n "London", 10);\n')),Object(i.b)("h2",{id:"91111-\u6027\u80fd\u4f18\u5316"},"9.11.11 \u6027\u80fd\u4f18\u5316"),Object(i.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"EF Core")," \u4f1a\u8ddf\u8e2a\u6240\u6709\u5b9e\u4f53\uff0c\u4e5f\u5c31\u662f\u4efb\u4f55\u6570\u636e\u6539\u53d8\u90fd\u4f1a\u5f15\u8d77\u6570\u636e\u68c0\u67e5\uff0c\u6240\u4ee5\u5982\u679c\u53ea\u505a\u67e5\u8be2\u64cd\u4f5c\uff0c\u5efa\u8bae\u5173\u95ed\u5b9e\u4f53\u8ddf\u8e2a\u529f\u80fd\u3002"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u4ee5\u4e0b\u9ad8\u6027\u80fd\u5b9e\u4f53\u96c6\u5408\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"DetachedEntities"),"\uff1a\u8131\u8f68/\u4e0d\u8ffd\u8e2a\u5b9e\u4f53"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"AsQueryable()"),"\uff1a\u4e0d\u8ffd\u8e2a\u5b9e\u4f53"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Entities.AsNoTracking()"),"\uff1a\u624b\u52a8\u5173\u95ed\u5b9e\u4f53\u8ffd\u8e2a")),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"EF Core")," \u4e2d\uff0c\u590d\u6742\u67e5\u8be2\u603b\u662f\u4f1a\u751f\u6210\u4e00\u4e2a ",Object(i.b)("inlineCode",{parentName:"p"},"sql"),"\uff0c\u4e5f\u5c31\u662f ",Object(i.b)("inlineCode",{parentName:"p"},"AsSingleQuery()"),"\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u8bbe\u7f6e\u4e3a ",Object(i.b)("inlineCode",{parentName:"p"},"AsSplitQuery()")," \u5207\u5272\u6210\u591a\u4e2a\u67e5\u8be2\u3002"),Object(i.b)("h2",{id:"91112-\u5206\u8868\u67e5\u8be2\u5c0f\u4f8b\u5b50"},"9.11.12 \u5206\u8868\u67e5\u8be2\u5c0f\u4f8b\u5b50"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Collections.Generic;\n\nnamespace Fur.Core\n{\n public class Person : Entity, IEntityTypeBuilder\n {\n public string Name { get; set; }\n\n /// \n /// \u914d\u7f6e\u5b9e\u4f53\u5173\u7cfb\n /// \n /// \n /// \n /// \n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.ToSqlQuery(\n @"select * from dbo.person.2020-09-19\n union all\n select * from dbo.person.2020-09-20");\n }\n }\n}\n')),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var posts = repository.Where(u => u.Id > 10).ToList();\n")),Object(i.b)("h2",{id:"91112-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.11.12 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/4bfcf3ee.9fd3cf97.js b/handbook/build/4bfcf3ee.9fd3cf97.js deleted file mode 100644 index e791104a68d..00000000000 --- a/handbook/build/4bfcf3ee.9fd3cf97.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[27],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return b})),t.d(n,"b",(function(){return p}));var a=t(0),r=t.n(a);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function s(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var l=r.a.createContext({}),u=function(e){var n=r.a.useContext(l),t=n;return e&&(t="function"==typeof e?e(n):s(s({},n),e)),t},b=function(e){var n=u(e.components);return r.a.createElement(l.Provider,{value:n},e.children)},m={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},d=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,i=e.originalType,o=e.parentName,l=c(e,["components","mdxType","originalType","parentName"]),b=u(t),d=a,p=b["".concat(o,".").concat(d)]||b[d]||m[d]||i;return t?r.a.createElement(p,s(s({ref:n},l),{},{components:t})):r.a.createElement(p,s({ref:n},l))}));function p(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var i=t.length,o=new Array(i);o[0]=d;var s={};for(var c in n)hasOwnProperty.call(n,c)&&(s[c]=n[c]);s.originalType=e,s.mdxType="string"==typeof e?e:a,o[1]=s;for(var l=2;lInner Join",id:"91151-\u5185\u8fde\u63a5-inner-join",children:[]},{value:"9.11.5.2 \u5de6\u8fde\u63a5 Left Join",id:"91152-\u5de6\u8fde\u63a5-left-join",children:[]},{value:"9.11.5.2 \u53f3\u8fde\u63a5 Right Join",id:"91152-\u53f3\u8fde\u63a5-right-join",children:[]}]},{value:"9.11.6 \u5206\u7ec4\u67e5\u8be2",id:"9116-\u5206\u7ec4\u67e5\u8be2",children:[]},{value:"9.11.7 \u5408\u5e76\u7ed3\u679c\u96c6",id:"9117-\u5408\u5e76\u7ed3\u679c\u96c6",children:[]},{value:"9.11.8 \u67e5\u8be2\u6392\u5e8f",id:"9118-\u67e5\u8be2\u6392\u5e8f",children:[{value:"9.11.8.1 \u6b63\u5e8f",id:"91181-\u6b63\u5e8f",children:[]},{value:"9.11.8.2 \u5012\u5e8f",id:"91182-\u5012\u5e8f",children:[]},{value:"9.11.8.3 \u6df7\u5408\u5012\u5e8f",id:"91183-\u6df7\u5408\u5012\u5e8f",children:[]}]},{value:"9.11.9 \u9012\u5f52\u67e5\u8be2",id:"9119-\u9012\u5f52\u67e5\u8be2",children:[]},{value:"9.11.10 \u52a8\u6001 Sql \u67e5\u8be2",id:"91110-\u52a8\u6001-sql-\u67e5\u8be2",children:[{value:"9.11.10.1 \u52a8\u6001 Sql",id:"911101-\u52a8\u6001-sql",children:[]},{value:"9.11.10.2 \u52a8\u6001 Lambda",id:"911102-\u52a8\u6001-lambda",children:[]}]},{value:"9.11.11 \u6027\u80fd\u4f18\u5316",id:"91111-\u6027\u80fd\u4f18\u5316",children:[]},{value:"9.11.12 \u5206\u8868\u67e5\u8be2\u5c0f\u4f8b\u5b50",id:"91112-\u5206\u8868\u67e5\u8be2\u5c0f\u4f8b\u5b50",children:[]},{value:"9.11.12 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"91112-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],b={rightToc:u};function m(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},b,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"9111-\u5173\u8054\u6570\u636e\u6a21\u578b"},"9.11.1 \u5173\u8054\u6570\u636e\u6a21\u578b"),Object(i.b)(o.a,{defaultValue:"person",values:[{label:"Person",value:"person"},{label:"PersonDetail",value:"person-detail"},{label:"Children",value:"children"},{label:"Post",value:"post"}],mdxType:"Tabs"},Object(i.b)(s.a,{value:"person",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{38,43,48}","{38,43,48}":!0}),"using Fur.DatabaseAccessor;\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Core\n{\n public class Person : Entity\n {\n /// \n /// \u6784\u9020\u51fd\u6570\n /// \n public Person()\n {\n CreatedTime = DateTime.Now;\n IsDeleted = false;\n }\n\n /// \n /// \u59d3\u540d\n /// \n [MaxLength(32)]\n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n\n /// \n /// \u4f4f\u5740\n /// \n public string Address { get; set; }\n\n /// \n /// \u4ece\u8868\n /// \n public PersonDetail PersonDetail { get; set; }\n\n /// \n /// \u4e00\u5bf9\u591a\n /// \n public ICollection Childrens { get; set; }\n\n /// \n /// \u591a\u5bf9\u591a\n /// \n public ICollection Posts { get; set; }\n }\n}\n"))),Object(i.b)(s.a,{value:"person-detail",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{25}","{25}":!0}),"using Fur.DatabaseAccessor;\n\nnamespace Fur.Core\n{\n public class PersonDetail : EntityBase\n {\n /// \n /// \u7535\u8bdd\u53f7\u7801\n /// \n public string PhoneNumber { get; set; }\n\n /// \n /// QQ \u53f7\u7801\n /// \n public string QQ { get; set; }\n\n /// \n /// \u5916\u952e\n /// \n public int PersonId { get; set; }\n\n /// \n /// \u4e3b\u8868\n /// \n public Person Person { get; set; }\n }\n}\n"))),Object(i.b)(s.a,{value:"children",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{35}","{35}":!0}),"using Fur.DatabaseAccessor;\nusing System;\n\nnamespace Fur.Core\n{\n public class Children : Entity\n {\n /// \n /// \u6784\u9020\u51fd\u6570\n /// \n public Children()\n {\n CreatedTime = DateTime.Now;\n IsDeleted = false;\n }\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n\n /// \n /// \u6027\u522b\n /// \n public Gender Gender { get; set; }\n\n /// \n /// \u5916\u952e\n /// \n public int PersonId { get; set; }\n\n /// \n /// \u4e3b\u8868\n /// \n public Person Person { get; set; }\n }\n}\n"))),Object(i.b)(s.a,{value:"post",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{26}","{26}":!0}),"using Fur.DatabaseAccessor;\nusing System;\nusing System.Collections.Generic;\n\nnamespace Fur.Core\n{\n public class Post : Entity\n {\n /// \n /// \u6784\u9020\u51fd\u6570\n /// \n public Post()\n {\n CreatedTime = DateTime.Now;\n IsDeleted = false;\n }\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n\n /// \n /// Person \u96c6\u5408\n /// \n public ICollection Persons { get; set; }\n }\n}\n")))),Object(i.b)("h2",{id:"9112-\u4e00\u5bf9\u4e00\u67e5\u8be2"},"9.11.2 \u4e00\u5bf9\u4e00\u67e5\u8be2"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u793a\u4f8b\u4e00\nvar person = repository.Include(u => u.Detail);\n\n// \u793a\u4f8b\u4e8c\nvar person = repository.Include(u => u.Detail)\n .Include(u => u.Post);\n\n// \u793a\u4f8b\u4e09\nvar person = repository.Include(u => u.Detail)\n .ThenInclude(d => d.Review)\n .Include(u => u.Post);\n\n// \u793a\u4f8b\u56db\nvar person = repository.Include(u => u.Detail.Where(d => d.Id > 10).OrderBy(d => d.Name))\n .ThenInclude(d => d.Review)\n .Include(u => u.Post);\n\n// \u793a\u4f8b\u4e94\nvar person = repository.IncludeIf(!string.IsNullOrEmpty(keyword), u => u.Detail);\n\n// \u793a\u4f8b\u516d\nvar person = repository.IncludeIf(!string.IsNullOrEmpty(keyword), u => u.Detail)\n .IncludeIf(age > 18), u => u.Detail.Where(d => d.Id > 10).OrderBy(d => d.Name))\n .ThenInclude(d => d.Review)\n .Include(u => u.Post);\n")),Object(i.b)("h2",{id:"9113-\u4e00\u5bf9\u591a\u67e5\u8be2"},"9.11.3 \u4e00\u5bf9\u591a\u67e5\u8be2"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u793a\u4f8b\u4e00\nvar person = repository.Include(u => u.Childrens);\n\n// \u53c2\u8003 \u4e00\u5bf9\u4e00 \u4f8b\u5b50\n")),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u8bf4\u660e")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"\u4e00\u5bf9\u4e00")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"\u4e00\u5bf9\u591a")," \u67e5\u8be2\u65b9\u6cd5\u4e00\u6837\uff0c\u552f\u4e00\u7684\u533a\u522b\u662f\uff1a",Object(i.b)("inlineCode",{parentName:"p"},"\u4e00\u5bf9\u591a")," \u91c7\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"ICollection")," \u5b9a\u4e49\u5c5e\u6027\u3002"))),Object(i.b)("h2",{id:"9114-\u591a\u5bf9\u591a\u67e5\u8be2"},"9.11.4 \u591a\u5bf9\u591a\u67e5\u8be2"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u793a\u4f8b\u4e00\nvar person = repository.Include(u => u.Posts);\n\n// \u53c2\u8003 \u4e00\u5bf9\u4e00 \u4f8b\u5b50\n")),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u8bf4\u660e")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"\u4e00\u5bf9\u4e00")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"\u591a\u5bf9\u591a")," \u67e5\u8be2\u65b9\u6cd5\u4e00\u6837\uff0c\u552f\u4e00\u7684\u533a\u522b\u662f\uff1a",Object(i.b)("inlineCode",{parentName:"p"},"\u591a\u5bf9\u591a")," \u91c7\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"ICollection")," \u5b9a\u4e49\u5c5e\u6027\u3002"))),Object(i.b)("h2",{id:"9115-\u8054\u8868\u67e5\u8be2"},"9.11.5 \u8054\u8868\u67e5\u8be2"),Object(i.b)("h3",{id:"91151-\u5185\u8fde\u63a5-inner-join"},"9.11.5.1 \u5185\u8fde\u63a5 ",Object(i.b)("inlineCode",{parentName:"h3"},"Inner Join")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var query = from p in _personRepository.AsQueryable()\n join d in _personDetailRepository.AsQueryable() on p.Id equals d.PersonId\n select new PersonDto\n {\n PhoneNumber = p.PersonDetail.PhoneNumber,\n Address = p.Address,\n Age = p.Age,\n Name = p.Name,\n Id = p.Id,\n QQ = p.PersonDetail.QQ\n };\n")),Object(i.b)("h3",{id:"91152-\u5de6\u8fde\u63a5-left-join"},"9.11.5.2 \u5de6\u8fde\u63a5 ",Object(i.b)("inlineCode",{parentName:"h3"},"Left Join")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,3}","{2,3}":!0}),"var query = from p in _personRepository.AsQueryable()\n join d in _personDetailRepository.AsQueryable() on p.Id equals d.PersonId into results\n from d in results.DefaultIfEmpty()\n select new PersonDto\n {\n PhoneNumber = p.PersonDetail.PhoneNumber,\n Address = p.Address,\n Age = p.Age,\n Name = p.Name,\n Id = p.Id,\n QQ = p.PersonDetail.QQ\n };\n")),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5c0f\u63d0\u793a")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("strong",{parentName:"p"},Object(i.b)("inlineCode",{parentName:"strong"},"Left Join"))," \u548c ",Object(i.b)("strong",{parentName:"p"},Object(i.b)("inlineCode",{parentName:"strong"},"Inner Join"))," \u4e0d\u540c\u7684\u662f\uff0c",Object(i.b)("strong",{parentName:"p"},Object(i.b)("inlineCode",{parentName:"strong"},"Left Join"))," \u4f1a\u5148\u5c06\u7ed3\u679c ",Object(i.b)("strong",{parentName:"p"},Object(i.b)("inlineCode",{parentName:"strong"},"into"))," \u5230\u65b0\u7684\u7ed3\u679c\u96c6\u7136\u540e\u518d\u67e5\u8be2\uff0c\u5e76\u8c03\u7528 ",Object(i.b)("strong",{parentName:"p"},Object(i.b)("inlineCode",{parentName:"strong"},"DefaultIfEmpty()"))," \u65b9\u6cd5\u3002"))),Object(i.b)("h3",{id:"91152-\u53f3\u8fde\u63a5-right-join"},"9.11.5.2 \u53f3\u8fde\u63a5 ",Object(i.b)("inlineCode",{parentName:"h3"},"Right Join")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Right Join")," \u53ea\u9700\u8981\u5c06 ",Object(i.b)("inlineCode",{parentName:"p"},"Left Join")," \u4e3b\u4ece\u8868\u4f4d\u7f6e\u66f4\u6362\u5373\u53ef\u3002"),Object(i.b)("h2",{id:"9116-\u5206\u7ec4\u67e5\u8be2"},"9.11.6 \u5206\u7ec4\u67e5\u8be2"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u793a\u4f8b\u4e00\nvar query = repository.AsQueryable().GroupBy(x => new { x.Column1, x.Column2 });\n\n// \u793a\u4f8b\u4e8c\nvar query = from student in repository.AsQueryable()\n group student by repository2.AsQueryable() into dateGroup\n select new ResultData()\n {\n Key = dateGroup.Key,\n Value = dateGroup.Count()\n };\n\n// \u793a\u4f8b\u4e09\nvar query = from a in repository.AsQueryable()\n join b in repository2.AsQueryable() on a.Id equals b.Aid\n join c in repository3.AsQueryable() on c.id equals b.Bid\n group emp by new { emp.Age, emp.Sex } into g\n select new {\n Peo = g.Key,\n Count = g.Count()\n };\n")),Object(i.b)("h2",{id:"9117-\u5408\u5e76\u7ed3\u679c\u96c6"},"9.11.7 \u5408\u5e76\u7ed3\u679c\u96c6"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var query = repository.AsQueryable(u => u.Id > 10)\n .Union(\n repository2.AsQueryable(u => u.Id <= 10)\n );\n")),Object(i.b)("h2",{id:"9118-\u67e5\u8be2\u6392\u5e8f"},"9.11.8 \u67e5\u8be2\u6392\u5e8f"),Object(i.b)("h3",{id:"91181-\u6b63\u5e8f"},"9.11.8.1 \u6b63\u5e8f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u793a\u4f8b\u4e00\nvar query = repository.AsQueryable()\n .OrderBy(u => u.Id);\n\n// \u793a\u4f8b\u4e8c\nvar query =repository.AsQueryable()\n .OrderBy(u => u.Id)\n .ThenBy(u => u.Name);\n")),Object(i.b)("h3",{id:"91182-\u5012\u5e8f"},"9.11.8.2 \u5012\u5e8f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u793a\u4f8b\u4e00\nvar query = repository.AsQueryable()\n .OrderByDescending(u => u.Id);\n\n// \u793a\u4f8b\u4e8c\nvar query =repository.AsQueryable()\n .OrderByDescending(u => u.Id)\n .ThenByDescending(u => u.Name);\n")),Object(i.b)("h3",{id:"91183-\u6df7\u5408\u5012\u5e8f"},"9.11.8.3 \u6df7\u5408\u5012\u5e8f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u793a\u4f8b\u4e00\nvar query = repository.AsQueryable()\n .OrderBy(u => u.Id)\n .OrderByDescending(u => u.Name)\n .ThenBy(u => u.Age);\n")),Object(i.b)("h2",{id:"9119-\u9012\u5f52\u67e5\u8be2"},"9.11.9 \u9012\u5f52\u67e5\u8be2"),Object(i.b)(o.a,{defaultValue:"city",values:[{label:"City",value:"city"},{label:"CityDto",value:"citydto"}],mdxType:"Tabs"},Object(i.b)(s.a,{value:"city",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{12,36,41,49-55}","{12,36,41,49-55}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Collections.Generic;\n\nnamespace Fur.Core\n{\n /// \n /// \u57ce\u5e02\n /// \n public class City : Entity, IEntityTypeBuilder, IEntitySeedData\n {\n /// \n /// \u6784\u9020\u51fd\u6570\n /// \n public City()\n {\n CreatedTime = DateTime.Now;\n IsDeleted = false;\n }\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n\n /// \n /// \u4e0a\u7ea7Id\n /// \n public int? ParentId { get; set; }\n\n /// \n /// \u4e0a\u7ea7\n /// \n public virtual City Parent { get; set; }\n\n /// \n /// \u5b50\u96c6\n /// \n public virtual ICollection Childrens { get; set; }\n\n /// \n /// \u914d\u7f6e\u5b9e\u4f53\u5173\u7cfb\n /// \n /// \n /// \n /// \n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder\n .HasMany(x => x.Childrens)\n .WithOne(x => x.Parent)\n .HasForeignKey(x => x.ParentId)\n .OnDelete(DeleteBehavior.ClientSetNull); // \u5fc5\u987b\u8bbe\u7f6e\u8fd9\u4e00\u884c\n }\n\n /// \n /// \u79cd\u5b50\u6570\u636e\n /// \n /// \n /// \n /// \n public IEnumerable HasData(DbContext dbContext, Type dbContextLocator)\n {\n return new List\n {\n new City { Id=1,CreatedTime =DateTime.Parse("2020-08-20 15:30:20"),IsDeleted=false,Name="\u4e2d\u56fd" },\n new City { Id=2,CreatedTime =DateTime.Parse("2020-08-20 15:30:20"),IsDeleted=false,Name="\u5e7f\u4e1c\u7701",ParentId=1 },\n new City { Id=3,CreatedTime =DateTime.Parse("2020-08-20 15:30:20"),IsDeleted=false,Name="\u4e2d\u5c71\u5e02",ParentId=2 },\n new City { Id=4,CreatedTime =DateTime.Parse("2020-08-20 15:30:20"),IsDeleted=false,Name="\u73e0\u6d77\u5e02",ParentId=2 },\n new City { Id=5,CreatedTime =DateTime.Parse("2020-08-20 15:30:20"),IsDeleted=false,Name="\u6d59\u6c5f\u7701",ParentId=1 },\n };\n }\n }\n}\n'))),Object(i.b)(s.a,{value:"citydto",mdxType:"TabItem"},Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"using System.Collections.Generic;\n\nnamespace Fur.Application.Persons\n{\n public class CityDto\n {\n /// \n /// \u9010\u6e10\n /// \n public int Id { get; set; }\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n\n /// \n /// \u5b50\u96c6\n /// \n public ICollection Childrens { get; set; }\n }\n}\n")))),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var cities = await repository.AsQueryable()\n .Include(u => u.Childrens)\n .Where(u => u.Id == 1)\n .ToListAsync();\n\nvar dtos = cities.Adapt>();\n")),Object(i.b)("h2",{id:"91110-\u52a8\u6001-sql-\u67e5\u8be2"},"9.11.10 \u52a8\u6001 ",Object(i.b)("inlineCode",{parentName:"h2"},"Sql")," \u67e5\u8be2"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u9ed8\u8ba4\u4e0d\u652f\u6301 \u52a8\u6001 ",Object(i.b)("inlineCode",{parentName:"p"},"Sql")," \u67e5\u8be2\u529f\u80fd\uff0c\u4e0d\u8fc7\u53ef\u4ee5\u901a\u8fc7\u7b2c\u4e09\u65b9\u5b9e\u73b0\uff1a"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u9879\u76ee\u5c42\u5b89\u88c5 ",Object(i.b)("inlineCode",{parentName:"p"},"System.Linq.Dynamic.Core")," \u5305 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/zzzprojects/System.Linq.Dynamic.Core"}),"https://github.com/zzzprojects/System.Linq.Dynamic.Core")),Object(i.b)("h3",{id:"911101-\u52a8\u6001-sql"},"9.11.10.1 \u52a8\u6001 ",Object(i.b)("inlineCode",{parentName:"h3"},"Sql")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// \u793a\u4f8b\u4e00\nvar query = repository.AsQueryable()\n .Where("City == @0 and Orders.Count >= @1", "China", 10)\n .OrderBy("CompanyName")\n .Select("new(CompanyName as Name, Phone)");\n\n// \u793a\u4f8b\u4e8c\nvar list = repository.AsQueryable()\n .Where("Name.Contains(@0)","Fur")\n .ToList();\n\n// \u793a\u4f8b\u4e09\uff0c\u652f\u6301 ? \u8bed\u6cd5\nvar customers = repository.AsQueryable()\n .Include(c => c.Location)\n .Where(c => c.Location?.Name == "test") // \u6ce8\u610f Location?.Name\n .ToList();\n')),Object(i.b)("h3",{id:"911102-\u52a8\u6001-lambda"},"9.11.10.2 \u52a8\u6001 ",Object(i.b)("inlineCode",{parentName:"h3"},"Lambda")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// \u793a\u4f8b\u4e00\nvar x = Expression.Parameter(typeof(int), "x");\nvar y = Expression.Parameter(typeof(int), "y");\nvar e = DynamicExpressionParser\n .ParseLambda(new ParameterExpression[] { x, y }, null, "(x + y) * 2");\n\n// \u793a\u4f8b\u4e8c\nvar e = DynamicExpressionParser.ParseLambda(\n typeof(Customer), typeof(bool),\n "City = @0 and Orders.Count >= @1",\n "London", 10);\n')),Object(i.b)("h2",{id:"91111-\u6027\u80fd\u4f18\u5316"},"9.11.11 \u6027\u80fd\u4f18\u5316"),Object(i.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"EF Core")," \u4f1a\u8ddf\u8e2a\u6240\u6709\u5b9e\u4f53\uff0c\u4e5f\u5c31\u662f\u4efb\u4f55\u6570\u636e\u6539\u53d8\u90fd\u4f1a\u5f15\u8d77\u6570\u636e\u68c0\u67e5\uff0c\u6240\u4ee5\u5982\u679c\u53ea\u505a\u67e5\u8be2\u64cd\u4f5c\uff0c\u5efa\u8bae\u5173\u95ed\u5b9e\u4f53\u8ddf\u8e2a\u529f\u80fd\u3002"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u4ee5\u4e0b\u9ad8\u6027\u80fd\u5b9e\u4f53\u96c6\u5408\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"DetachedEntities"),"\uff1a\u8131\u8f68/\u4e0d\u8ffd\u8e2a\u5b9e\u4f53"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"AsQueryable()"),"\uff1a\u4e0d\u8ffd\u8e2a\u5b9e\u4f53"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Entities.AsNoTracking()"),"\uff1a\u624b\u52a8\u5173\u95ed\u5b9e\u4f53\u8ffd\u8e2a")),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"EF Core")," \u4e2d\uff0c\u590d\u6742\u67e5\u8be2\u603b\u662f\u4f1a\u751f\u6210\u4e00\u4e2a ",Object(i.b)("inlineCode",{parentName:"p"},"sql"),"\uff0c\u4e5f\u5c31\u662f ",Object(i.b)("inlineCode",{parentName:"p"},"AsSingleQuery()"),"\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u8bbe\u7f6e\u4e3a ",Object(i.b)("inlineCode",{parentName:"p"},"AsSplitQuery()")," \u5207\u5272\u6210\u591a\u4e2a\u67e5\u8be2\u3002"),Object(i.b)("h2",{id:"91112-\u5206\u8868\u67e5\u8be2\u5c0f\u4f8b\u5b50"},"9.11.12 \u5206\u8868\u67e5\u8be2\u5c0f\u4f8b\u5b50"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Collections.Generic;\n\nnamespace Fur.Core\n{\n public class Person : Entity, IEntityTypeBuilder\n {\n public string Name { get; set; }\n\n /// \n /// \u914d\u7f6e\u5b9e\u4f53\u5173\u7cfb\n /// \n /// \n /// \n /// \n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.ToSqlQuery(\n @"select * from dbo.person.2020-09-19\n union all\n select * from dbo.person.2020-09-20");\n }\n }\n}\n')),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var posts = repository.Where(u => u.Id > 10).ToList();\n")),Object(i.b)("h2",{id:"91112-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.11.12 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/4c30b939.7af2ecca.js b/handbook/build/4c30b939.7af2ecca.js new file mode 100644 index 00000000000..96673d0df10 --- /dev/null +++ b/handbook/build/4c30b939.7af2ecca.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[30],{142:function(e,t,a){"use strict";a.d(t,"a",(function(){return u})),a.d(t,"b",(function(){return j}));var r=a(0),n=a.n(r);function b(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function c(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function i(e){for(var t=1;t=0||(n[a]=e[a]);return n}(e,t);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}var p=n.a.createContext({}),o=function(e){var t=n.a.useContext(p),a=t;return e&&(a="function"==typeof e?e(t):i(i({},t),e)),a},u=function(e){var t=o(e.components);return n.a.createElement(p.Provider,{value:t},e.children)},O={inlineCode:"code",wrapper:function(e){var t=e.children;return n.a.createElement(n.a.Fragment,{},t)}},m=n.a.forwardRef((function(e,t){var a=e.components,r=e.mdxType,b=e.originalType,c=e.parentName,p=l(e,["components","mdxType","originalType","parentName"]),u=o(a),m=r,j=u["".concat(c,".").concat(m)]||u[m]||O[m]||b;return a?n.a.createElement(j,i(i({ref:t},p),{},{components:a})):n.a.createElement(j,i({ref:t},p))}));function j(e,t){var a=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var b=a.length,c=new Array(b);c[0]=m;var i={};for(var l in t)hasOwnProperty.call(t,l)&&(i[l]=t[l]);i.originalType=e,i.mdxType="string"==typeof e?e:r,c[1]=i;for(var p=2;p=0||(n[a]=e[a]);return n}(e,t);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}var p=n.a.createContext({}),o=function(e){var t=n.a.useContext(p),a=t;return e&&(a="function"==typeof e?e(t):i(i({},t),e)),a},u=function(e){var t=o(e.components);return n.a.createElement(p.Provider,{value:t},e.children)},O={inlineCode:"code",wrapper:function(e){var t=e.children;return n.a.createElement(n.a.Fragment,{},t)}},m=n.a.forwardRef((function(e,t){var a=e.components,r=e.mdxType,b=e.originalType,c=e.parentName,p=l(e,["components","mdxType","originalType","parentName"]),u=o(a),m=r,j=u["".concat(c,".").concat(m)]||u[m]||O[m]||b;return a?n.a.createElement(j,i(i({ref:t},p),{},{components:a})):n.a.createElement(j,i({ref:t},p))}));function j(e,t){var a=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var b=a.length,c=new Array(b);c[0]=m;var i={};for(var l in t)hasOwnProperty.call(t,l)&&(i[l]=t[l]);i.originalType=e,i.mdxType="string"==typeof e?e:r,c[1]=i;for(var p=2;p=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var s=r.a.createContext({}),l=function(e){var n=r.a.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):b(b({},n),e)),t},d=function(e){var n=l(e.components);return r.a.createElement(s.Provider,{value:n},e.children)},p={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},m=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,c=e.originalType,i=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),d=l(t),m=a,u=d["".concat(i,".").concat(m)]||d[m]||p[m]||c;return t?r.a.createElement(u,b(b({ref:n},s),{},{components:t})):r.a.createElement(u,b({ref:n},s))}));function u(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var c=t.length,i=new Array(c);i[0]=m;var b={};for(var o in n)hasOwnProperty.call(n,o)&&(b[o]=n[o]);b.originalType=e,b.mdxType="string"==typeof e?e:a,i[1]=b;for(var s=2;s\u4e3b\u5e93 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"92621-\u521b\u5efa-\u4e3b\u5e93-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"9.26.2.2 \u521b\u5efa \u4ece\u5e93 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"92622-\u521b\u5efa-\u4ece\u5e93-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"9.26.2.3 \u6ce8\u518c \u4e3b\u4ece\u5e93 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"92623-\u6ce8\u518c-\u4e3b\u4ece\u5e93-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"9.26.2.4 \u521b\u5efa Person \u5b9e\u4f53",id:"92624-\u521b\u5efa-person-\u5b9e\u4f53",children:[]},{value:"9.26.2.5 \u5c06 Person \u8f6c\u6362\u6210\u6570\u636e\u5e93\u8868",id:"92625-\u5c06-person-\u8f6c\u6362\u6210\u6570\u636e\u5e93\u8868",children:[]},{value:"9.26.2.6 \u4f7f\u7528\u4f8b\u5b50",id:"92626-\u4f7f\u7528\u4f8b\u5b50",children:[]}]},{value:"9.26.3 \u4e3b\u4ece\u590d\u5236",id:"9263-\u4e3b\u4ece\u590d\u5236",children:[]},{value:"9.26.4 \u4e3b\u4ece\u590d\u5236\u51e0\u79cd\u65b9\u5f0f",id:"9264-\u4e3b\u4ece\u590d\u5236\u51e0\u79cd\u65b9\u5f0f",children:[{value:"9.26.4.1 \u540c\u6b65\u590d\u5236",id:"92641-\u540c\u6b65\u590d\u5236",children:[]},{value:"9.26.4.2 \u5f02\u6b65\u590d\u5236",id:"92642-\u5f02\u6b65\u590d\u5236",children:[]},{value:"9.26.4.3 \u534a\u540c\u6b65\u590d\u5236",id:"92643-\u534a\u540c\u6b65\u590d\u5236",children:[]}]},{value:"9.26.5 SqlServer \u4e3b\u5e93\u914d\u7f6e",id:"9265-sqlserver-\u4e3b\u5e93\u914d\u7f6e",children:[{value:"9.26.5.1 \u6dfb\u52a0 \u672c\u5730\u53d1\u5e03",id:"92651-\u6dfb\u52a0-\u672c\u5730\u53d1\u5e03",children:[]},{value:"9.26.5.2 \u9009\u62e9 \u5206\u53d1\u670d\u52a1\u5668",id:"92652-\u9009\u62e9-\u5206\u53d1\u670d\u52a1\u5668",children:[]},{value:"9.26.5.3 \u542f\u7528 \u4ee3\u7406",id:"92653-\u542f\u7528-\u4ee3\u7406",children:[]},{value:"9.26.5.4 \u53d1\u5e03\u6570\u636e\u5e93",id:"92654-\u53d1\u5e03\u6570\u636e\u5e93",children:[]},{value:"9.26.5.5 \u5feb\u7167\u53d1\u5e03",id:"92655-\u5feb\u7167\u53d1\u5e03",children:[]},{value:"9.26.5.6 \u9009\u62e9\u53d1\u5e03\u9879\u76ee",id:"92656-\u9009\u62e9\u53d1\u5e03\u9879\u76ee",children:[]},{value:"9.26.5.7 \u914d\u7f6e\u5206\u53d1\u8ba1\u5212",id:"92657-\u914d\u7f6e\u5206\u53d1\u8ba1\u5212",children:[]},{value:"9.26.5.8 \u914d\u7f6e\u5b89\u5168\u8bbe\u7f6e",id:"92658-\u914d\u7f6e\u5b89\u5168\u8bbe\u7f6e",children:[]},{value:"9.26.5.9 \u5b8c\u6210\u914d\u7f6e",id:"92659-\u5b8c\u6210\u914d\u7f6e",children:[]}]},{value:"9.26.6 SqlServer \u4ece\u5e93\u914d\u7f6e",id:"9266-sqlserver-\u4ece\u5e93\u914d\u7f6e",children:[{value:"9.26.6.1 \u6dfb\u52a0 \u672c\u5730\u8ba2\u9605",id:"92661-\u6dfb\u52a0-\u672c\u5730\u8ba2\u9605",children:[]},{value:"9.26.6.2 \u9009\u62e9 \u5206\u53d1\u670d\u52a1\u5668",id:"92662-\u9009\u62e9-\u5206\u53d1\u670d\u52a1\u5668",children:[]},{value:"9.26.6.3 \u9009\u62e9 \u5206\u53d1\u4ee3\u7406\u4f4d\u7f6e",id:"92663-\u9009\u62e9-\u5206\u53d1\u4ee3\u7406\u4f4d\u7f6e",children:[]},{value:"9.26.6.4 \u9009\u62e9 \u8ba2\u9605\u6570\u636e\u5e93",id:"92664-\u9009\u62e9-\u8ba2\u9605\u6570\u636e\u5e93",children:[]},{value:"9.26.6.5 \u9009\u62e9 \u5206\u53d1\u5b89\u5168\u8bbe\u7f6e",id:"92665-\u9009\u62e9-\u5206\u53d1\u5b89\u5168\u8bbe\u7f6e",children:[]},{value:"9.26.6.6 \u9009\u62e9 \u540c\u6b65\u8ba1\u5212",id:"92666-\u9009\u62e9-\u540c\u6b65\u8ba1\u5212",children:[]},{value:"9.26.6.7 \u5b8c\u6210\u8ba2\u9605",id:"92667-\u5b8c\u6210\u8ba2\u9605",children:[]}]},{value:"9.26.7 \u5206\u53d1\u5b9a\u4e49\u76d1\u89c6",id:"9267-\u5206\u53d1\u5b9a\u4e49\u76d1\u89c6",children:[]},{value:"9.26.8 \u67e5\u770b\u4e3b\u4ece\u590d\u5236\u7ed3\u679c",id:"9268-\u67e5\u770b\u4e3b\u4ece\u590d\u5236\u7ed3\u679c",children:[]},{value:"9.26.9 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9269-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],l={rightToc:s};function d(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(c.b)("wrapper",Object(a.a)({},l,t,{components:n,mdxType:"MDXLayout"}),Object(c.b)("h2",{id:"9261-\u8bfb\u5199\u5206\u79bb"},"9.26.1 \u8bfb\u5199\u5206\u79bb"),Object(c.b)("p",null,"\u5176\u5b9e\u5c31\u662f\u5c06\u6570\u636e\u5e93\u5206\u4e3a\u4e86\u4e3b\u4ece\u5e93\uff0c\u4e00\u4e2a\u4e3b\u5e93\u7528\u4e8e\u5199\u6570\u636e\uff0c\u591a\u4e2a\u4ece\u5e93\u5b8c\u6210\u8bfb\u6570\u636e\u7684\u64cd\u4f5c\uff0c\u4e3b\u4ece\u5e93\u4e4b\u95f4\u901a\u8fc7\u67d0\u79cd\u673a\u5236\u8fdb\u884c\u6570\u636e\u7684\u540c\u6b65\uff0c\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u6570\u636e\u5e93\u67b6\u6784\u3002"),Object(c.b)("img",{src:Object(i.a)("img/readwrite.png"),style:{height:300}}),Object(c.b)("h3",{id:"92611-\u89e3\u51b3\u4e86\u4ec0\u4e48\u95ee\u9898"},"9.26.1.1 \u89e3\u51b3\u4e86\u4ec0\u4e48\u95ee\u9898"),Object(c.b)("p",null,"\u5927\u591a\u6570\u4e92\u8054\u7f51\u4e1a\u52a1\uff0c\u5f80\u5f80\u8bfb\u591a\u5199\u5c11\uff0c\u8fd9\u65f6\u5019\uff0c\u6570\u636e\u5e93\u7684\u8bfb\u4f1a\u9996\u5148\u6210\u4e3a\u6570\u636e\u5e93\u7684\u74f6\u9888\uff0c\u8fd9\u65f6\uff0c\u5982\u679c\u6211\u4eec\u5e0c\u671b\u80fd\u591f\u7ebf\u6027\u7684\u63d0\u5347\u6570\u636e\u5e93\u7684\u8bfb\u6027\u80fd\uff0c\u6d88\u9664\u8bfb\u5199\u9501\u51b2\u7a81\u4ece\u800c\u63d0\u5347\u6570\u636e\u5e93\u7684\u5199\u6027\u80fd\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u4f7f\u7528\u201c\u5206\u7ec4\u67b6\u6784\u201d\uff08\u8bfb\u5199\u5206\u79bb\u67b6\u6784\uff09\u3002"),Object(c.b)("p",null,"\u7528\u4e00\u53e5\u8bdd\u6982\u62ec\uff0c\u8bfb\u5199\u5206\u79bb\u662f\u7528\u6765\u89e3\u51b3\u6570\u636e\u5e93\u7684\u8bfb\u6027\u80fd\u74f6\u9888\u7684\u3002"),Object(c.b)("h3",{id:"92612-\u6ce8\u610f\u4e8b\u9879"},"9.26.1.2 \u6ce8\u610f\u4e8b\u9879"),Object(c.b)("ul",null,Object(c.b)("li",{parentName:"ul"},"\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u8981\u8fdb\u884c\u533a\u5206\uff0c\u54ea\u4e9b\u662f\u8bfb\u8fde\u63a5\u6c60\uff0c\u54ea\u4e2a\u662f\u5199\u8fde\u63a5\u6c60\uff0c\u7814\u53d1\u7684\u96be\u5ea6\u4f1a\u589e\u52a0\uff1b"),Object(c.b)("li",{parentName:"ul"},"\u4e3a\u4e86\u4fdd\u8bc1\u9ad8\u53ef\u7528\uff0c\u8bfb\u8fde\u63a5\u6c60\u8981\u80fd\u591f\u5b9e\u73b0\u6545\u969c\u81ea\u52a8\u8f6c\u79fb\uff1b"),Object(c.b)("li",{parentName:"ul"},"\u4e3b\u4ece\u7684\u4e00\u81f4\u6027\u95ee\u9898\u9700\u8981\u8003\u8651\u3002")),Object(c.b)("h2",{id:"9262-\u5982\u4f55\u5b9e\u73b0"},"9.26.2 \u5982\u4f55\u5b9e\u73b0"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"Fur")," \u5728\u6570\u636e\u5e93\u6a21\u5757\u8bbe\u8ba1\u4e4b\u521d\uff0c\u5c31\u8003\u8651\u4e86\u8bfb\u5199\u5206\u79bb\u8fd9\u79cd\u60c5\u51b5\uff0c\u6240\u4ee5\u4ece\u5e95\u5c42\u5c31\u652f\u6301\u52a8\u6001\u5207\u6362\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u53ca\u8bfb\u5199\u64cd\u4f5c\u65b9\u6cd5\u7ea6\u675f\u3002"),Object(c.b)("p",null,"\u8bfb\u5199\u5206\u79bb\u64cd\u4f5c\u4e3b\u8981\u4f7f\u7528 ",Object(c.b)("inlineCode",{parentName:"p"},"IMSRepository")," \u4ed3\u50a8\uff0c\u8be5\u4ed3\u50a8\u5df2\u7ecf\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u65b9\u4fbf\u7684\u64cd\u4f5c\u8c03\u7528\u3002\u5f53\u7136\u4e5f\u53ef\u4ee5\u4e0d\u4f7f\u7528\u8be5\u4ed3\u50a8\u3002"),Object(c.b)("p",null,"\u4e0b\u9762\u5c31\u7ed9\u5927\u5bb6\u6f14\u793a\u5982\u4f55\u8bfb\u5199\u591a\u5e93\u8bfb\u5199\u64cd\u4f5c\u3002"),Object(c.b)("h3",{id:"92621-\u521b\u5efa-\u4e3b\u5e93-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"9.26.2.1 \u521b\u5efa ",Object(c.b)("inlineCode",{parentName:"h3"},"\u4e3b\u5e93")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n /// \n /// \u4e3b\u5e93\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\n /// \n [AppDbContext("MasterConnectionString")]\n public class MasterDbContext : AppDbContext\n {\n public MasterDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(c.b)("p",null,Object(c.b)("strong",{parentName:"p"},"\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\uff1a")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json"}),'{\n "ConnectionStrings": {\n "MasterConnectionString": "Server=localhost;Database=Fur;User=sa;Password=000000;MultipleActiveResultSets=True;"\n }\n}\n')),Object(c.b)("h3",{id:"92622-\u521b\u5efa-\u4ece\u5e93-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"9.26.2.2 \u521b\u5efa ",Object(c.b)("inlineCode",{parentName:"h3"},"\u4ece\u5e93")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{11}","{11}":!0}),'using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n /// \n /// \u4ece\u5e93\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\n /// \n [AppDbContext("SlaveConnectionString")]\n public class SlaveDbContext : AppDbContext\n {\n public SlaveDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(c.b)("div",{className:"admonition admonition-important alert alert--info"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u591a\u6570\u636e\u5e93\u64cd\u4f5c\u9664\u4e86\u9ed8\u8ba4\u6570\u636e\u5e93\u65e0\u9700\u81ea\u5b9a\u4e49 ",Object(c.b)("strong",{parentName:"p"},"\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668"),"\uff0c\u5176\u4ed6\u6570\u636e\u5e93\u90fd\u9700\u8981\u6709\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u3002\u5982 ",Object(c.b)("inlineCode",{parentName:"p"},"SlaveDbContextLocator")))),Object(c.b)("p",null,Object(c.b)("strong",{parentName:"p"},"\u4ece\u5e93\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\uff1a")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8}","{8}":!0}),"using Fur.DatabaseAccessor;\n\nnamespace Fur.Core\n{\n /// \n /// \u4ece\u5e93\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\n /// \n public class SlaveDbContextLocator : IDbContextLocator\n {\n }\n}\n")),Object(c.b)("p",null,Object(c.b)("strong",{parentName:"p"},"\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\uff1a")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json"}),'{\n "ConnectionStrings": {\n "SlaveConnectionString": "Server=localhost;Database=FurSlave;User=sa;Password=000000;MultipleActiveResultSets=True;"\n }\n}\n')),Object(c.b)("h3",{id:"92623-\u6ce8\u518c-\u4e3b\u4ece\u5e93-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"9.26.2.3 \u6ce8\u518c ",Object(c.b)("inlineCode",{parentName:"h3"},"\u4e3b\u4ece\u5e93")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{13-14}","{13-14}":!0}),"using Fur.Core;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(600)]\n public sealed class FurEntityFrameworkCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddDatabaseAccessor(options =>\n {\n services.AddSqlServerPool();\n services.AddSqlServerPool();\n });\n }\n }\n}\n")),Object(c.b)("h3",{id:"92624-\u521b\u5efa-person-\u5b9e\u4f53"},"9.26.2.4 \u521b\u5efa ",Object(c.b)("inlineCode",{parentName:"h3"},"Person")," \u5b9e\u4f53"),Object(c.b)("p",null,"\u7531\u4e8e ",Object(c.b)("inlineCode",{parentName:"p"},"\u4e3b\u4ece\u5e93")," \u5177\u6709\u76f8\u540c\u7684\u6570\u636e\u5e93\u7ed3\u6784\uff0c\u6240\u4ee5\u5b9e\u4f53\u4e5f\u5fc5\u987b\u58f0\u660e ",Object(c.b)("inlineCode",{parentName:"p"},"\u4e3b\u4ece\u5e93"),"\uff1a"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7}","{7}":!0}),"using Fur.DatabaseAccessor;\nusing System.ComponentModel.DataAnnotations;\nusing System.ComponentModel.DataAnnotations.Schema;\n\nnamespace Fur.Core\n{\n public class Person : IEntity\n {\n /// \n /// \u4e3b\u952eId\n /// \n [Key]\n [DatabaseGenerated(DatabaseGeneratedOption.Identity)]\n public int Id { get; set; }\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n }\n}\n")),Object(c.b)("h3",{id:"92625-\u5c06-person-\u8f6c\u6362\u6210\u6570\u636e\u5e93\u8868"},"9.26.2.5 \u5c06 ",Object(c.b)("inlineCode",{parentName:"h3"},"Person")," \u8f6c\u6362\u6210\u6570\u636e\u5e93\u8868"),Object(c.b)("p",null,Object(c.b)("strong",{parentName:"p"},"\u521b\u5efa\u4e3b\u5e93\u6570\u636e\u5e93\u8868\uff1a")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Add-Migration v0.0.1 -Context MasterDbContext\n")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database -Context MasterDbContext\n")),Object(c.b)("p",null,Object(c.b)("strong",{parentName:"p"},"\u521b\u5efa\u4ece\u5e93\u6570\u636e\u5e93\u8868\uff1a")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Add-Migration v0.0.1 -Context SlaveDbContext\n")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database -Context SlaveDbContext\n")),Object(c.b)("img",{src:Object(i.a)("img/readwrite1.png")}),Object(c.b)("img",{src:Object(i.a)("img/readwrite2.png")}),Object(c.b)("h3",{id:"92626-\u4f7f\u7528\u4f8b\u5b50"},"9.26.2.6 \u4f7f\u7528\u4f8b\u5b50"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{13,19,31,40}","{13,19,31,40}":!0}),'using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing Fur.DynamicApiController;\nusing System.Collections.Generic;\n\nnamespace Fur.Application\n{\n public class PersonService : IDynamicApiController\n {\n /// \n /// \u53ef\u8c03\u914d\u4ed3\u50a8\uff08\u8bfb\u5199\u5206\u79bb\uff09\n /// \n private readonly IMSRepository _msRepository;\n\n /// \n /// \u6784\u9020\u51fd\u6570\u521d\u59cb\u5316\n /// \n /// \n public PersonService(IMSRepository msRepository)\n {\n _msRepository = msRepository;\n }\n\n /// \n /// \u65b0\u589e\u8d70\u4e3b\u5e93\n /// \n /// \n /// \n public void Insert(Person person)\n {\n _msRepository.Master().Insert(person);\n }\n\n /// \n /// \u67e5\u8be2\u8d70\u4ece\u5e93\n /// \n /// \n public List Get()\n {\n return _msRepository.Slave1().AsEnumerable();\n }\n }\n}\n')),Object(c.b)("h2",{id:"9263-\u4e3b\u4ece\u590d\u5236"},"9.26.3 \u4e3b\u4ece\u590d\u5236"),Object(c.b)("p",null,"\u4e3b\u4ece\u590d\u5236\uff1a\u662f\u4e00\u79cd\u6570\u636e\u5907\u4efd\u7684\u65b9\u6848\u3002"),Object(c.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u662f\u4f7f\u7528\u4e24\u4e2a\u6216\u4e24\u4e2a\u4ee5\u4e0a\u76f8\u540c\u7684\u6570\u636e\u5e93\uff0c\u5c06\u4e00\u4e2a\u6570\u636e\u5e93\u5f53\u505a\u4e3b\u6570\u636e\u5e93\uff0c\u800c\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u5f53\u505a\u4ece\u6570\u636e\u5e93\u3002",Object(c.b)("strong",{parentName:"p"},"\u5728\u4e3b\u6570\u636e\u5e93\u4e2d\u8fdb\u884c\u76f8\u5e94\u64cd\u4f5c\u65f6\uff0c\u4ece\u6570\u636e\u5e93\u8bb0\u5f55\u4e0b\u6240\u6709\u4e3b\u6570\u636e\u5e93\u7684\u64cd\u4f5c\uff0c\u4f7f\u5176\u4e8c\u8005\u4e00\u6a21\u4e00\u6837\u3002")),Object(c.b)("h2",{id:"9264-\u4e3b\u4ece\u590d\u5236\u51e0\u79cd\u65b9\u5f0f"},"9.26.4 \u4e3b\u4ece\u590d\u5236\u51e0\u79cd\u65b9\u5f0f"),Object(c.b)("h3",{id:"92641-\u540c\u6b65\u590d\u5236"},"9.26.4.1 \u540c\u6b65\u590d\u5236"),Object(c.b)("p",null,"\u6240\u8c13\u7684\u540c\u6b65\u590d\u5236\uff0c\u610f\u601d\u662f ",Object(c.b)("inlineCode",{parentName:"p"},"Master")," \u7684\u53d8\u5316\uff0c\u5fc5\u987b\u7b49\u5f85 ",Object(c.b)("inlineCode",{parentName:"p"},"Slave-1\uff0cSlave-2\uff0c...\uff0cSlave-n")," \u5b8c\u6210\u540e\u624d\u80fd\u8fd4\u56de\u3002\n\u8fd9\u6837\uff0c\u663e\u7136\u4e0d\u53ef\u53d6\uff0c\u6bd4\u5982\uff0c\u5728 ",Object(c.b)("inlineCode",{parentName:"p"},"Web")," \u524d\u7aef\u9875\u9762\u4e0a\uff0c\u7528\u6237\u589e\u52a0\u4e86\u6761\u8bb0\u5f55\uff0c\u9700\u8981\u7b49\u5f85\u5f88\u957f\u65f6\u95f4\u3002"),Object(c.b)("h3",{id:"92642-\u5f02\u6b65\u590d\u5236"},"9.26.4.2 \u5f02\u6b65\u590d\u5236"),Object(c.b)("p",null,"\u5982\u540c AJAX \u8bf7\u6c42\u4e00\u6837\u3002",Object(c.b)("inlineCode",{parentName:"p"},"Master")," \u53ea\u9700\u8981\u5b8c\u6210\u81ea\u5df1\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u5373\u53ef\u3002\u81f3\u4e8e ",Object(c.b)("inlineCode",{parentName:"p"},"Slaves")," \u662f\u5426\u6536\u5230\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff0c\u662f\u5426\u5b8c\u6210\u64cd\u4f5c\uff0c\u4e0d\u7528\u5173\u5fc3\u3002",Object(c.b)("strong",{parentName:"p"},"\uff08\u63a8\u8350\u65b9\u5f0f\uff09")),Object(c.b)("h3",{id:"92643-\u534a\u540c\u6b65\u590d\u5236"},"9.26.4.3 \u534a\u540c\u6b65\u590d\u5236"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"Master")," \u53ea\u4fdd\u8bc1 ",Object(c.b)("inlineCode",{parentName:"p"},"Slaves")," \u4e2d\u7684\u4e00\u4e2a\u64cd\u4f5c\u6210\u529f\uff0c\u5c31\u8fd4\u56de\uff0c\u5176\u4ed6 ",Object(c.b)("inlineCode",{parentName:"p"},"Slave")," \u4e0d\u7ba1\u3002"),Object(c.b)("p",null,"\u4e0b\u9762\u5c06\u4f7f\u7528 ",Object(c.b)("inlineCode",{parentName:"p"},"SqlServer")," \u7b80\u5355\u914d\u7f6e\u4e3b\u4ece\u590d\u5236\u529f\u80fd\u3002"),Object(c.b)("h2",{id:"9265-sqlserver-\u4e3b\u5e93\u914d\u7f6e"},"9.26.5 ",Object(c.b)("inlineCode",{parentName:"h2"},"SqlServer")," \u4e3b\u5e93\u914d\u7f6e"),Object(c.b)("h3",{id:"92651-\u6dfb\u52a0-\u672c\u5730\u53d1\u5e03"},"9.26.5.1 \u6dfb\u52a0 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u672c\u5730\u53d1\u5e03")),Object(c.b)("img",{src:Object(i.a)("img/dbcopy1.png")}),Object(c.b)("h3",{id:"92652-\u9009\u62e9-\u5206\u53d1\u670d\u52a1\u5668"},"9.26.5.2 \u9009\u62e9 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u5206\u53d1\u670d\u52a1\u5668")),Object(c.b)("img",{src:Object(i.a)("img/dbcopy2.png")}),Object(c.b)("h3",{id:"92653-\u542f\u7528-\u4ee3\u7406"},"9.26.5.3 \u542f\u7528 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u4ee3\u7406")),Object(c.b)("img",{src:Object(i.a)("img/dbcopy3.png")}),Object(c.b)("h3",{id:"92654-\u53d1\u5e03\u6570\u636e\u5e93"},"9.26.5.4 \u53d1\u5e03\u6570\u636e\u5e93"),Object(c.b)("img",{src:Object(i.a)("img/dbcopy4.png")}),Object(c.b)("h3",{id:"92655-\u5feb\u7167\u53d1\u5e03"},"9.26.5.5 \u5feb\u7167\u53d1\u5e03"),Object(c.b)("img",{src:Object(i.a)("img/dbcopy5.png")}),Object(c.b)("p",null,"\u5177\u4f53\u9009\u62e9\u4f55\u79cd\u53d1\u5e03\u7c7b\u578b\uff0c\u89c6\u5177\u4f53\u4e1a\u52a1\u573a\u666f\u800c\u5b9a\u3002"),Object(c.b)("h3",{id:"92656-\u9009\u62e9\u53d1\u5e03\u9879\u76ee"},"9.26.5.6 \u9009\u62e9\u53d1\u5e03\u9879\u76ee"),Object(c.b)("img",{src:Object(i.a)("img/dbcopy6.png")}),Object(c.b)("h3",{id:"92657-\u914d\u7f6e\u5206\u53d1\u8ba1\u5212"},"9.26.5.7 \u914d\u7f6e\u5206\u53d1\u8ba1\u5212"),Object(c.b)("img",{src:Object(i.a)("img/dbcopy7.png")}),Object(c.b)("img",{src:Object(i.a)("img/dbcopy8.png")}),Object(c.b)("h3",{id:"92658-\u914d\u7f6e\u5b89\u5168\u8bbe\u7f6e"},"9.26.5.8 \u914d\u7f6e\u5b89\u5168\u8bbe\u7f6e"),Object(c.b)("img",{src:Object(i.a)("img/dbcopy9.png")}),Object(c.b)("img",{src:Object(i.a)("img/dbcopy10.png")}),Object(c.b)("h3",{id:"92659-\u5b8c\u6210\u914d\u7f6e"},"9.26.5.9 \u5b8c\u6210\u914d\u7f6e"),Object(c.b)("img",{src:Object(i.a)("img/dbcopy11.png")}),Object(c.b)("img",{src:Object(i.a)("img/dbcopy12.png")}),Object(c.b)("h2",{id:"9266-sqlserver-\u4ece\u5e93\u914d\u7f6e"},"9.26.6 ",Object(c.b)("inlineCode",{parentName:"h2"},"SqlServer")," \u4ece\u5e93\u914d\u7f6e"),Object(c.b)("h3",{id:"92661-\u6dfb\u52a0-\u672c\u5730\u8ba2\u9605"},"9.26.6.1 \u6dfb\u52a0 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u672c\u5730\u8ba2\u9605")),Object(c.b)("img",{src:Object(i.a)("img/dbrece1.png")}),Object(c.b)("h3",{id:"92662-\u9009\u62e9-\u5206\u53d1\u670d\u52a1\u5668"},"9.26.6.2 \u9009\u62e9 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u5206\u53d1\u670d\u52a1\u5668")),Object(c.b)("img",{src:Object(i.a)("img/dbrece2.png")}),Object(c.b)("h3",{id:"92663-\u9009\u62e9-\u5206\u53d1\u4ee3\u7406\u4f4d\u7f6e"},"9.26.6.3 \u9009\u62e9 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u5206\u53d1\u4ee3\u7406\u4f4d\u7f6e")),Object(c.b)("img",{src:Object(i.a)("img/dbrece3.png")}),Object(c.b)("h3",{id:"92664-\u9009\u62e9-\u8ba2\u9605\u6570\u636e\u5e93"},"9.26.6.4 \u9009\u62e9 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u8ba2\u9605\u6570\u636e\u5e93")),Object(c.b)("img",{src:Object(i.a)("img/dbrece4.png")}),Object(c.b)("h3",{id:"92665-\u9009\u62e9-\u5206\u53d1\u5b89\u5168\u8bbe\u7f6e"},"9.26.6.5 \u9009\u62e9 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u5206\u53d1\u5b89\u5168\u8bbe\u7f6e")),Object(c.b)("img",{src:Object(i.a)("img/dbrece5.png")}),Object(c.b)("img",{src:Object(i.a)("img/dbrece6.png")}),Object(c.b)("h3",{id:"92666-\u9009\u62e9-\u540c\u6b65\u8ba1\u5212"},"9.26.6.6 \u9009\u62e9 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u540c\u6b65\u8ba1\u5212")),Object(c.b)("img",{src:Object(i.a)("img/dbrece7.png")}),Object(c.b)("h3",{id:"92667-\u5b8c\u6210\u8ba2\u9605"},"9.26.6.7 \u5b8c\u6210\u8ba2\u9605"),Object(c.b)("img",{src:Object(i.a)("img/dbrece8.png")}),Object(c.b)("h2",{id:"9267-\u5206\u53d1\u5b9a\u4e49\u76d1\u89c6"},"9.26.7 \u5206\u53d1\u5b9a\u4e49\u76d1\u89c6"),Object(c.b)("img",{src:Object(i.a)("img/dbrece9.png")}),Object(c.b)("h2",{id:"9268-\u67e5\u770b\u4e3b\u4ece\u590d\u5236\u7ed3\u679c"},"9.26.8 \u67e5\u770b\u4e3b\u4ece\u590d\u5236\u7ed3\u679c"),Object(c.b)("img",{src:Object(i.a)("img/dbrece10.png")}),Object(c.b)("img",{src:Object(i.a)("img/dbrece11.png")}),Object(c.b)("div",{className:"admonition admonition-important alert alert--info"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u7279\u6027")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},'\u4e3b\u4ece\u590d\u5236\u6709\u4e00\u5b9a\u8fdf\u5ef6\u6027\uff0c\u6240\u4ee5\u7cfb\u7edf\u8bbe\u8ba1\u8981\u6709\u4e00\u5b9a\u201c\u5bb9\u5fcd\u6027"\u3002'))),Object(c.b)("h2",{id:"9269-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.26.9 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/4dbcf072.86aa2a4d.js b/handbook/build/4dbcf072.86aa2a4d.js new file mode 100644 index 00000000000..5456e51888e --- /dev/null +++ b/handbook/build/4dbcf072.86aa2a4d.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[31],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return d})),t.d(n,"b",(function(){return u}));var a=t(0),r=t.n(a);function c(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function b(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var s=r.a.createContext({}),l=function(e){var n=r.a.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):b(b({},n),e)),t},d=function(e){var n=l(e.components);return r.a.createElement(s.Provider,{value:n},e.children)},p={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},m=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,c=e.originalType,i=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),d=l(t),m=a,u=d["".concat(i,".").concat(m)]||d[m]||p[m]||c;return t?r.a.createElement(u,b(b({ref:n},s),{},{components:t})):r.a.createElement(u,b({ref:n},s))}));function u(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var c=t.length,i=new Array(c);i[0]=m;var b={};for(var o in n)hasOwnProperty.call(n,o)&&(b[o]=n[o]);b.originalType=e,b.mdxType="string"==typeof e?e:a,i[1]=b;for(var s=2;s\u4e3b\u5e93 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"92621-\u521b\u5efa-\u4e3b\u5e93-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"9.26.2.2 \u521b\u5efa \u4ece\u5e93 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"92622-\u521b\u5efa-\u4ece\u5e93-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"9.26.2.3 \u6ce8\u518c \u4e3b\u4ece\u5e93 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"92623-\u6ce8\u518c-\u4e3b\u4ece\u5e93-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"9.26.2.4 \u521b\u5efa Person \u5b9e\u4f53",id:"92624-\u521b\u5efa-person-\u5b9e\u4f53",children:[]},{value:"9.26.2.5 \u5c06 Person \u8f6c\u6362\u6210\u6570\u636e\u5e93\u8868",id:"92625-\u5c06-person-\u8f6c\u6362\u6210\u6570\u636e\u5e93\u8868",children:[]},{value:"9.26.2.6 \u4f7f\u7528\u4f8b\u5b50",id:"92626-\u4f7f\u7528\u4f8b\u5b50",children:[]}]},{value:"9.26.3 \u4e3b\u4ece\u590d\u5236",id:"9263-\u4e3b\u4ece\u590d\u5236",children:[]},{value:"9.26.4 \u4e3b\u4ece\u590d\u5236\u51e0\u79cd\u65b9\u5f0f",id:"9264-\u4e3b\u4ece\u590d\u5236\u51e0\u79cd\u65b9\u5f0f",children:[{value:"9.26.4.1 \u540c\u6b65\u590d\u5236",id:"92641-\u540c\u6b65\u590d\u5236",children:[]},{value:"9.26.4.2 \u5f02\u6b65\u590d\u5236",id:"92642-\u5f02\u6b65\u590d\u5236",children:[]},{value:"9.26.4.3 \u534a\u540c\u6b65\u590d\u5236",id:"92643-\u534a\u540c\u6b65\u590d\u5236",children:[]}]},{value:"9.26.5 SqlServer \u4e3b\u5e93\u914d\u7f6e",id:"9265-sqlserver-\u4e3b\u5e93\u914d\u7f6e",children:[{value:"9.26.5.1 \u6dfb\u52a0 \u672c\u5730\u53d1\u5e03",id:"92651-\u6dfb\u52a0-\u672c\u5730\u53d1\u5e03",children:[]},{value:"9.26.5.2 \u9009\u62e9 \u5206\u53d1\u670d\u52a1\u5668",id:"92652-\u9009\u62e9-\u5206\u53d1\u670d\u52a1\u5668",children:[]},{value:"9.26.5.3 \u542f\u7528 \u4ee3\u7406",id:"92653-\u542f\u7528-\u4ee3\u7406",children:[]},{value:"9.26.5.4 \u53d1\u5e03\u6570\u636e\u5e93",id:"92654-\u53d1\u5e03\u6570\u636e\u5e93",children:[]},{value:"9.26.5.5 \u5feb\u7167\u53d1\u5e03",id:"92655-\u5feb\u7167\u53d1\u5e03",children:[]},{value:"9.26.5.6 \u9009\u62e9\u53d1\u5e03\u9879\u76ee",id:"92656-\u9009\u62e9\u53d1\u5e03\u9879\u76ee",children:[]},{value:"9.26.5.7 \u914d\u7f6e\u5206\u53d1\u8ba1\u5212",id:"92657-\u914d\u7f6e\u5206\u53d1\u8ba1\u5212",children:[]},{value:"9.26.5.8 \u914d\u7f6e\u5b89\u5168\u8bbe\u7f6e",id:"92658-\u914d\u7f6e\u5b89\u5168\u8bbe\u7f6e",children:[]},{value:"9.26.5.9 \u5b8c\u6210\u914d\u7f6e",id:"92659-\u5b8c\u6210\u914d\u7f6e",children:[]}]},{value:"9.26.6 SqlServer \u4ece\u5e93\u914d\u7f6e",id:"9266-sqlserver-\u4ece\u5e93\u914d\u7f6e",children:[{value:"9.26.6.1 \u6dfb\u52a0 \u672c\u5730\u8ba2\u9605",id:"92661-\u6dfb\u52a0-\u672c\u5730\u8ba2\u9605",children:[]},{value:"9.26.6.2 \u9009\u62e9 \u5206\u53d1\u670d\u52a1\u5668",id:"92662-\u9009\u62e9-\u5206\u53d1\u670d\u52a1\u5668",children:[]},{value:"9.26.6.3 \u9009\u62e9 \u5206\u53d1\u4ee3\u7406\u4f4d\u7f6e",id:"92663-\u9009\u62e9-\u5206\u53d1\u4ee3\u7406\u4f4d\u7f6e",children:[]},{value:"9.26.6.4 \u9009\u62e9 \u8ba2\u9605\u6570\u636e\u5e93",id:"92664-\u9009\u62e9-\u8ba2\u9605\u6570\u636e\u5e93",children:[]},{value:"9.26.6.5 \u9009\u62e9 \u5206\u53d1\u5b89\u5168\u8bbe\u7f6e",id:"92665-\u9009\u62e9-\u5206\u53d1\u5b89\u5168\u8bbe\u7f6e",children:[]},{value:"9.26.6.6 \u9009\u62e9 \u540c\u6b65\u8ba1\u5212",id:"92666-\u9009\u62e9-\u540c\u6b65\u8ba1\u5212",children:[]},{value:"9.26.6.7 \u5b8c\u6210\u8ba2\u9605",id:"92667-\u5b8c\u6210\u8ba2\u9605",children:[]}]},{value:"9.26.7 \u5206\u53d1\u5b9a\u4e49\u76d1\u89c6",id:"9267-\u5206\u53d1\u5b9a\u4e49\u76d1\u89c6",children:[]},{value:"9.26.8 \u67e5\u770b\u4e3b\u4ece\u590d\u5236\u7ed3\u679c",id:"9268-\u67e5\u770b\u4e3b\u4ece\u590d\u5236\u7ed3\u679c",children:[]},{value:"9.26.9 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9269-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],l={rightToc:s};function d(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(c.b)("wrapper",Object(a.a)({},l,t,{components:n,mdxType:"MDXLayout"}),Object(c.b)("h2",{id:"9261-\u8bfb\u5199\u5206\u79bb"},"9.26.1 \u8bfb\u5199\u5206\u79bb"),Object(c.b)("p",null,"\u5176\u5b9e\u5c31\u662f\u5c06\u6570\u636e\u5e93\u5206\u4e3a\u4e86\u4e3b\u4ece\u5e93\uff0c\u4e00\u4e2a\u4e3b\u5e93\u7528\u4e8e\u5199\u6570\u636e\uff0c\u591a\u4e2a\u4ece\u5e93\u5b8c\u6210\u8bfb\u6570\u636e\u7684\u64cd\u4f5c\uff0c\u4e3b\u4ece\u5e93\u4e4b\u95f4\u901a\u8fc7\u67d0\u79cd\u673a\u5236\u8fdb\u884c\u6570\u636e\u7684\u540c\u6b65\uff0c\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u6570\u636e\u5e93\u67b6\u6784\u3002"),Object(c.b)("img",{src:Object(i.a)("img/readwrite.png"),style:{height:300}}),Object(c.b)("h3",{id:"92611-\u89e3\u51b3\u4e86\u4ec0\u4e48\u95ee\u9898"},"9.26.1.1 \u89e3\u51b3\u4e86\u4ec0\u4e48\u95ee\u9898"),Object(c.b)("p",null,"\u5927\u591a\u6570\u4e92\u8054\u7f51\u4e1a\u52a1\uff0c\u5f80\u5f80\u8bfb\u591a\u5199\u5c11\uff0c\u8fd9\u65f6\u5019\uff0c\u6570\u636e\u5e93\u7684\u8bfb\u4f1a\u9996\u5148\u6210\u4e3a\u6570\u636e\u5e93\u7684\u74f6\u9888\uff0c\u8fd9\u65f6\uff0c\u5982\u679c\u6211\u4eec\u5e0c\u671b\u80fd\u591f\u7ebf\u6027\u7684\u63d0\u5347\u6570\u636e\u5e93\u7684\u8bfb\u6027\u80fd\uff0c\u6d88\u9664\u8bfb\u5199\u9501\u51b2\u7a81\u4ece\u800c\u63d0\u5347\u6570\u636e\u5e93\u7684\u5199\u6027\u80fd\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u4f7f\u7528\u201c\u5206\u7ec4\u67b6\u6784\u201d\uff08\u8bfb\u5199\u5206\u79bb\u67b6\u6784\uff09\u3002"),Object(c.b)("p",null,"\u7528\u4e00\u53e5\u8bdd\u6982\u62ec\uff0c\u8bfb\u5199\u5206\u79bb\u662f\u7528\u6765\u89e3\u51b3\u6570\u636e\u5e93\u7684\u8bfb\u6027\u80fd\u74f6\u9888\u7684\u3002"),Object(c.b)("h3",{id:"92612-\u6ce8\u610f\u4e8b\u9879"},"9.26.1.2 \u6ce8\u610f\u4e8b\u9879"),Object(c.b)("ul",null,Object(c.b)("li",{parentName:"ul"},"\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u8981\u8fdb\u884c\u533a\u5206\uff0c\u54ea\u4e9b\u662f\u8bfb\u8fde\u63a5\u6c60\uff0c\u54ea\u4e2a\u662f\u5199\u8fde\u63a5\u6c60\uff0c\u7814\u53d1\u7684\u96be\u5ea6\u4f1a\u589e\u52a0\uff1b"),Object(c.b)("li",{parentName:"ul"},"\u4e3a\u4e86\u4fdd\u8bc1\u9ad8\u53ef\u7528\uff0c\u8bfb\u8fde\u63a5\u6c60\u8981\u80fd\u591f\u5b9e\u73b0\u6545\u969c\u81ea\u52a8\u8f6c\u79fb\uff1b"),Object(c.b)("li",{parentName:"ul"},"\u4e3b\u4ece\u7684\u4e00\u81f4\u6027\u95ee\u9898\u9700\u8981\u8003\u8651\u3002")),Object(c.b)("h2",{id:"9262-\u5982\u4f55\u5b9e\u73b0"},"9.26.2 \u5982\u4f55\u5b9e\u73b0"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"Fur")," \u5728\u6570\u636e\u5e93\u6a21\u5757\u8bbe\u8ba1\u4e4b\u521d\uff0c\u5c31\u8003\u8651\u4e86\u8bfb\u5199\u5206\u79bb\u8fd9\u79cd\u60c5\u51b5\uff0c\u6240\u4ee5\u4ece\u5e95\u5c42\u5c31\u652f\u6301\u52a8\u6001\u5207\u6362\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u53ca\u8bfb\u5199\u64cd\u4f5c\u65b9\u6cd5\u7ea6\u675f\u3002"),Object(c.b)("p",null,"\u8bfb\u5199\u5206\u79bb\u64cd\u4f5c\u4e3b\u8981\u4f7f\u7528 ",Object(c.b)("inlineCode",{parentName:"p"},"IMSRepository")," \u4ed3\u50a8\uff0c\u8be5\u4ed3\u50a8\u5df2\u7ecf\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u65b9\u4fbf\u7684\u64cd\u4f5c\u8c03\u7528\u3002\u5f53\u7136\u4e5f\u53ef\u4ee5\u4e0d\u4f7f\u7528\u8be5\u4ed3\u50a8\u3002"),Object(c.b)("p",null,"\u4e0b\u9762\u5c31\u7ed9\u5927\u5bb6\u6f14\u793a\u5982\u4f55\u8bfb\u5199\u591a\u5e93\u8bfb\u5199\u64cd\u4f5c\u3002"),Object(c.b)("h3",{id:"92621-\u521b\u5efa-\u4e3b\u5e93-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"9.26.2.1 \u521b\u5efa ",Object(c.b)("inlineCode",{parentName:"h3"},"\u4e3b\u5e93")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n /// \n /// \u4e3b\u5e93\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\n /// \n [AppDbContext("MasterConnectionString")]\n public class MasterDbContext : AppDbContext\n {\n public MasterDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(c.b)("p",null,Object(c.b)("strong",{parentName:"p"},"\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\uff1a")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json"}),'{\n "ConnectionStrings": {\n "MasterConnectionString": "Server=localhost;Database=Fur;User=sa;Password=000000;MultipleActiveResultSets=True;"\n }\n}\n')),Object(c.b)("h3",{id:"92622-\u521b\u5efa-\u4ece\u5e93-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"9.26.2.2 \u521b\u5efa ",Object(c.b)("inlineCode",{parentName:"h3"},"\u4ece\u5e93")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{11}","{11}":!0}),'using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n /// \n /// \u4ece\u5e93\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\n /// \n [AppDbContext("SlaveConnectionString")]\n public class SlaveDbContext : AppDbContext\n {\n public SlaveDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(c.b)("div",{className:"admonition admonition-important alert alert--info"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u591a\u6570\u636e\u5e93\u64cd\u4f5c\u9664\u4e86\u9ed8\u8ba4\u6570\u636e\u5e93\u65e0\u9700\u81ea\u5b9a\u4e49 ",Object(c.b)("strong",{parentName:"p"},"\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668"),"\uff0c\u5176\u4ed6\u6570\u636e\u5e93\u90fd\u9700\u8981\u6709\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u3002\u5982 ",Object(c.b)("inlineCode",{parentName:"p"},"SlaveDbContextLocator")))),Object(c.b)("p",null,Object(c.b)("strong",{parentName:"p"},"\u4ece\u5e93\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\uff1a")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8}","{8}":!0}),"using Fur.DatabaseAccessor;\n\nnamespace Fur.Core\n{\n /// \n /// \u4ece\u5e93\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\n /// \n public class SlaveDbContextLocator : IDbContextLocator\n {\n }\n}\n")),Object(c.b)("p",null,Object(c.b)("strong",{parentName:"p"},"\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\uff1a")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json"}),'{\n "ConnectionStrings": {\n "SlaveConnectionString": "Server=localhost;Database=FurSlave;User=sa;Password=000000;MultipleActiveResultSets=True;"\n }\n}\n')),Object(c.b)("h3",{id:"92623-\u6ce8\u518c-\u4e3b\u4ece\u5e93-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"9.26.2.3 \u6ce8\u518c ",Object(c.b)("inlineCode",{parentName:"h3"},"\u4e3b\u4ece\u5e93")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{13-14}","{13-14}":!0}),"using Fur.Core;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(600)]\n public sealed class FurEntityFrameworkCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddDatabaseAccessor(options =>\n {\n services.AddSqlServerPool();\n services.AddSqlServerPool();\n });\n }\n }\n}\n")),Object(c.b)("h3",{id:"92624-\u521b\u5efa-person-\u5b9e\u4f53"},"9.26.2.4 \u521b\u5efa ",Object(c.b)("inlineCode",{parentName:"h3"},"Person")," \u5b9e\u4f53"),Object(c.b)("p",null,"\u7531\u4e8e ",Object(c.b)("inlineCode",{parentName:"p"},"\u4e3b\u4ece\u5e93")," \u5177\u6709\u76f8\u540c\u7684\u6570\u636e\u5e93\u7ed3\u6784\uff0c\u6240\u4ee5\u5b9e\u4f53\u4e5f\u5fc5\u987b\u58f0\u660e ",Object(c.b)("inlineCode",{parentName:"p"},"\u4e3b\u4ece\u5e93"),"\uff1a"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7}","{7}":!0}),"using Fur.DatabaseAccessor;\nusing System.ComponentModel.DataAnnotations;\nusing System.ComponentModel.DataAnnotations.Schema;\n\nnamespace Fur.Core\n{\n public class Person : IEntity\n {\n /// \n /// \u4e3b\u952eId\n /// \n [Key]\n [DatabaseGenerated(DatabaseGeneratedOption.Identity)]\n public int Id { get; set; }\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n }\n}\n")),Object(c.b)("h3",{id:"92625-\u5c06-person-\u8f6c\u6362\u6210\u6570\u636e\u5e93\u8868"},"9.26.2.5 \u5c06 ",Object(c.b)("inlineCode",{parentName:"h3"},"Person")," \u8f6c\u6362\u6210\u6570\u636e\u5e93\u8868"),Object(c.b)("p",null,Object(c.b)("strong",{parentName:"p"},"\u521b\u5efa\u4e3b\u5e93\u6570\u636e\u5e93\u8868\uff1a")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Add-Migration v0.0.1 -Context MasterDbContext\n")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database -Context MasterDbContext\n")),Object(c.b)("p",null,Object(c.b)("strong",{parentName:"p"},"\u521b\u5efa\u4ece\u5e93\u6570\u636e\u5e93\u8868\uff1a")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Add-Migration v0.0.1 -Context SlaveDbContext\n")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database -Context SlaveDbContext\n")),Object(c.b)("img",{src:Object(i.a)("img/readwrite1.png")}),Object(c.b)("img",{src:Object(i.a)("img/readwrite2.png")}),Object(c.b)("h3",{id:"92626-\u4f7f\u7528\u4f8b\u5b50"},"9.26.2.6 \u4f7f\u7528\u4f8b\u5b50"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{13,19,31,40}","{13,19,31,40}":!0}),'using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing Fur.DynamicApiController;\nusing System.Collections.Generic;\n\nnamespace Fur.Application\n{\n public class PersonService : IDynamicApiController\n {\n /// \n /// \u53ef\u8c03\u914d\u4ed3\u50a8\uff08\u8bfb\u5199\u5206\u79bb\uff09\n /// \n private readonly IMSRepository _msRepository;\n\n /// \n /// \u6784\u9020\u51fd\u6570\u521d\u59cb\u5316\n /// \n /// \n public PersonService(IMSRepository msRepository)\n {\n _msRepository = msRepository;\n }\n\n /// \n /// \u65b0\u589e\u8d70\u4e3b\u5e93\n /// \n /// \n /// \n public void Insert(Person person)\n {\n _msRepository.Master().Insert(person);\n }\n\n /// \n /// \u67e5\u8be2\u8d70\u4ece\u5e93\n /// \n /// \n public List Get()\n {\n return _msRepository.Slave1().AsEnumerable();\n }\n }\n}\n')),Object(c.b)("h2",{id:"9263-\u4e3b\u4ece\u590d\u5236"},"9.26.3 \u4e3b\u4ece\u590d\u5236"),Object(c.b)("p",null,"\u4e3b\u4ece\u590d\u5236\uff1a\u662f\u4e00\u79cd\u6570\u636e\u5907\u4efd\u7684\u65b9\u6848\u3002"),Object(c.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u662f\u4f7f\u7528\u4e24\u4e2a\u6216\u4e24\u4e2a\u4ee5\u4e0a\u76f8\u540c\u7684\u6570\u636e\u5e93\uff0c\u5c06\u4e00\u4e2a\u6570\u636e\u5e93\u5f53\u505a\u4e3b\u6570\u636e\u5e93\uff0c\u800c\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u5f53\u505a\u4ece\u6570\u636e\u5e93\u3002",Object(c.b)("strong",{parentName:"p"},"\u5728\u4e3b\u6570\u636e\u5e93\u4e2d\u8fdb\u884c\u76f8\u5e94\u64cd\u4f5c\u65f6\uff0c\u4ece\u6570\u636e\u5e93\u8bb0\u5f55\u4e0b\u6240\u6709\u4e3b\u6570\u636e\u5e93\u7684\u64cd\u4f5c\uff0c\u4f7f\u5176\u4e8c\u8005\u4e00\u6a21\u4e00\u6837\u3002")),Object(c.b)("h2",{id:"9264-\u4e3b\u4ece\u590d\u5236\u51e0\u79cd\u65b9\u5f0f"},"9.26.4 \u4e3b\u4ece\u590d\u5236\u51e0\u79cd\u65b9\u5f0f"),Object(c.b)("h3",{id:"92641-\u540c\u6b65\u590d\u5236"},"9.26.4.1 \u540c\u6b65\u590d\u5236"),Object(c.b)("p",null,"\u6240\u8c13\u7684\u540c\u6b65\u590d\u5236\uff0c\u610f\u601d\u662f ",Object(c.b)("inlineCode",{parentName:"p"},"Master")," \u7684\u53d8\u5316\uff0c\u5fc5\u987b\u7b49\u5f85 ",Object(c.b)("inlineCode",{parentName:"p"},"Slave-1\uff0cSlave-2\uff0c...\uff0cSlave-n")," \u5b8c\u6210\u540e\u624d\u80fd\u8fd4\u56de\u3002\n\u8fd9\u6837\uff0c\u663e\u7136\u4e0d\u53ef\u53d6\uff0c\u6bd4\u5982\uff0c\u5728 ",Object(c.b)("inlineCode",{parentName:"p"},"Web")," \u524d\u7aef\u9875\u9762\u4e0a\uff0c\u7528\u6237\u589e\u52a0\u4e86\u6761\u8bb0\u5f55\uff0c\u9700\u8981\u7b49\u5f85\u5f88\u957f\u65f6\u95f4\u3002"),Object(c.b)("h3",{id:"92642-\u5f02\u6b65\u590d\u5236"},"9.26.4.2 \u5f02\u6b65\u590d\u5236"),Object(c.b)("p",null,"\u5982\u540c AJAX \u8bf7\u6c42\u4e00\u6837\u3002",Object(c.b)("inlineCode",{parentName:"p"},"Master")," \u53ea\u9700\u8981\u5b8c\u6210\u81ea\u5df1\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u5373\u53ef\u3002\u81f3\u4e8e ",Object(c.b)("inlineCode",{parentName:"p"},"Slaves")," \u662f\u5426\u6536\u5230\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff0c\u662f\u5426\u5b8c\u6210\u64cd\u4f5c\uff0c\u4e0d\u7528\u5173\u5fc3\u3002",Object(c.b)("strong",{parentName:"p"},"\uff08\u63a8\u8350\u65b9\u5f0f\uff09")),Object(c.b)("h3",{id:"92643-\u534a\u540c\u6b65\u590d\u5236"},"9.26.4.3 \u534a\u540c\u6b65\u590d\u5236"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"Master")," \u53ea\u4fdd\u8bc1 ",Object(c.b)("inlineCode",{parentName:"p"},"Slaves")," \u4e2d\u7684\u4e00\u4e2a\u64cd\u4f5c\u6210\u529f\uff0c\u5c31\u8fd4\u56de\uff0c\u5176\u4ed6 ",Object(c.b)("inlineCode",{parentName:"p"},"Slave")," \u4e0d\u7ba1\u3002"),Object(c.b)("p",null,"\u4e0b\u9762\u5c06\u4f7f\u7528 ",Object(c.b)("inlineCode",{parentName:"p"},"SqlServer")," \u7b80\u5355\u914d\u7f6e\u4e3b\u4ece\u590d\u5236\u529f\u80fd\u3002"),Object(c.b)("h2",{id:"9265-sqlserver-\u4e3b\u5e93\u914d\u7f6e"},"9.26.5 ",Object(c.b)("inlineCode",{parentName:"h2"},"SqlServer")," \u4e3b\u5e93\u914d\u7f6e"),Object(c.b)("h3",{id:"92651-\u6dfb\u52a0-\u672c\u5730\u53d1\u5e03"},"9.26.5.1 \u6dfb\u52a0 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u672c\u5730\u53d1\u5e03")),Object(c.b)("img",{src:Object(i.a)("img/dbcopy1.png")}),Object(c.b)("h3",{id:"92652-\u9009\u62e9-\u5206\u53d1\u670d\u52a1\u5668"},"9.26.5.2 \u9009\u62e9 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u5206\u53d1\u670d\u52a1\u5668")),Object(c.b)("img",{src:Object(i.a)("img/dbcopy2.png")}),Object(c.b)("h3",{id:"92653-\u542f\u7528-\u4ee3\u7406"},"9.26.5.3 \u542f\u7528 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u4ee3\u7406")),Object(c.b)("img",{src:Object(i.a)("img/dbcopy3.png")}),Object(c.b)("h3",{id:"92654-\u53d1\u5e03\u6570\u636e\u5e93"},"9.26.5.4 \u53d1\u5e03\u6570\u636e\u5e93"),Object(c.b)("img",{src:Object(i.a)("img/dbcopy4.png")}),Object(c.b)("h3",{id:"92655-\u5feb\u7167\u53d1\u5e03"},"9.26.5.5 \u5feb\u7167\u53d1\u5e03"),Object(c.b)("img",{src:Object(i.a)("img/dbcopy5.png")}),Object(c.b)("p",null,"\u5177\u4f53\u9009\u62e9\u4f55\u79cd\u53d1\u5e03\u7c7b\u578b\uff0c\u89c6\u5177\u4f53\u4e1a\u52a1\u573a\u666f\u800c\u5b9a\u3002"),Object(c.b)("h3",{id:"92656-\u9009\u62e9\u53d1\u5e03\u9879\u76ee"},"9.26.5.6 \u9009\u62e9\u53d1\u5e03\u9879\u76ee"),Object(c.b)("img",{src:Object(i.a)("img/dbcopy6.png")}),Object(c.b)("h3",{id:"92657-\u914d\u7f6e\u5206\u53d1\u8ba1\u5212"},"9.26.5.7 \u914d\u7f6e\u5206\u53d1\u8ba1\u5212"),Object(c.b)("img",{src:Object(i.a)("img/dbcopy7.png")}),Object(c.b)("img",{src:Object(i.a)("img/dbcopy8.png")}),Object(c.b)("h3",{id:"92658-\u914d\u7f6e\u5b89\u5168\u8bbe\u7f6e"},"9.26.5.8 \u914d\u7f6e\u5b89\u5168\u8bbe\u7f6e"),Object(c.b)("img",{src:Object(i.a)("img/dbcopy9.png")}),Object(c.b)("img",{src:Object(i.a)("img/dbcopy10.png")}),Object(c.b)("h3",{id:"92659-\u5b8c\u6210\u914d\u7f6e"},"9.26.5.9 \u5b8c\u6210\u914d\u7f6e"),Object(c.b)("img",{src:Object(i.a)("img/dbcopy11.png")}),Object(c.b)("img",{src:Object(i.a)("img/dbcopy12.png")}),Object(c.b)("h2",{id:"9266-sqlserver-\u4ece\u5e93\u914d\u7f6e"},"9.26.6 ",Object(c.b)("inlineCode",{parentName:"h2"},"SqlServer")," \u4ece\u5e93\u914d\u7f6e"),Object(c.b)("h3",{id:"92661-\u6dfb\u52a0-\u672c\u5730\u8ba2\u9605"},"9.26.6.1 \u6dfb\u52a0 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u672c\u5730\u8ba2\u9605")),Object(c.b)("img",{src:Object(i.a)("img/dbrece1.png")}),Object(c.b)("h3",{id:"92662-\u9009\u62e9-\u5206\u53d1\u670d\u52a1\u5668"},"9.26.6.2 \u9009\u62e9 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u5206\u53d1\u670d\u52a1\u5668")),Object(c.b)("img",{src:Object(i.a)("img/dbrece2.png")}),Object(c.b)("h3",{id:"92663-\u9009\u62e9-\u5206\u53d1\u4ee3\u7406\u4f4d\u7f6e"},"9.26.6.3 \u9009\u62e9 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u5206\u53d1\u4ee3\u7406\u4f4d\u7f6e")),Object(c.b)("img",{src:Object(i.a)("img/dbrece3.png")}),Object(c.b)("h3",{id:"92664-\u9009\u62e9-\u8ba2\u9605\u6570\u636e\u5e93"},"9.26.6.4 \u9009\u62e9 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u8ba2\u9605\u6570\u636e\u5e93")),Object(c.b)("img",{src:Object(i.a)("img/dbrece4.png")}),Object(c.b)("h3",{id:"92665-\u9009\u62e9-\u5206\u53d1\u5b89\u5168\u8bbe\u7f6e"},"9.26.6.5 \u9009\u62e9 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u5206\u53d1\u5b89\u5168\u8bbe\u7f6e")),Object(c.b)("img",{src:Object(i.a)("img/dbrece5.png")}),Object(c.b)("img",{src:Object(i.a)("img/dbrece6.png")}),Object(c.b)("h3",{id:"92666-\u9009\u62e9-\u540c\u6b65\u8ba1\u5212"},"9.26.6.6 \u9009\u62e9 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u540c\u6b65\u8ba1\u5212")),Object(c.b)("img",{src:Object(i.a)("img/dbrece7.png")}),Object(c.b)("h3",{id:"92667-\u5b8c\u6210\u8ba2\u9605"},"9.26.6.7 \u5b8c\u6210\u8ba2\u9605"),Object(c.b)("img",{src:Object(i.a)("img/dbrece8.png")}),Object(c.b)("h2",{id:"9267-\u5206\u53d1\u5b9a\u4e49\u76d1\u89c6"},"9.26.7 \u5206\u53d1\u5b9a\u4e49\u76d1\u89c6"),Object(c.b)("img",{src:Object(i.a)("img/dbrece9.png")}),Object(c.b)("h2",{id:"9268-\u67e5\u770b\u4e3b\u4ece\u590d\u5236\u7ed3\u679c"},"9.26.8 \u67e5\u770b\u4e3b\u4ece\u590d\u5236\u7ed3\u679c"),Object(c.b)("img",{src:Object(i.a)("img/dbrece10.png")}),Object(c.b)("img",{src:Object(i.a)("img/dbrece11.png")}),Object(c.b)("div",{className:"admonition admonition-important alert alert--info"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u7279\u6027")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},'\u4e3b\u4ece\u590d\u5236\u6709\u4e00\u5b9a\u8fdf\u5ef6\u6027\uff0c\u6240\u4ee5\u7cfb\u7edf\u8bbe\u8ba1\u8981\u6709\u4e00\u5b9a\u201c\u5bb9\u5fcd\u6027"\u3002'))),Object(c.b)("h2",{id:"9269-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.26.9 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/4e3694ae.befe978c.js b/handbook/build/4e3694ae.befe978c.js deleted file mode 100644 index ff9403b7ce2..00000000000 --- a/handbook/build/4e3694ae.befe978c.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[30],{86:function(o){o.exports=JSON.parse('{"allTagsPath":"/blog/tags","slug":"furos","name":"furos","count":1,"permalink":"/blog/tags/furos"}')}}]); \ No newline at end of file diff --git a/handbook/build/4efad03e.7367e18f.js b/handbook/build/4efad03e.7367e18f.js new file mode 100644 index 00000000000..d62ee129756 --- /dev/null +++ b/handbook/build/4efad03e.7367e18f.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[32],{88:function(o){o.exports=JSON.parse('{"permalink":"/fur/blog","page":1,"postsPerPage":10,"totalPages":1,"totalCount":1,"previousPage":null,"nextPage":null,"blogDescription":"Blog"}')}}]); \ No newline at end of file diff --git a/handbook/build/525b9089.4330aea1.js b/handbook/build/525b9089.4330aea1.js new file mode 100644 index 00000000000..c013aa0f3de --- /dev/null +++ b/handbook/build/525b9089.4330aea1.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[33],{89:function(a){a.exports=JSON.parse('{"allTagsPath":"/fur/blog/tags","slug":"fur","name":"fur","count":1,"permalink":"/fur/blog/tags/fur"}')}}]); \ No newline at end of file diff --git a/handbook/build/59d16f51.61813dfb.js b/handbook/build/59d16f51.61813dfb.js deleted file mode 100644 index 52d993047f0..00000000000 --- a/handbook/build/59d16f51.61813dfb.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[31],{142:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return m}));var r=n(0),a=n.n(r);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var b=a.a.createContext({}),s=function(e){var t=a.a.useContext(b),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},u=function(e){var t=s(e.components);return a.a.createElement(b.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},p=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,o=e.originalType,i=e.parentName,b=l(e,["components","mdxType","originalType","parentName"]),u=s(n),p=r,m=u["".concat(i,".").concat(p)]||u[p]||d[p]||o;return n?a.a.createElement(m,c(c({ref:t},b),{},{components:n})):a.a.createElement(m,c({ref:t},b))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var o=n.length,i=new Array(o);i[0]=p;var c={};for(var l in t)hasOwnProperty.call(t,l)&&(c[l]=t[l]);c.originalType=e,c.mdxType="string"==typeof e?e:r,i[1]=c;for(var b=2;bFur \u652f\u6301\u6570\u636e\u5e93\u63d0\u4f9b\u5668",id:"9181-fur-\u652f\u6301\u6570\u636e\u5e93\u63d0\u4f9b\u5668",children:[{value:"9.18.1.1 \u6570\u636e\u5e93\u63d0\u4f9b\u5668\u5bf9\u5e94\u5305",id:"91811-\u6570\u636e\u5e93\u63d0\u4f9b\u5668\u5bf9\u5e94\u5305",children:[]}]},{value:"9.18.2 \u591a\u6570\u636e\u5e93\u670d\u52a1\u6ce8\u518c",id:"9182-\u591a\u6570\u636e\u5e93\u670d\u52a1\u6ce8\u518c",children:[]},{value:"9.18.3 \u591a\u6570\u636e\u5e93\u4f7f\u7528\u65b9\u5f0f",id:"9183-\u591a\u6570\u636e\u5e93\u4f7f\u7528\u65b9\u5f0f",children:[{value:"9.18.3.1 \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f",id:"91831-\u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f",children:[]},{value:"9.18.3.2 \u975e\u6cdb\u578b\u4ed3\u50a8\u65b9\u5f0f",id:"91832-\u975e\u6cdb\u578b\u4ed3\u50a8\u65b9\u5f0f",children:[]},{value:"9.18.3.3 Sql \u4ed3\u50a8\u65b9\u5f0f",id:"91833-sql-\u4ed3\u50a8\u65b9\u5f0f",children:[]},{value:"9.18.3.4 \u5b9e\u4f53\u5b9a\u4e49\u65b9\u5f0f",id:"91834-\u5b9e\u4f53\u5b9a\u4e49\u65b9\u5f0f",children:[]},{value:"9.18.3.5 Linq \u51fd\u6570\u65b9\u5f0f",id:"91835-linq-\u51fd\u6570\u65b9\u5f0f",children:[]}]},{value:"9.18.4 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9184-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],b={rightToc:l};function s(e){var t=e.components,n=Object(a.a)(e,["components"]);return Object(o.b)("wrapper",Object(r.a)({},b,n,{components:t,mdxType:"MDXLayout"}),Object(o.b)("h2",{id:"9181-fur-\u652f\u6301\u6570\u636e\u5e93\u63d0\u4f9b\u5668"},"9.18.1 ",Object(o.b)("inlineCode",{parentName:"h2"},"Fur")," \u652f\u6301\u6570\u636e\u5e93\u63d0\u4f9b\u5668"),Object(o.b)("table",null,Object(o.b)("thead",{parentName:"table"},Object(o.b)("tr",{parentName:"thead"},Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"SqlServer"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Sqlite"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Cosmos"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"InMemoryDatabase"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"MySql"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"PostgreSQL"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Oracle"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Firebird"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Dm"))),Object(o.b)("tbody",{parentName:"table"},Object(o.b)("tr",{parentName:"tbody"},Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714")))),Object(o.b)("h3",{id:"91811-\u6570\u636e\u5e93\u63d0\u4f9b\u5668\u5bf9\u5e94\u5305"},"9.18.1.1 \u6570\u636e\u5e93\u63d0\u4f9b\u5668\u5bf9\u5e94\u5305"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"SqlServer"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.SqlServer")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Sqlite"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.Sqlite")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Cosmos"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.Cosmos")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"InMemoryDatabase"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.InMemory")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"MySql"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Pomelo.EntityFrameworkCore.MySql")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"PostgreSQL"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Npgsql.EntityFrameworkCore.PostgreSQL")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Oracle"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Citms.EntityFrameworkCore.Oracle")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Firebird"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"FirebirdSql.EntityFrameworkCore.Firebird")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Dm"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.Dm"))),Object(o.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(o.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u8fd9\u4e9b\u6570\u636e\u5e93\u5305\u5e94\u8be5\u5b89\u88c5\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u5c42\u3002"))),Object(o.b)("h2",{id:"9182-\u591a\u6570\u636e\u5e93\u670d\u52a1\u6ce8\u518c"},"9.18.2 \u591a\u6570\u636e\u5e93\u670d\u52a1\u6ce8\u518c"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// \u6ce8\u518c SqlServer\noptions.AddDbPool(DbProvider.SqlServer);\n\n// \u6ce8\u518c Sqlite\noptions.AddDbPool(DbProvider.Sqlite);\n\n// \u6ce8\u518c Cosmos\noptions.AddDbPool(DbProvider.Cosmos);\n\n// \u6ce8\u518c InMemoryDatabase\noptions.AddDbPool(DbProvider.InMemoryDatabase);\n\n// \u6ce8\u518c MySql\noptions.AddDbPool(DbProvider.MySql);\n\n// \u6ce8\u518c PostgreSQL\noptions.AddDbPool(DbProvider.Npgsql);\n\n// \u6ce8\u518c Oracle\noptions.AddDbPool(DbProvider.Oracle);\n\n// \u6ce8\u518c Firebird\noptions.AddDbPool(DbProvider.Firebird);\n\n// \u6ce8\u518c Dm\noptions.AddDbPool(DbProvider.Dm);\n")),Object(o.b)("h2",{id:"9183-\u591a\u6570\u636e\u5e93\u4f7f\u7528\u65b9\u5f0f"},"9.18.3 \u591a\u6570\u636e\u5e93\u4f7f\u7528\u65b9\u5f0f"),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u901a\u8fc7\u72ec\u521b\u7684 ",Object(o.b)("inlineCode",{parentName:"p"},"\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668")," \u5b9e\u73b0\u591a\u6570\u636e\u5e93\u7075\u6d3b\u64cd\u4f5c\u5207\u6362\u3002\u53ea\u9700\u8981\u4e3a\u6bcf\u4e00\u79cd\u6570\u636e\u5e93\u7ed1\u5b9a\u552f\u4e00\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u5373\u53ef\u3002"),Object(o.b)("p",null,"\u4ee5\u4e0b\u662f ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u652f\u6301\u591a\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u5b9e\u4f8b\uff1a"),Object(o.b)("h3",{id:"91831-\u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f"},"9.18.3.1 \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// \u5207\u6362\u5230 MSSQL \u64cd\u4f5c Person\u8868\nvar mssqlRepository = personRepository.Change();\n\n// \u5207\u6362\u5230 MySql \u64cd\u4f5c Person\u8868\nvar mysqlRepository = personRepository.Change();\n\n// \u5207\u6362\u5230 Sqlite \u64cd\u4f5c Person\u8868\nvar sqliteRepository = personRepository.Change();\n\n")),Object(o.b)("h3",{id:"91832-\u975e\u6cdb\u578b\u4ed3\u50a8\u65b9\u5f0f"},"9.18.3.2 \u975e\u6cdb\u578b\u4ed3\u50a8\u65b9\u5f0f"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// \u5207\u6362\u5230 MSSQL \u64cd\u4f5c Person\u8868\nvar mssqlRepository = repository.Change();\n\n// \u5207\u6362\u5230 MySql \u64cd\u4f5c Person\u8868\nvar mysqlRepository = repository.Change();\n\n// \u5207\u6362\u5230 Sqlite \u64cd\u4f5c Person\u8868\nvar sqliteRepository = repository.Change();\n")),Object(o.b)("h3",{id:"91833-sql-\u4ed3\u50a8\u65b9\u5f0f"},"9.18.3.3 ",Object(o.b)("inlineCode",{parentName:"h3"},"Sql")," \u4ed3\u50a8\u65b9\u5f0f"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// \u5207\u6362\u5230 MSSQL \u64cd\u4f5c Person\u8868\nvar mssqlRepository = sqlRepository.Change();\n\n// \u5207\u6362\u5230 MySql \u64cd\u4f5c Person\u8868\nvar mysqlRepository = sqlRepository.Change();\n\n// \u5207\u6362\u5230 Sqlite \u64cd\u4f5c Person\u8868\nvar sqliteRepository = sqlRepository.Change();\n")),Object(o.b)("h3",{id:"91834-\u5b9e\u4f53\u5b9a\u4e49\u65b9\u5f0f"},"9.18.3.4 \u5b9e\u4f53\u5b9a\u4e49\u65b9\u5f0f"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"\n// \u652f\u6301\u4e00\u4e2a\u6570\u636e\u5e93\npublic class Person: IEntity\n{\n // ....\n}\n\n// \u652f\u6301\u591a\u4e2a\u6570\u636e\u5e93\npublic class Person: IEntity\n{\n // ....\n}\n")),Object(o.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(o.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u6240\u6709\u7684 ",Object(o.b)("inlineCode",{parentName:"p"},"\u5b9e\u4f53\u4f9d\u8d56\u63a5\u53e3\u6216\u62bd\u8c61\u7c7b")," \u90fd\u652f\u6301\u6cdb\u578b\u65b9\u5f0f \u6307\u5b9a \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\uff0c\u6700\u591a\u652f\u6301 ",Object(o.b)("inlineCode",{parentName:"p"},"8")," \u4e2a\u3002"))),Object(o.b)("h3",{id:"91835-linq-\u51fd\u6570\u65b9\u5f0f"},"9.18.3.5 Linq \u51fd\u6570\u65b9\u5f0f"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'public static class QueryFunctions\n{\n [QueryableFunction("FN_GetId", "dbo", typeof(MySqlDbContextLocator), typeof(SqliteDbContextLocator))]\n public static int GetId(int id) => throw new NotSupportedException();\n}\n')),Object(o.b)("h2",{id:"9184-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.18.4 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(o.b)("a",Object(r.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}s.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/59d16f51.b99a9697.js b/handbook/build/59d16f51.b99a9697.js new file mode 100644 index 00000000000..3b53aa7bf64 --- /dev/null +++ b/handbook/build/59d16f51.b99a9697.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[34],{142:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return m}));var r=n(0),a=n.n(r);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var b=a.a.createContext({}),s=function(e){var t=a.a.useContext(b),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},u=function(e){var t=s(e.components);return a.a.createElement(b.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},p=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,o=e.originalType,i=e.parentName,b=l(e,["components","mdxType","originalType","parentName"]),u=s(n),p=r,m=u["".concat(i,".").concat(p)]||u[p]||d[p]||o;return n?a.a.createElement(m,c(c({ref:t},b),{},{components:n})):a.a.createElement(m,c({ref:t},b))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var o=n.length,i=new Array(o);i[0]=p;var c={};for(var l in t)hasOwnProperty.call(t,l)&&(c[l]=t[l]);c.originalType=e,c.mdxType="string"==typeof e?e:r,i[1]=c;for(var b=2;bFur \u652f\u6301\u6570\u636e\u5e93\u63d0\u4f9b\u5668",id:"9181-fur-\u652f\u6301\u6570\u636e\u5e93\u63d0\u4f9b\u5668",children:[{value:"9.18.1.1 \u6570\u636e\u5e93\u63d0\u4f9b\u5668\u5bf9\u5e94\u5305",id:"91811-\u6570\u636e\u5e93\u63d0\u4f9b\u5668\u5bf9\u5e94\u5305",children:[]}]},{value:"9.18.2 \u591a\u6570\u636e\u5e93\u670d\u52a1\u6ce8\u518c",id:"9182-\u591a\u6570\u636e\u5e93\u670d\u52a1\u6ce8\u518c",children:[]},{value:"9.18.3 \u591a\u6570\u636e\u5e93\u4f7f\u7528\u65b9\u5f0f",id:"9183-\u591a\u6570\u636e\u5e93\u4f7f\u7528\u65b9\u5f0f",children:[{value:"9.18.3.1 \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f",id:"91831-\u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f",children:[]},{value:"9.18.3.2 \u975e\u6cdb\u578b\u4ed3\u50a8\u65b9\u5f0f",id:"91832-\u975e\u6cdb\u578b\u4ed3\u50a8\u65b9\u5f0f",children:[]},{value:"9.18.3.3 Sql \u4ed3\u50a8\u65b9\u5f0f",id:"91833-sql-\u4ed3\u50a8\u65b9\u5f0f",children:[]},{value:"9.18.3.4 \u5b9e\u4f53\u5b9a\u4e49\u65b9\u5f0f",id:"91834-\u5b9e\u4f53\u5b9a\u4e49\u65b9\u5f0f",children:[]},{value:"9.18.3.5 Linq \u51fd\u6570\u65b9\u5f0f",id:"91835-linq-\u51fd\u6570\u65b9\u5f0f",children:[]}]},{value:"9.18.4 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9184-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],b={rightToc:l};function s(e){var t=e.components,n=Object(a.a)(e,["components"]);return Object(o.b)("wrapper",Object(r.a)({},b,n,{components:t,mdxType:"MDXLayout"}),Object(o.b)("h2",{id:"9181-fur-\u652f\u6301\u6570\u636e\u5e93\u63d0\u4f9b\u5668"},"9.18.1 ",Object(o.b)("inlineCode",{parentName:"h2"},"Fur")," \u652f\u6301\u6570\u636e\u5e93\u63d0\u4f9b\u5668"),Object(o.b)("table",null,Object(o.b)("thead",{parentName:"table"},Object(o.b)("tr",{parentName:"thead"},Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"SqlServer"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Sqlite"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Cosmos"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"InMemoryDatabase"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"MySql"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"PostgreSQL"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Oracle"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Firebird"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Dm"))),Object(o.b)("tbody",{parentName:"table"},Object(o.b)("tr",{parentName:"tbody"},Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714"),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"\u2714")))),Object(o.b)("h3",{id:"91811-\u6570\u636e\u5e93\u63d0\u4f9b\u5668\u5bf9\u5e94\u5305"},"9.18.1.1 \u6570\u636e\u5e93\u63d0\u4f9b\u5668\u5bf9\u5e94\u5305"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"SqlServer"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.SqlServer")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Sqlite"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.Sqlite")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Cosmos"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.Cosmos")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"InMemoryDatabase"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.InMemory")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"MySql"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Pomelo.EntityFrameworkCore.MySql")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"PostgreSQL"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Npgsql.EntityFrameworkCore.PostgreSQL")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Oracle"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Citms.EntityFrameworkCore.Oracle")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Firebird"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"FirebirdSql.EntityFrameworkCore.Firebird")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Dm"),"\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.Dm"))),Object(o.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(o.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u8fd9\u4e9b\u6570\u636e\u5e93\u5305\u5e94\u8be5\u5b89\u88c5\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u5c42\u3002"))),Object(o.b)("h2",{id:"9182-\u591a\u6570\u636e\u5e93\u670d\u52a1\u6ce8\u518c"},"9.18.2 \u591a\u6570\u636e\u5e93\u670d\u52a1\u6ce8\u518c"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// \u6ce8\u518c SqlServer\noptions.AddDbPool(DbProvider.SqlServer);\n\n// \u6ce8\u518c Sqlite\noptions.AddDbPool(DbProvider.Sqlite);\n\n// \u6ce8\u518c Cosmos\noptions.AddDbPool(DbProvider.Cosmos);\n\n// \u6ce8\u518c InMemoryDatabase\noptions.AddDbPool(DbProvider.InMemoryDatabase);\n\n// \u6ce8\u518c MySql\noptions.AddDbPool(DbProvider.MySql);\n\n// \u6ce8\u518c PostgreSQL\noptions.AddDbPool(DbProvider.Npgsql);\n\n// \u6ce8\u518c Oracle\noptions.AddDbPool(DbProvider.Oracle);\n\n// \u6ce8\u518c Firebird\noptions.AddDbPool(DbProvider.Firebird);\n\n// \u6ce8\u518c Dm\noptions.AddDbPool(DbProvider.Dm);\n")),Object(o.b)("h2",{id:"9183-\u591a\u6570\u636e\u5e93\u4f7f\u7528\u65b9\u5f0f"},"9.18.3 \u591a\u6570\u636e\u5e93\u4f7f\u7528\u65b9\u5f0f"),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u901a\u8fc7\u72ec\u521b\u7684 ",Object(o.b)("inlineCode",{parentName:"p"},"\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668")," \u5b9e\u73b0\u591a\u6570\u636e\u5e93\u7075\u6d3b\u64cd\u4f5c\u5207\u6362\u3002\u53ea\u9700\u8981\u4e3a\u6bcf\u4e00\u79cd\u6570\u636e\u5e93\u7ed1\u5b9a\u552f\u4e00\u7684\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u5373\u53ef\u3002"),Object(o.b)("p",null,"\u4ee5\u4e0b\u662f ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u652f\u6301\u591a\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u5b9e\u4f8b\uff1a"),Object(o.b)("h3",{id:"91831-\u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f"},"9.18.3.1 \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// \u5207\u6362\u5230 MSSQL \u64cd\u4f5c Person\u8868\nvar mssqlRepository = personRepository.Change();\n\n// \u5207\u6362\u5230 MySql \u64cd\u4f5c Person\u8868\nvar mysqlRepository = personRepository.Change();\n\n// \u5207\u6362\u5230 Sqlite \u64cd\u4f5c Person\u8868\nvar sqliteRepository = personRepository.Change();\n\n")),Object(o.b)("h3",{id:"91832-\u975e\u6cdb\u578b\u4ed3\u50a8\u65b9\u5f0f"},"9.18.3.2 \u975e\u6cdb\u578b\u4ed3\u50a8\u65b9\u5f0f"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// \u5207\u6362\u5230 MSSQL \u64cd\u4f5c Person\u8868\nvar mssqlRepository = repository.Change();\n\n// \u5207\u6362\u5230 MySql \u64cd\u4f5c Person\u8868\nvar mysqlRepository = repository.Change();\n\n// \u5207\u6362\u5230 Sqlite \u64cd\u4f5c Person\u8868\nvar sqliteRepository = repository.Change();\n")),Object(o.b)("h3",{id:"91833-sql-\u4ed3\u50a8\u65b9\u5f0f"},"9.18.3.3 ",Object(o.b)("inlineCode",{parentName:"h3"},"Sql")," \u4ed3\u50a8\u65b9\u5f0f"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// \u5207\u6362\u5230 MSSQL \u64cd\u4f5c Person\u8868\nvar mssqlRepository = sqlRepository.Change();\n\n// \u5207\u6362\u5230 MySql \u64cd\u4f5c Person\u8868\nvar mysqlRepository = sqlRepository.Change();\n\n// \u5207\u6362\u5230 Sqlite \u64cd\u4f5c Person\u8868\nvar sqliteRepository = sqlRepository.Change();\n")),Object(o.b)("h3",{id:"91834-\u5b9e\u4f53\u5b9a\u4e49\u65b9\u5f0f"},"9.18.3.4 \u5b9e\u4f53\u5b9a\u4e49\u65b9\u5f0f"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"\n// \u652f\u6301\u4e00\u4e2a\u6570\u636e\u5e93\npublic class Person: IEntity\n{\n // ....\n}\n\n// \u652f\u6301\u591a\u4e2a\u6570\u636e\u5e93\npublic class Person: IEntity\n{\n // ....\n}\n")),Object(o.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(o.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u6240\u6709\u7684 ",Object(o.b)("inlineCode",{parentName:"p"},"\u5b9e\u4f53\u4f9d\u8d56\u63a5\u53e3\u6216\u62bd\u8c61\u7c7b")," \u90fd\u652f\u6301\u6cdb\u578b\u65b9\u5f0f \u6307\u5b9a \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\uff0c\u6700\u591a\u652f\u6301 ",Object(o.b)("inlineCode",{parentName:"p"},"8")," \u4e2a\u3002"))),Object(o.b)("h3",{id:"91835-linq-\u51fd\u6570\u65b9\u5f0f"},"9.18.3.5 Linq \u51fd\u6570\u65b9\u5f0f"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'public static class QueryFunctions\n{\n [QueryableFunction("FN_GetId", "dbo", typeof(MySqlDbContextLocator), typeof(SqliteDbContextLocator))]\n public static int GetId(int id) => throw new NotSupportedException();\n}\n')),Object(o.b)("h2",{id:"9184-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.18.4 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(o.b)("a",Object(r.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}s.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/5c4ee1d6.84f4a477.js b/handbook/build/5c4ee1d6.84f4a477.js deleted file mode 100644 index d8bb237668e..00000000000 --- a/handbook/build/5c4ee1d6.84f4a477.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[32],{88:function(o){o.exports=JSON.parse('{"permalink":"/blog","page":1,"postsPerPage":10,"totalPages":1,"totalCount":1,"previousPage":null,"nextPage":null,"blogDescription":"Blog"}')}}]); \ No newline at end of file diff --git a/handbook/build/5ce0ebbd.4ab6a852.js b/handbook/build/5ce0ebbd.4ab6a852.js deleted file mode 100644 index 97437fef3e5..00000000000 --- a/handbook/build/5ce0ebbd.4ab6a852.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[33],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return s})),t.d(n,"b",(function(){return m}));var a=t(0),r=t.n(a);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function p(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function c(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var b=r.a.createContext({}),l=function(e){var n=r.a.useContext(b),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},s=function(e){var n=l(e.components);return r.a.createElement(b.Provider,{value:n},e.children)},u={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},d=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,i=e.originalType,p=e.parentName,b=o(e,["components","mdxType","originalType","parentName"]),s=l(t),d=a,m=s["".concat(p,".").concat(d)]||s[d]||u[d]||i;return t?r.a.createElement(m,c(c({ref:n},b),{},{components:t})):r.a.createElement(m,c({ref:n},b))}));function m(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var i=t.length,p=new Array(i);p[0]=d;var c={};for(var o in n)hasOwnProperty.call(n,o)&&(c[o]=n[o]);c.originalType=e,c.mdxType="string"==typeof e?e:a,p[1]=c;for(var b=2;bStartup \u7c7b",id:"31-startup-\u7c7b",children:[{value:"3.1.1 Startup \u4e24\u4e2a\u91cd\u8981\u65b9\u6cd5",id:"311-startup-\u4e24\u4e2a\u91cd\u8981\u65b9\u6cd5",children:[]}]},{value:"3.2 AppStartup",id:"32-appstartup",children:[{value:"3.2.1 \u5982\u4f55\u914d\u7f6e AppStartup",id:"321-\u5982\u4f55\u914d\u7f6e-appstartup",children:[]},{value:"3.2.2 AppStartup \u7ea6\u5b9a",id:"322-appstartup-\u7ea6\u5b9a",children:[]},{value:"3.2.3 AppStartup \u914d\u7f6e\u987a\u5e8f",id:"323-appstartup-\u914d\u7f6e\u987a\u5e8f",children:[]},{value:"3.2.4 AppStartup \u65b9\u6cd5\u8c03\u7528\u987a\u5e8f",id:"324-appstartup-\u65b9\u6cd5\u8c03\u7528\u987a\u5e8f",children:[]}]},{value:"3.3 \u6846\u67b6\u9ed8\u8ba4 AppStartup \u5b9e\u73b0",id:"33-\u6846\u67b6\u9ed8\u8ba4-appstartup-\u5b9e\u73b0",children:[]},{value:"3.4 Startup \u914d\u7f6e\u6700\u4f73\u5b9e\u8df5",id:"34-startup-\u914d\u7f6e\u6700\u4f73\u5b9e\u8df5",children:[]},{value:"3.5 \u5173\u4e8e appsettings.json",id:"35-\u5173\u4e8e-appsettingsjson",children:[]},{value:"3.6 \u795e\u5947\u7684 Inject()",id:"36-\u795e\u5947\u7684-inject",children:[]},{value:"3.7 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"37-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],b={rightToc:o};function l(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},b,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"31-startup-\u7c7b"},"3.1 ",Object(i.b)("inlineCode",{parentName:"h2"},"Startup")," \u7c7b"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Startup")," \u7c7b\u662f ",Object(i.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u9ed8\u8ba4\u8c03\u7528\u7684\u7c7b\uff0c\u8be5\u7c7b\u662f\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Program.cs")," \u4e2d\u914d\u7f6e\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{19} title="Fur.Web.Entry\\Program.cs"',"{19}":!0,title:'"Fur.Web.Entry\\Program.cs"'}),"using Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.Hosting;\n\nnamespace Fur.Web.Entry\n{\n public class Program\n {\n public static void Main(string[] args)\n {\n CreateHostBuilder(args).Build().Run();\n }\n\n public static IHostBuilder CreateHostBuilder(string[] args)\n {\n return Host.CreateDefaultBuilder(args)\n .ConfigureWebHostDefaults(webBuilder =>\n {\n webBuilder.Inject()\n .UseStartup();\n });\n }\n }\n}\n")),Object(i.b)("h3",{id:"311-startup-\u4e24\u4e2a\u91cd\u8981\u65b9\u6cd5"},"3.1.1 ",Object(i.b)("inlineCode",{parentName:"h3"},"Startup")," \u4e24\u4e2a\u91cd\u8981\u65b9\u6cd5"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Startup")," \u9ed8\u8ba4\u6709\u4e24\u4e2a\u91cd\u8981\u7684\u65b9\u6cd5:"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ConfigureServices"),"\uff1a\u914d\u7f6e\u5e94\u7528\u6240\u9700\u670d\u52a1\uff0c\u5728\u8be5\u65b9\u6cd5\u4e2d\u53ef\u4ee5\u6dfb\u52a0\u5e94\u7528\u6240\u9700\u8981\u7684\u529f\u80fd\u6216\u670d\u52a1"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Configure"),"\uff1a\u914d\u7f6e\u5e94\u7528\u8bf7\u6c42\u5904\u7406\u7ba1\u9053")),Object(i.b)("p",null,"\u9ed8\u8ba4\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{9,13} title="Fur.Web.Entry\\Startup.cs"',"{9,13}":!0,title:'"Fur.Web.Entry\\Startup.cs"'}),"using Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Entry\n{\n public class Startup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n }\n }\n}\n")),Object(i.b)("p",null,"\u5728\u8fd9\u91cc\uff0c\u4e0d\u6253\u7b97\u8be6\u7ec6\u8bb2 ",Object(i.b)("inlineCode",{parentName:"p"},"Startup")," \u7c7b\u7684\u5177\u4f53\u529f\u80fd\u548c\u4f5c\u7528\u3002"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(i.b)("inlineCode",{parentName:"p"},"Startup")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/startup?view=aspnetcore-3.1"}),"ASP.NET Core - Startup \u7c7b")," \u7ae0\u8282\u3002"))),Object(i.b)("h2",{id:"32-appstartup"},"3.2 ",Object(i.b)("inlineCode",{parentName:"h2"},"AppStartup")),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u63d0\u4f9b\u4e86\u66f4\u4e3a\u7075\u6d3b\u7684 ",Object(i.b)("inlineCode",{parentName:"p"},"Startup")," \u7c7b\u914d\u7f6e\u65b9\u5f0f\uff0c\u65e0\u9700\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Web \u542f\u7528\u5c42")," \u4e2d\u914d\u7f6e\uff0c\u53ef\u5c06\u914d\u7f6e\u653e\u5230\u4efb\u4f55\u9879\u76ee\u5c42\u3002"),Object(i.b)("p",null,"\u53ef\u80fd\u4f1a\u6709\u8bfb\u8005\u6709\u7591\u95ee\uff0c\u4e3a\u4ec0\u4e48\u8981\u591a\u6b64\u4e00\u4e3e\u5462\uff1f\u539f\u56e0\u6709\u51e0\u70b9\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Startup")," \u7c7b\u9ed8\u8ba4\u548c ",Object(i.b)("inlineCode",{parentName:"li"},"Web \u5e94\u7528\u5c42")," \u7ed1\u5b9a\u5728\u4e00\u8d77\uff0c\u8fd9\u6837\u5c31\u4f1a\u5bfc\u81f4\u5982\u679c\u6211\u521b\u5efa\u4e86\u65b0\u7684 ",Object(i.b)("inlineCode",{parentName:"li"},"Web \u5e94\u7528\u5c42"),"\uff0c",Object(i.b)("inlineCode",{parentName:"li"},"Startup")," \u53c8\u8981\u91cd\u65b0\u914d\u7f6e"),Object(i.b)("li",{parentName:"ul"},"\u968f\u7740\u4e1a\u52a1\u7684\u589e\u957f\uff0c\u9700\u8981\u96c6\u6210\u8d8a\u6765\u8d8a\u591a\u7684\u7b2c\u4e09\u65b9\u670d\u52a1\uff0c\u8fd9\u65f6\u5019 ",Object(i.b)("inlineCode",{parentName:"li"},"Startup")," \u7c7b\u5c31\u4f1a\u53d8\u5f97\u8d8a\u6765\u8d8a\u81c3\u80bf\uff0c\u96be\u4ee5\u7ef4\u62a4"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Startup")," \u7c7b\u65e0\u6cd5\u5176\u4ed6\u9879\u76ee\u7c7b\u578b\u8fdb\u884c\u5171\u7528")),Object(i.b)("p",null,"\u6240\u4ee5\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u4e86\u66f4\u52a0\u7075\u6d3b\u7684\u914d\u7f6e\u65b9\u5f0f\uff1a",Object(i.b)("inlineCode",{parentName:"p"},"AppStartup"),"\u3002"),Object(i.b)("h3",{id:"321-\u5982\u4f55\u914d\u7f6e-appstartup"},"3.2.1 \u5982\u4f55\u914d\u7f6e ",Object(i.b)("inlineCode",{parentName:"h3"},"AppStartup")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"AppStartup")," \u662f\u4e00\u4e2a\u62bd\u8c61\u7684\u7a7a\u7c7b\uff0c\u6ca1\u6709\u4efb\u4f55\u5b9a\u4e49\u6210\u5458\u3002\u6b63\u662f\u56e0\u4e3a\u8fd9\u6837\uff0c\u624d\u63d0\u4f9b\u66f4\u52a0\u7075\u6d3b\u7684\u914d\u7f6e\u65b9\u5f0f\u3002"),Object(i.b)("h3",{id:"322-appstartup-\u7ea6\u5b9a"},"3.2.2 ",Object(i.b)("inlineCode",{parentName:"h3"},"AppStartup")," \u7ea6\u5b9a"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"AppStartup")," \u6d3e\u751f\u7c7b\u53ea\u6709\u4e24\u4e2a\u5c0f\u7ea6\u5b9a\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u4efb\u4f55\u516c\u5f00\u3001\u975e\u9759\u6001\u3001\u8fd4\u56de\u503c\u4e3a ",Object(i.b)("inlineCode",{parentName:"li"},"void")," \u4e14\u65b9\u6cd5\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f ",Object(i.b)("inlineCode",{parentName:"li"},"IServiceCollection")," \u7c7b\u578b\uff0c\u90a3\u4e48\u4ed6\u5c31\u662f\u4e00\u4e2a ",Object(i.b)("inlineCode",{parentName:"li"},"ConfigureServices")," \u65b9\u6cd5"),Object(i.b)("li",{parentName:"ul"},"\u4efb\u4f55\u516c\u5f00\u3001\u975e\u9759\u6001\u3001\u8fd4\u56de\u503c\u4e3a ",Object(i.b)("inlineCode",{parentName:"li"},"void")," \u4e14\u65b9\u6cd5\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f ",Object(i.b)("inlineCode",{parentName:"li"},"IApplicationBuilder")," \u7c7b\u578b\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f ",Object(i.b)("inlineCode",{parentName:"li"},"IWebHostEnvironment")," \u7c7b\u578b\uff0c\u90a3\u4e48\u4ed6\u5c31\u662f\u4e00\u4e2a ",Object(i.b)("inlineCode",{parentName:"li"},"Configure")," \u65b9\u6cd5")),Object(i.b)("p",null,"\u6240\u4ee5\uff0c\u6211\u4eec\u53ef\u4ee5\u81ea\u7531\u7684\u7f16\u5199\u65b9\u6cd5\uff0c\u53ea\u8981\u9075\u5faa\u7ea6\u5b9a\u5373\u53ef\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,7,12,18,23}","{5,7,12,18,23}":!0}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n public class MyStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddDataValidation();\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n app.UseSwagger();\n }\n\n // \u53ef\u4ee5\u968f\u610f\u5b9a\u4e49\u540d\u5b57\u548c\u65b9\u6cd5\n public void XXXXName(IServiceCollection services)\n {\n }\n\n // \u53ef\u4ee5\u968f\u610f\u5b9a\u4e49\u540d\u5b57\u548c\u65b9\u6cd5\n public void ZZZName(IApplicationBuilder app, IWebHostEnvironment env)\n {\n }\n }\n}\n")),Object(i.b)("h3",{id:"323-appstartup-\u914d\u7f6e\u987a\u5e8f"},"3.2.3 ",Object(i.b)("inlineCode",{parentName:"h3"},"AppStartup")," \u914d\u7f6e\u987a\u5e8f"),Object(i.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"AppStartup")," \u914d\u7f6e\u987a\u5e8f\u7531\u6240\u5728\u7a0b\u5e8f\u96c6\u7684\u540d\u79f0\u8fdb\u884c\u6b63\u5e8f\u8c03\u7528\uff0c\u5982\u679c\u6211\u4eec\u9700\u8981\u914d\u7f6e\u6267\u884c\u987a\u5e8f\uff0c\u53ea\u9700\u8981\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"AppStartup")," \u6d3e\u751f\u7c7b\u4e2d\u8d34 ",Object(i.b)("inlineCode",{parentName:"p"},"[AppStartup(order)]")," \u7279\u6027\u5373\u53ef\u3002"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"order")," \u6570\u503c\u8d8a\u5927\uff0c\u8d8a\u5728\u524d\u9762\u8c03\u7528\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5}","{5}":!0}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(10)]\n public class FirstStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n }\n }\n}\n")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5}","{5}":!0}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(9)]\n public class SecondStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n }\n }\n}\n")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"FirstStartup")," \u4f1a\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"SecondStartup")," \u4e4b\u524d\u8c03\u7528\u3002"),Object(i.b)("h3",{id:"324-appstartup-\u65b9\u6cd5\u8c03\u7528\u987a\u5e8f"},"3.2.4 ",Object(i.b)("inlineCode",{parentName:"h3"},"AppStartup")," \u65b9\u6cd5\u8c03\u7528\u987a\u5e8f"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"AppStartup")," \u65b9\u6cd5\u8c03\u7528\u987a\u5e8f\u548c\u65b9\u6cd5\u7684\u4e66\u5199\u5148\u540e\u6709\u5173\uff0c\u8d8a\u5728\u524d\u9762\u7684\u65b9\u6cd5\u8d8a\u5148\u8c03\u7528\u3002"),Object(i.b)("h2",{id:"33-\u6846\u67b6\u9ed8\u8ba4-appstartup-\u5b9e\u73b0"},"3.3 \u6846\u67b6\u9ed8\u8ba4 ",Object(i.b)("inlineCode",{parentName:"h2"},"AppStartup")," \u5b9e\u73b0"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u9ed8\u8ba4\u5728\u6bcf\u4e00\u4e2a\u9879\u76ee\u5c42\u4e2d\u90fd\u521b\u5efa\u4e86\u4e00\u4e2a ",Object(i.b)("inlineCode",{parentName:"p"},"AppStartup")," \u6d3e\u751f\u7c7b\uff0c\u65b9\u4fbf\u5927\u5bb6\u914d\u7f6e\u3002\u5982\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"FurStartup.cs"),"\uff1a",Object(i.b)("inlineCode",{parentName:"li"},"Fur")," \u6846\u67b6\u6838\u5fc3\u542f\u52a8\u7c7b\uff08\u901a\u5e38\u65e0\u9700\u914d\u7f6e\uff09"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"FurApplicationStartup.cs"),"\uff1a\u4e1a\u52a1\u670d\u52a1\u542f\u52a8\u7c7b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"FurCoreStartup.cs"),"\uff1a\u5e94\u7528\u6838\u5fc3\u529f\u80fd\u542f\u52a8\u7c7b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"FurEntityFrameworkCoreStartup.cs"),"\uff1a\u6570\u636e\u5e93\u76f8\u5173\u542f\u52a8\u7c7b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"FurWebCoreStartup.cs"),"\uff1a",Object(i.b)("inlineCode",{parentName:"li"},"Web")," \u6838\u5fc3\u542f\u52a8\u914d\u7f6e\u7c7b")),Object(i.b)("h2",{id:"34-startup-\u914d\u7f6e\u6700\u4f73\u5b9e\u8df5"},"3.4 ",Object(i.b)("inlineCode",{parentName:"h2"},"Startup")," \u914d\u7f6e\u6700\u4f73\u5b9e\u8df5"),Object(i.b)("p",null,"\u5efa\u8bae ",Object(i.b)("inlineCode",{parentName:"p"},"Web")," \u542f\u52a8\u5c42\u7684 ",Object(i.b)("inlineCode",{parentName:"p"},"Startup.cs")," \u4fdd\u6301\u4e3a\u7a7a\u65b9\u6cd5\u4f53\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'title="Fur.Web.Entry\\Startup.cs"',title:'"Fur.Web.Entry\\Startup.cs"'}),"using Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Entry\n{\n public class Startup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n }\n }\n}\n")),Object(i.b)("p",null,"\u5c06\u6240\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"Web \u5e94\u7528\u5c42")," \u914d\u7f6e\u8fc1\u79fb\u5230 ",Object(i.b)("inlineCode",{parentName:"p"},"FurWebCoreStartup.cs")," \u4e2d\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'title="Fur.Web.Core\\FurWebCoreStartup.cs"',title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Fur.UnifyResult;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddCorsAccessor();\n\n services.AddSpecificationDocuments();\n services.AddControllers()\n .AddDynamicApiControllers()\n .AddDataValidation()\n .AddFriendlyException()\n .AddUnifyResult();\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n if (env.IsDevelopment())\n {\n app.UseDeveloperExceptionPage();\n }\n\n app.UseHttpsRedirection();\n\n app.UseRouting();\n\n app.UseCorsAccessor();\n\n app.UseAuthentication();\n app.UseAuthorization();\n\n app.UseSpecificationDocuments();\n\n app.UseEndpoints(endpoints =>\n {\n endpoints.MapControllers();\n });\n }\n }\n}\n")),Object(i.b)("p",null,"\u8fd9\u6837\uff0c\u540e\u7eed\u66f4\u6362 ",Object(i.b)("inlineCode",{parentName:"p"},"Web \u5e94\u7528\u5c42")," \u4e5f\u65e0\u9700\u91cd\u65b0\u914d\u7f6e ",Object(i.b)("inlineCode",{parentName:"p"},"Startup.cs")),Object(i.b)("h2",{id:"35-\u5173\u4e8e-appsettingsjson"},"3.5 \u5173\u4e8e ",Object(i.b)("inlineCode",{parentName:"h2"},"appsettings.json")),Object(i.b)("p",null,"\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u914d\u7f6e\u653e\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u4e2d\u914d\u7f6e\uff0c\u4f46\u662f\u8fd9\u6837\u7684\u65b9\u5f0f\u548c ",Object(i.b)("inlineCode",{parentName:"p"},"Startup.cs")," \u914d\u7f6e\u4e00\u6837\u7684\u9053\u7406\uff0c\u4e00\u65e6\u6211\u4eec\u66f4\u6362\u4e86 ",Object(i.b)("inlineCode",{parentName:"p"},"Web \u5e94\u7528\u5c42"),"\uff0c\u90a3\u4e48 ",Object(i.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u53c8\u8981\u91cd\u65b0\u914d\u7f6e\u4e00\u6b21\u3002"),Object(i.b)("p",null,"\u6240\u4ee5\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u66f4\u52a0\u7075\u6d3b\u7684\u65b9\u5f0f\u914d\u7f6e ",Object(i.b)("inlineCode",{parentName:"p"},"appsettings.json"),"\uff0c",Object(i.b)("strong",{parentName:"p"},"\u53ea\u9700\u8981\u5728\u4efb\u4f55\u9879\u76ee\u5c42\u6839\u76ee\u5f55\u4e0b\u521b\u5efa ",Object(i.b)("inlineCode",{parentName:"strong"},".json")," \u6587\u4ef6\u5373\u53ef")),Object(i.b)("p",null,Object(i.b)("strong",{parentName:"p"},Object(i.b)("inlineCode",{parentName:"strong"},"Fur")," \u6846\u67b6\u6700\u540e\u4f1a\u81ea\u52a8\u5408\u5e76\u6240\u6709\u5206\u6563\u7684\u914d\u7f6e\u6587\u4ef6\u3002")),Object(i.b)("p",null,"\u5982\u6211\u4eec\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u5c42\u521b\u5efa ",Object(i.b)("inlineCode",{parentName:"p"},"dbsettings.json")," \u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:'title="Fur.EntityFramework.Core\\dbsettings.json"',title:'"Fur.EntityFramework.Core\\dbsettings.json"'}),'{\n "ConnectionStrings": {\n "DbConnectionString": "Server=localhost;Database=Fur;User=sa;Password=000000;MultipleActiveResultSets=True;",\n "Sqlite3ConnectionString": "Data Source=./Fur.db"\n }\n}\n')),Object(i.b)("p",null,Object(i.b)("strong",{parentName:"p"},"\u65e0\u9700\u5728 ",Object(i.b)("inlineCode",{parentName:"strong"},"appsettings.json")," \u4e2d\u914d\u7f6e"),"\uff0c\u4e0b\u9762\u662f ",Object(i.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u9ed8\u8ba4\u4ee3\u7801:"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json"}),'{\n "Logging": {\n "LogLevel": {\n "Default": "Information",\n "Microsoft": "Warning",\n "Microsoft.Hosting.Lifetime": "Information",\n "Microsoft.EntityFrameworkCore": "Information"\n }\n },\n "AllowedHosts": "*"\n}\n')),Object(i.b)("p",null,"\u8fd9\u6837\u6211\u4eec\u628a\u914d\u7f6e\u6587\u4ef6\u5206\u6563\u5728\u4e0d\u540c\u9879\u76ee\u5c42\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u5b9e\u73b0\u5171\u7528\u548c\u5171\u4eab\u4e86\u3002"),Object(i.b)("h2",{id:"36-\u795e\u5947\u7684-inject"},"3.6 \u795e\u5947\u7684 ",Object(i.b)("inlineCode",{parentName:"h2"},"Inject()")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Inject()")," \u65b9\u6cd5\u662f ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u7684\u6700\u5c0f\u4fb5\u5165\u5f0f\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u8ba9\u4efb\u4f55 ",Object(i.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," Web \u9879\u76ee\u77ac\u95f4\u652f\u6301\u6240\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u7279\u6027\u3002"),Object(i.b)("p",null,"\u6211\u4eec\u521b\u5efa\u4e86\u65b0\u7684 ",Object(i.b)("inlineCode",{parentName:"p"},"Web \u9879\u76ee"),"\uff0c\u53ea\u9700\u8981\u4e09\u4e2a\u6b65\u9aa4\u5373\u53ef\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u6dfb\u52a0 ",Object(i.b)("inlineCode",{parentName:"li"},"Fur.Web.Core")," \u9879\u76ee\u5f15\u7528"),Object(i.b)("li",{parentName:"ul"},"\u5728 ",Object(i.b)("inlineCode",{parentName:"li"},"Program.cs")," \u4e2d\u8c03\u7528\u5373\u53ef"),Object(i.b)("li",{parentName:"ul"},"\u5c06 ",Object(i.b)("inlineCode",{parentName:"li"},"Startup.cs")," \u4ee3\u7801\u8fc1\u79fb\u5230 ",Object(i.b)("inlineCode",{parentName:"li"},"Fur.Web.Core")," \u9879\u76ee\u7684 ",Object(i.b)("inlineCode",{parentName:"li"},"FurWebCoreStartup.cs")," \u4e2d")),Object(i.b)("p",null,"\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{18} title="Fur.Web.Entry\\Program.cs"',"{18}":!0,title:'"Fur.Web.Entry\\Program.cs"'}),"using Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.Hosting;\n\nnamespace Fur.Web.Entry\n{\n public class Program\n {\n public static void Main(string[] args)\n {\n CreateHostBuilder(args).Build().Run();\n }\n\n public static IHostBuilder CreateHostBuilder(string[] args)\n {\n return Host.CreateDefaultBuilder(args)\n .ConfigureWebHostDefaults(webBuilder =>\n {\n webBuilder.Inject()\n .UseStartup();\n });\n }\n }\n}\n")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'title="Fur.Web.Entry\\Startup.cs"',title:'"Fur.Web.Entry\\Startup.cs"'}),"using Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Entry\n{\n public class Startup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n }\n }\n}\n")),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),Object(i.b)("inlineCode",{parentName:"h5"},"Startup.cs")," \u4ee3\u7801\u8fc1\u79fb")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u53ea\u9700\u8981\u5c06 ",Object(i.b)("inlineCode",{parentName:"p"},"ConfigureServices")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"Configure")," \u65b9\u6cd5\u4ee3\u7801\u8fc1\u79fb\u5230 ",Object(i.b)("inlineCode",{parentName:"p"},"FurWebCoreStartup.cs")," \u4e2d\u5373\u53ef\uff0c\u800c ",Object(i.b)("inlineCode",{parentName:"p"},"Startup.cs")," \u4e2d\u4e24\u4e2a\u65b9\u6cd5\u7559\u7a7a\u5373\u53ef\u3002"))),Object(i.b)("p",null,"\u975e\u5e38\u7b80\u5355\u5427\u3002\u6211\u4eec\u540e\u7eed\u521b\u5efa\u4efb\u4f55 ",Object(i.b)("inlineCode",{parentName:"p"},"MVC"),"\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"RazorPages"),"\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"Blazor")," \u9879\u76ee\u53ea\u9700\u8981\u6dfb\u52a0 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.Web.Core")," \u5f15\u7528\u548c\u8c03\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"Inject()")," \u5373\u53ef\u3002"),Object(i.b)("h2",{id:"37-\u53cd\u9988\u4e0e\u5efa\u8bae"},"3.7 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}l.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/5ce0ebbd.e81097b1.js b/handbook/build/5ce0ebbd.e81097b1.js new file mode 100644 index 00000000000..95414a1868c --- /dev/null +++ b/handbook/build/5ce0ebbd.e81097b1.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[35],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return s})),t.d(n,"b",(function(){return m}));var a=t(0),r=t.n(a);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function p(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function c(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var b=r.a.createContext({}),l=function(e){var n=r.a.useContext(b),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},s=function(e){var n=l(e.components);return r.a.createElement(b.Provider,{value:n},e.children)},u={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},d=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,i=e.originalType,p=e.parentName,b=o(e,["components","mdxType","originalType","parentName"]),s=l(t),d=a,m=s["".concat(p,".").concat(d)]||s[d]||u[d]||i;return t?r.a.createElement(m,c(c({ref:n},b),{},{components:t})):r.a.createElement(m,c({ref:n},b))}));function m(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var i=t.length,p=new Array(i);p[0]=d;var c={};for(var o in n)hasOwnProperty.call(n,o)&&(c[o]=n[o]);c.originalType=e,c.mdxType="string"==typeof e?e:a,p[1]=c;for(var b=2;bStartup \u7c7b",id:"31-startup-\u7c7b",children:[{value:"3.1.1 Startup \u4e24\u4e2a\u91cd\u8981\u65b9\u6cd5",id:"311-startup-\u4e24\u4e2a\u91cd\u8981\u65b9\u6cd5",children:[]}]},{value:"3.2 AppStartup",id:"32-appstartup",children:[{value:"3.2.1 \u5982\u4f55\u914d\u7f6e AppStartup",id:"321-\u5982\u4f55\u914d\u7f6e-appstartup",children:[]},{value:"3.2.2 AppStartup \u7ea6\u5b9a",id:"322-appstartup-\u7ea6\u5b9a",children:[]},{value:"3.2.3 AppStartup \u914d\u7f6e\u987a\u5e8f",id:"323-appstartup-\u914d\u7f6e\u987a\u5e8f",children:[]},{value:"3.2.4 AppStartup \u65b9\u6cd5\u8c03\u7528\u987a\u5e8f",id:"324-appstartup-\u65b9\u6cd5\u8c03\u7528\u987a\u5e8f",children:[]}]},{value:"3.3 \u6846\u67b6\u9ed8\u8ba4 AppStartup \u5b9e\u73b0",id:"33-\u6846\u67b6\u9ed8\u8ba4-appstartup-\u5b9e\u73b0",children:[]},{value:"3.4 Startup \u914d\u7f6e\u6700\u4f73\u5b9e\u8df5",id:"34-startup-\u914d\u7f6e\u6700\u4f73\u5b9e\u8df5",children:[]},{value:"3.5 \u5173\u4e8e appsettings.json",id:"35-\u5173\u4e8e-appsettingsjson",children:[]},{value:"3.6 \u795e\u5947\u7684 Inject()",id:"36-\u795e\u5947\u7684-inject",children:[]},{value:"3.7 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"37-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],b={rightToc:o};function l(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},b,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"31-startup-\u7c7b"},"3.1 ",Object(i.b)("inlineCode",{parentName:"h2"},"Startup")," \u7c7b"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Startup")," \u7c7b\u662f ",Object(i.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u9ed8\u8ba4\u8c03\u7528\u7684\u7c7b\uff0c\u8be5\u7c7b\u662f\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Program.cs")," \u4e2d\u914d\u7f6e\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{19} title="Fur.Web.Entry\\Program.cs"',"{19}":!0,title:'"Fur.Web.Entry\\Program.cs"'}),"using Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.Hosting;\n\nnamespace Fur.Web.Entry\n{\n public class Program\n {\n public static void Main(string[] args)\n {\n CreateHostBuilder(args).Build().Run();\n }\n\n public static IHostBuilder CreateHostBuilder(string[] args)\n {\n return Host.CreateDefaultBuilder(args)\n .ConfigureWebHostDefaults(webBuilder =>\n {\n webBuilder.Inject()\n .UseStartup();\n });\n }\n }\n}\n")),Object(i.b)("h3",{id:"311-startup-\u4e24\u4e2a\u91cd\u8981\u65b9\u6cd5"},"3.1.1 ",Object(i.b)("inlineCode",{parentName:"h3"},"Startup")," \u4e24\u4e2a\u91cd\u8981\u65b9\u6cd5"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Startup")," \u9ed8\u8ba4\u6709\u4e24\u4e2a\u91cd\u8981\u7684\u65b9\u6cd5:"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ConfigureServices"),"\uff1a\u914d\u7f6e\u5e94\u7528\u6240\u9700\u670d\u52a1\uff0c\u5728\u8be5\u65b9\u6cd5\u4e2d\u53ef\u4ee5\u6dfb\u52a0\u5e94\u7528\u6240\u9700\u8981\u7684\u529f\u80fd\u6216\u670d\u52a1"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Configure"),"\uff1a\u914d\u7f6e\u5e94\u7528\u8bf7\u6c42\u5904\u7406\u7ba1\u9053")),Object(i.b)("p",null,"\u9ed8\u8ba4\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{9,13} title="Fur.Web.Entry\\Startup.cs"',"{9,13}":!0,title:'"Fur.Web.Entry\\Startup.cs"'}),"using Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Entry\n{\n public class Startup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n }\n }\n}\n")),Object(i.b)("p",null,"\u5728\u8fd9\u91cc\uff0c\u4e0d\u6253\u7b97\u8be6\u7ec6\u8bb2 ",Object(i.b)("inlineCode",{parentName:"p"},"Startup")," \u7c7b\u7684\u5177\u4f53\u529f\u80fd\u548c\u4f5c\u7528\u3002"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(i.b)("inlineCode",{parentName:"p"},"Startup")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/startup?view=aspnetcore-3.1"}),"ASP.NET Core - Startup \u7c7b")," \u7ae0\u8282\u3002"))),Object(i.b)("h2",{id:"32-appstartup"},"3.2 ",Object(i.b)("inlineCode",{parentName:"h2"},"AppStartup")),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u63d0\u4f9b\u4e86\u66f4\u4e3a\u7075\u6d3b\u7684 ",Object(i.b)("inlineCode",{parentName:"p"},"Startup")," \u7c7b\u914d\u7f6e\u65b9\u5f0f\uff0c\u65e0\u9700\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Web \u542f\u7528\u5c42")," \u4e2d\u914d\u7f6e\uff0c\u53ef\u5c06\u914d\u7f6e\u653e\u5230\u4efb\u4f55\u9879\u76ee\u5c42\u3002"),Object(i.b)("p",null,"\u53ef\u80fd\u4f1a\u6709\u8bfb\u8005\u6709\u7591\u95ee\uff0c\u4e3a\u4ec0\u4e48\u8981\u591a\u6b64\u4e00\u4e3e\u5462\uff1f\u539f\u56e0\u6709\u51e0\u70b9\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Startup")," \u7c7b\u9ed8\u8ba4\u548c ",Object(i.b)("inlineCode",{parentName:"li"},"Web \u5e94\u7528\u5c42")," \u7ed1\u5b9a\u5728\u4e00\u8d77\uff0c\u8fd9\u6837\u5c31\u4f1a\u5bfc\u81f4\u5982\u679c\u6211\u521b\u5efa\u4e86\u65b0\u7684 ",Object(i.b)("inlineCode",{parentName:"li"},"Web \u5e94\u7528\u5c42"),"\uff0c",Object(i.b)("inlineCode",{parentName:"li"},"Startup")," \u53c8\u8981\u91cd\u65b0\u914d\u7f6e"),Object(i.b)("li",{parentName:"ul"},"\u968f\u7740\u4e1a\u52a1\u7684\u589e\u957f\uff0c\u9700\u8981\u96c6\u6210\u8d8a\u6765\u8d8a\u591a\u7684\u7b2c\u4e09\u65b9\u670d\u52a1\uff0c\u8fd9\u65f6\u5019 ",Object(i.b)("inlineCode",{parentName:"li"},"Startup")," \u7c7b\u5c31\u4f1a\u53d8\u5f97\u8d8a\u6765\u8d8a\u81c3\u80bf\uff0c\u96be\u4ee5\u7ef4\u62a4"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Startup")," \u7c7b\u65e0\u6cd5\u5176\u4ed6\u9879\u76ee\u7c7b\u578b\u8fdb\u884c\u5171\u7528")),Object(i.b)("p",null,"\u6240\u4ee5\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u4e86\u66f4\u52a0\u7075\u6d3b\u7684\u914d\u7f6e\u65b9\u5f0f\uff1a",Object(i.b)("inlineCode",{parentName:"p"},"AppStartup"),"\u3002"),Object(i.b)("h3",{id:"321-\u5982\u4f55\u914d\u7f6e-appstartup"},"3.2.1 \u5982\u4f55\u914d\u7f6e ",Object(i.b)("inlineCode",{parentName:"h3"},"AppStartup")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"AppStartup")," \u662f\u4e00\u4e2a\u62bd\u8c61\u7684\u7a7a\u7c7b\uff0c\u6ca1\u6709\u4efb\u4f55\u5b9a\u4e49\u6210\u5458\u3002\u6b63\u662f\u56e0\u4e3a\u8fd9\u6837\uff0c\u624d\u63d0\u4f9b\u66f4\u52a0\u7075\u6d3b\u7684\u914d\u7f6e\u65b9\u5f0f\u3002"),Object(i.b)("h3",{id:"322-appstartup-\u7ea6\u5b9a"},"3.2.2 ",Object(i.b)("inlineCode",{parentName:"h3"},"AppStartup")," \u7ea6\u5b9a"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"AppStartup")," \u6d3e\u751f\u7c7b\u53ea\u6709\u4e24\u4e2a\u5c0f\u7ea6\u5b9a\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u4efb\u4f55\u516c\u5f00\u3001\u975e\u9759\u6001\u3001\u8fd4\u56de\u503c\u4e3a ",Object(i.b)("inlineCode",{parentName:"li"},"void")," \u4e14\u65b9\u6cd5\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f ",Object(i.b)("inlineCode",{parentName:"li"},"IServiceCollection")," \u7c7b\u578b\uff0c\u90a3\u4e48\u4ed6\u5c31\u662f\u4e00\u4e2a ",Object(i.b)("inlineCode",{parentName:"li"},"ConfigureServices")," \u65b9\u6cd5"),Object(i.b)("li",{parentName:"ul"},"\u4efb\u4f55\u516c\u5f00\u3001\u975e\u9759\u6001\u3001\u8fd4\u56de\u503c\u4e3a ",Object(i.b)("inlineCode",{parentName:"li"},"void")," \u4e14\u65b9\u6cd5\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f ",Object(i.b)("inlineCode",{parentName:"li"},"IApplicationBuilder")," \u7c7b\u578b\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f ",Object(i.b)("inlineCode",{parentName:"li"},"IWebHostEnvironment")," \u7c7b\u578b\uff0c\u90a3\u4e48\u4ed6\u5c31\u662f\u4e00\u4e2a ",Object(i.b)("inlineCode",{parentName:"li"},"Configure")," \u65b9\u6cd5")),Object(i.b)("p",null,"\u6240\u4ee5\uff0c\u6211\u4eec\u53ef\u4ee5\u81ea\u7531\u7684\u7f16\u5199\u65b9\u6cd5\uff0c\u53ea\u8981\u9075\u5faa\u7ea6\u5b9a\u5373\u53ef\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,7,12,18,23}","{5,7,12,18,23}":!0}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n public class MyStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddDataValidation();\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n app.UseSwagger();\n }\n\n // \u53ef\u4ee5\u968f\u610f\u5b9a\u4e49\u540d\u5b57\u548c\u65b9\u6cd5\n public void XXXXName(IServiceCollection services)\n {\n }\n\n // \u53ef\u4ee5\u968f\u610f\u5b9a\u4e49\u540d\u5b57\u548c\u65b9\u6cd5\n public void ZZZName(IApplicationBuilder app, IWebHostEnvironment env)\n {\n }\n }\n}\n")),Object(i.b)("h3",{id:"323-appstartup-\u914d\u7f6e\u987a\u5e8f"},"3.2.3 ",Object(i.b)("inlineCode",{parentName:"h3"},"AppStartup")," \u914d\u7f6e\u987a\u5e8f"),Object(i.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"AppStartup")," \u914d\u7f6e\u987a\u5e8f\u7531\u6240\u5728\u7a0b\u5e8f\u96c6\u7684\u540d\u79f0\u8fdb\u884c\u6b63\u5e8f\u8c03\u7528\uff0c\u5982\u679c\u6211\u4eec\u9700\u8981\u914d\u7f6e\u6267\u884c\u987a\u5e8f\uff0c\u53ea\u9700\u8981\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"AppStartup")," \u6d3e\u751f\u7c7b\u4e2d\u8d34 ",Object(i.b)("inlineCode",{parentName:"p"},"[AppStartup(order)]")," \u7279\u6027\u5373\u53ef\u3002"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"order")," \u6570\u503c\u8d8a\u5927\uff0c\u8d8a\u5728\u524d\u9762\u8c03\u7528\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5}","{5}":!0}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(10)]\n public class FirstStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n }\n }\n}\n")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5}","{5}":!0}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(9)]\n public class SecondStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n }\n }\n}\n")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"FirstStartup")," \u4f1a\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"SecondStartup")," \u4e4b\u524d\u8c03\u7528\u3002"),Object(i.b)("h3",{id:"324-appstartup-\u65b9\u6cd5\u8c03\u7528\u987a\u5e8f"},"3.2.4 ",Object(i.b)("inlineCode",{parentName:"h3"},"AppStartup")," \u65b9\u6cd5\u8c03\u7528\u987a\u5e8f"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"AppStartup")," \u65b9\u6cd5\u8c03\u7528\u987a\u5e8f\u548c\u65b9\u6cd5\u7684\u4e66\u5199\u5148\u540e\u6709\u5173\uff0c\u8d8a\u5728\u524d\u9762\u7684\u65b9\u6cd5\u8d8a\u5148\u8c03\u7528\u3002"),Object(i.b)("h2",{id:"33-\u6846\u67b6\u9ed8\u8ba4-appstartup-\u5b9e\u73b0"},"3.3 \u6846\u67b6\u9ed8\u8ba4 ",Object(i.b)("inlineCode",{parentName:"h2"},"AppStartup")," \u5b9e\u73b0"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u9ed8\u8ba4\u5728\u6bcf\u4e00\u4e2a\u9879\u76ee\u5c42\u4e2d\u90fd\u521b\u5efa\u4e86\u4e00\u4e2a ",Object(i.b)("inlineCode",{parentName:"p"},"AppStartup")," \u6d3e\u751f\u7c7b\uff0c\u65b9\u4fbf\u5927\u5bb6\u914d\u7f6e\u3002\u5982\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"FurStartup.cs"),"\uff1a",Object(i.b)("inlineCode",{parentName:"li"},"Fur")," \u6846\u67b6\u6838\u5fc3\u542f\u52a8\u7c7b\uff08\u901a\u5e38\u65e0\u9700\u914d\u7f6e\uff09"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"FurApplicationStartup.cs"),"\uff1a\u4e1a\u52a1\u670d\u52a1\u542f\u52a8\u7c7b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"FurCoreStartup.cs"),"\uff1a\u5e94\u7528\u6838\u5fc3\u529f\u80fd\u542f\u52a8\u7c7b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"FurEntityFrameworkCoreStartup.cs"),"\uff1a\u6570\u636e\u5e93\u76f8\u5173\u542f\u52a8\u7c7b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"FurWebCoreStartup.cs"),"\uff1a",Object(i.b)("inlineCode",{parentName:"li"},"Web")," \u6838\u5fc3\u542f\u52a8\u914d\u7f6e\u7c7b")),Object(i.b)("h2",{id:"34-startup-\u914d\u7f6e\u6700\u4f73\u5b9e\u8df5"},"3.4 ",Object(i.b)("inlineCode",{parentName:"h2"},"Startup")," \u914d\u7f6e\u6700\u4f73\u5b9e\u8df5"),Object(i.b)("p",null,"\u5efa\u8bae ",Object(i.b)("inlineCode",{parentName:"p"},"Web")," \u542f\u52a8\u5c42\u7684 ",Object(i.b)("inlineCode",{parentName:"p"},"Startup.cs")," \u4fdd\u6301\u4e3a\u7a7a\u65b9\u6cd5\u4f53\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'title="Fur.Web.Entry\\Startup.cs"',title:'"Fur.Web.Entry\\Startup.cs"'}),"using Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Entry\n{\n public class Startup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n }\n }\n}\n")),Object(i.b)("p",null,"\u5c06\u6240\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"Web \u5e94\u7528\u5c42")," \u914d\u7f6e\u8fc1\u79fb\u5230 ",Object(i.b)("inlineCode",{parentName:"p"},"FurWebCoreStartup.cs")," \u4e2d\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'title="Fur.Web.Core\\FurWebCoreStartup.cs"',title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Fur.UnifyResult;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddCorsAccessor();\n\n services.AddSpecificationDocuments();\n services.AddControllers()\n .AddDynamicApiControllers()\n .AddDataValidation()\n .AddFriendlyException()\n .AddUnifyResult();\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n if (env.IsDevelopment())\n {\n app.UseDeveloperExceptionPage();\n }\n\n app.UseHttpsRedirection();\n\n app.UseRouting();\n\n app.UseCorsAccessor();\n\n app.UseAuthentication();\n app.UseAuthorization();\n\n app.UseSpecificationDocuments();\n\n app.UseEndpoints(endpoints =>\n {\n endpoints.MapControllers();\n });\n }\n }\n}\n")),Object(i.b)("p",null,"\u8fd9\u6837\uff0c\u540e\u7eed\u66f4\u6362 ",Object(i.b)("inlineCode",{parentName:"p"},"Web \u5e94\u7528\u5c42")," \u4e5f\u65e0\u9700\u91cd\u65b0\u914d\u7f6e ",Object(i.b)("inlineCode",{parentName:"p"},"Startup.cs")),Object(i.b)("h2",{id:"35-\u5173\u4e8e-appsettingsjson"},"3.5 \u5173\u4e8e ",Object(i.b)("inlineCode",{parentName:"h2"},"appsettings.json")),Object(i.b)("p",null,"\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u914d\u7f6e\u653e\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u4e2d\u914d\u7f6e\uff0c\u4f46\u662f\u8fd9\u6837\u7684\u65b9\u5f0f\u548c ",Object(i.b)("inlineCode",{parentName:"p"},"Startup.cs")," \u914d\u7f6e\u4e00\u6837\u7684\u9053\u7406\uff0c\u4e00\u65e6\u6211\u4eec\u66f4\u6362\u4e86 ",Object(i.b)("inlineCode",{parentName:"p"},"Web \u5e94\u7528\u5c42"),"\uff0c\u90a3\u4e48 ",Object(i.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u53c8\u8981\u91cd\u65b0\u914d\u7f6e\u4e00\u6b21\u3002"),Object(i.b)("p",null,"\u6240\u4ee5\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u66f4\u52a0\u7075\u6d3b\u7684\u65b9\u5f0f\u914d\u7f6e ",Object(i.b)("inlineCode",{parentName:"p"},"appsettings.json"),"\uff0c",Object(i.b)("strong",{parentName:"p"},"\u53ea\u9700\u8981\u5728\u4efb\u4f55\u9879\u76ee\u5c42\u6839\u76ee\u5f55\u4e0b\u521b\u5efa ",Object(i.b)("inlineCode",{parentName:"strong"},".json")," \u6587\u4ef6\u5373\u53ef")),Object(i.b)("p",null,Object(i.b)("strong",{parentName:"p"},Object(i.b)("inlineCode",{parentName:"strong"},"Fur")," \u6846\u67b6\u6700\u540e\u4f1a\u81ea\u52a8\u5408\u5e76\u6240\u6709\u5206\u6563\u7684\u914d\u7f6e\u6587\u4ef6\u3002")),Object(i.b)("p",null,"\u5982\u6211\u4eec\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u5c42\u521b\u5efa ",Object(i.b)("inlineCode",{parentName:"p"},"dbsettings.json")," \u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:'title="Fur.EntityFramework.Core\\dbsettings.json"',title:'"Fur.EntityFramework.Core\\dbsettings.json"'}),'{\n "ConnectionStrings": {\n "DbConnectionString": "Server=localhost;Database=Fur;User=sa;Password=000000;MultipleActiveResultSets=True;",\n "Sqlite3ConnectionString": "Data Source=./Fur.db"\n }\n}\n')),Object(i.b)("p",null,Object(i.b)("strong",{parentName:"p"},"\u65e0\u9700\u5728 ",Object(i.b)("inlineCode",{parentName:"strong"},"appsettings.json")," \u4e2d\u914d\u7f6e"),"\uff0c\u4e0b\u9762\u662f ",Object(i.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u9ed8\u8ba4\u4ee3\u7801:"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json"}),'{\n "Logging": {\n "LogLevel": {\n "Default": "Information",\n "Microsoft": "Warning",\n "Microsoft.Hosting.Lifetime": "Information",\n "Microsoft.EntityFrameworkCore": "Information"\n }\n },\n "AllowedHosts": "*"\n}\n')),Object(i.b)("p",null,"\u8fd9\u6837\u6211\u4eec\u628a\u914d\u7f6e\u6587\u4ef6\u5206\u6563\u5728\u4e0d\u540c\u9879\u76ee\u5c42\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u5b9e\u73b0\u5171\u7528\u548c\u5171\u4eab\u4e86\u3002"),Object(i.b)("h2",{id:"36-\u795e\u5947\u7684-inject"},"3.6 \u795e\u5947\u7684 ",Object(i.b)("inlineCode",{parentName:"h2"},"Inject()")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Inject()")," \u65b9\u6cd5\u662f ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u7684\u6700\u5c0f\u4fb5\u5165\u5f0f\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u8ba9\u4efb\u4f55 ",Object(i.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," Web \u9879\u76ee\u77ac\u95f4\u652f\u6301\u6240\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u7279\u6027\u3002"),Object(i.b)("p",null,"\u6211\u4eec\u521b\u5efa\u4e86\u65b0\u7684 ",Object(i.b)("inlineCode",{parentName:"p"},"Web \u9879\u76ee"),"\uff0c\u53ea\u9700\u8981\u4e09\u4e2a\u6b65\u9aa4\u5373\u53ef\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u6dfb\u52a0 ",Object(i.b)("inlineCode",{parentName:"li"},"Fur.Web.Core")," \u9879\u76ee\u5f15\u7528"),Object(i.b)("li",{parentName:"ul"},"\u5728 ",Object(i.b)("inlineCode",{parentName:"li"},"Program.cs")," \u4e2d\u8c03\u7528\u5373\u53ef"),Object(i.b)("li",{parentName:"ul"},"\u5c06 ",Object(i.b)("inlineCode",{parentName:"li"},"Startup.cs")," \u4ee3\u7801\u8fc1\u79fb\u5230 ",Object(i.b)("inlineCode",{parentName:"li"},"Fur.Web.Core")," \u9879\u76ee\u7684 ",Object(i.b)("inlineCode",{parentName:"li"},"FurWebCoreStartup.cs")," \u4e2d")),Object(i.b)("p",null,"\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{18} title="Fur.Web.Entry\\Program.cs"',"{18}":!0,title:'"Fur.Web.Entry\\Program.cs"'}),"using Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.Hosting;\n\nnamespace Fur.Web.Entry\n{\n public class Program\n {\n public static void Main(string[] args)\n {\n CreateHostBuilder(args).Build().Run();\n }\n\n public static IHostBuilder CreateHostBuilder(string[] args)\n {\n return Host.CreateDefaultBuilder(args)\n .ConfigureWebHostDefaults(webBuilder =>\n {\n webBuilder.Inject()\n .UseStartup();\n });\n }\n }\n}\n")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'title="Fur.Web.Entry\\Startup.cs"',title:'"Fur.Web.Entry\\Startup.cs"'}),"using Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Entry\n{\n public class Startup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n }\n }\n}\n")),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),Object(i.b)("inlineCode",{parentName:"h5"},"Startup.cs")," \u4ee3\u7801\u8fc1\u79fb")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u53ea\u9700\u8981\u5c06 ",Object(i.b)("inlineCode",{parentName:"p"},"ConfigureServices")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"Configure")," \u65b9\u6cd5\u4ee3\u7801\u8fc1\u79fb\u5230 ",Object(i.b)("inlineCode",{parentName:"p"},"FurWebCoreStartup.cs")," \u4e2d\u5373\u53ef\uff0c\u800c ",Object(i.b)("inlineCode",{parentName:"p"},"Startup.cs")," \u4e2d\u4e24\u4e2a\u65b9\u6cd5\u7559\u7a7a\u5373\u53ef\u3002"))),Object(i.b)("p",null,"\u975e\u5e38\u7b80\u5355\u5427\u3002\u6211\u4eec\u540e\u7eed\u521b\u5efa\u4efb\u4f55 ",Object(i.b)("inlineCode",{parentName:"p"},"MVC"),"\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"RazorPages"),"\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"Blazor")," \u9879\u76ee\u53ea\u9700\u8981\u6dfb\u52a0 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.Web.Core")," \u5f15\u7528\u548c\u8c03\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"Inject()")," \u5373\u53ef\u3002"),Object(i.b)("h2",{id:"37-\u53cd\u9988\u4e0e\u5efa\u8bae"},"3.7 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}l.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/5e077782.49e1c594.js b/handbook/build/5e077782.49e1c594.js new file mode 100644 index 00000000000..715123a04ed --- /dev/null +++ b/handbook/build/5e077782.49e1c594.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[36],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return s})),t.d(n,"b",(function(){return d}));var i=t(0),a=t.n(i);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function b(e){for(var n=1;n=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}var o=a.a.createContext({}),p=function(e){var n=a.a.useContext(o),t=n;return e&&(t="function"==typeof e?e(n):b(b({},n),e)),t},s=function(e){var n=p(e.components);return a.a.createElement(o.Provider,{value:n},e.children)},u={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},j=a.a.forwardRef((function(e,n){var t=e.components,i=e.mdxType,r=e.originalType,c=e.parentName,o=l(e,["components","mdxType","originalType","parentName"]),s=p(t),j=i,d=s["".concat(c,".").concat(j)]||s[j]||u[j]||r;return t?a.a.createElement(d,b(b({ref:n},o),{},{components:t})):a.a.createElement(d,b({ref:n},o))}));function d(e,n){var t=arguments,i=n&&n.mdxType;if("string"==typeof e||i){var r=t.length,c=new Array(r);c[0]=j;var b={};for(var l in n)hasOwnProperty.call(n,l)&&(b[l]=n[l]);b.originalType=e,b.mdxType="string"==typeof e?e:i,c[1]=b;for(var o=2;oIOC/DI \u4f18\u7f3a\u70b9",id:"113-iocdi-\u4f18\u7f3a\u70b9",children:[]},{value:"11.4 \u4f9d\u8d56\u6ce8\u5165\u7684\u4e09\u79cd\u65b9\u5f0f",id:"114-\u4f9d\u8d56\u6ce8\u5165\u7684\u4e09\u79cd\u65b9\u5f0f",children:[{value:"11.4.1 \u6784\u9020\u65b9\u6cd5\u6ce8\u5165",id:"1141-\u6784\u9020\u65b9\u6cd5\u6ce8\u5165",children:[]},{value:"11.4.2 \u5c5e\u6027\u65b9\u5f0f\u6ce8\u5165",id:"1142-\u5c5e\u6027\u65b9\u5f0f\u6ce8\u5165",children:[]},{value:"11.4.3 \u65b9\u6cd5\u53c2\u6570\u6ce8\u5165",id:"1143-\u65b9\u6cd5\u53c2\u6570\u6ce8\u5165",children:[]}]},{value:"11.5 \u6ce8\u518c\u5bf9\u8c61\u751f\u5b58\u671f",id:"115-\u6ce8\u518c\u5bf9\u8c61\u751f\u5b58\u671f",children:[{value:"11.5.1 \u6682\u65f6/\u77ac\u65f6 \u751f\u5b58\u671f",id:"1151-\u6682\u65f6\u77ac\u65f6-\u751f\u5b58\u671f",children:[]},{value:"11.5.2 \u4f5c\u7528\u57df \u751f\u5b58\u671f",id:"1152-\u4f5c\u7528\u57df-\u751f\u5b58\u671f",children:[]},{value:"11.5.3 \u5355\u4f8b \u751f\u5b58\u671f",id:"1153-\u5355\u4f8b-\u751f\u5b58\u671f",children:[]}]},{value:"11.6 \u5185\u7f6e\u4f9d\u8d56\u63a5\u53e3",id:"116-\u5185\u7f6e\u4f9d\u8d56\u63a5\u53e3",children:[]},{value:"11.7 \u5e38\u89c1\u4f7f\u7528",id:"117-\u5e38\u89c1\u4f7f\u7528",children:[{value:"11.7.2 \u7b2c\u4e00\u4e2a\u4f8b\u5b50",id:"1172-\u7b2c\u4e00\u4e2a\u4f8b\u5b50",children:[]},{value:"11.7.3 \u6ce8\u518c\u6cdb\u578b\u5b9e\u4f8b",id:"1173-\u6ce8\u518c\u6cdb\u578b\u5b9e\u4f8b",children:[]},{value:"11.7.4 \u4e00\u4e2a\u63a5\u53e3\u591a\u4e2a\u5b9e\u73b0",id:"1174-\u4e00\u4e2a\u63a5\u53e3\u591a\u4e2a\u5b9e\u73b0",children:[]},{value:"11.7.5 \u65e0\u63a5\u53e3\u65b9\u5f0f",id:"1175-\u65e0\u63a5\u53e3\u65b9\u5f0f",children:[]}]},{value:"11.8 [Injection] \u7279\u6027\u914d\u7f6e",id:"118-injection-\u7279\u6027\u914d\u7f6e",children:[]},{value:"11.9 \u81ea\u5b9a\u4e49\u9ad8\u7ea7\u6ce8\u518c",id:"119-\u81ea\u5b9a\u4e49\u9ad8\u7ea7\u6ce8\u518c",children:[]},{value:"11.10 appsettings.json \u914d\u7f6e\u6ce8\u518c",id:"1110-appsettingsjson-\u914d\u7f6e\u6ce8\u518c",children:[]},{value:"11.11 \u6ce8\u518c\u987a\u5e8f\u548c\u4f18\u5148\u7ea7",id:"1111-\u6ce8\u518c\u987a\u5e8f\u548c\u4f18\u5148\u7ea7",children:[]},{value:"11.12 Aop \u6ce8\u518c\u62e6\u622a",id:"1112-aop-\u6ce8\u518c\u62e6\u622a",children:[{value:"11.12.1 AOP \u7684\u4f5c\u7528",id:"11121-aop-\u7684\u4f5c\u7528",children:[]}]},{value:"11.13 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"1113-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],p={rightToc:o};function s(e){var n=e.components,t=Object(a.a)(e,["components"]);return Object(r.b)("wrapper",Object(i.a)({},p,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"111-\u4f9d\u8d56\u6ce8\u5165"},"11.1 \u4f9d\u8d56\u6ce8\u5165"),Object(r.b)("p",null,"\u6240\u8c13\u4f9d\u8d56\u6ce8\u5165\uff0c\u662f\u6307\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\uff0c\u5982\u679c\u9700\u8981\u8c03\u7528\u53e6\u4e00\u4e2a\u5bf9\u8c61\u534f\u52a9\u65f6\uff0c\u65e0\u987b\u5728\u4ee3\u7801\u4e2d\u521b\u5efa\u88ab\u8c03\u7528\u8005\uff0c\u800c\u662f\u4f9d\u8d56\u4e8e\u5916\u90e8\u7684\u6ce8\u5165\u3002"),Object(r.b)("p",null,"\u901a\u4fd7\u6765\u8bb2\uff0c\u5c31\u662f\u628a\u6709\u4f9d\u8d56\u5173\u7cfb\u7684\u7c7b\u653e\u5230\u5bb9\u5668\u4e2d\uff0c\u7136\u540e\u5728\u6211\u4eec\u9700\u8981\u8fd9\u4e9b\u7c7b\u65f6\uff0c\u5bb9\u5668\u81ea\u52a8\u89e3\u6790\u51fa\u8fd9\u4e9b\u7c7b\u7684\u5b9e\u4f8b\u3002"),Object(r.b)("p",null,"\u4f9d\u8d56\u6ce8\u5165\u6700\u5927\u7684\u597d\u5904\u65f6\u5b9e\u73b0\u7c7b\u7684\u89e3\u8026\uff0c\u5229\u4e8e\u7a0b\u5e8f\u62d3\u5c55\u3001\u5355\u5143\u6d4b\u8bd5\u3001\u81ea\u52a8\u5316\u6a21\u62df\u6d4b\u8bd5\u7b49\u3002"),Object(r.b)("p",null,"\u4f9d\u8d56\u6ce8\u5165\u7684\u82f1\u6587\u4e3a\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"Dependency Injection"),"\uff0c\u7b80\u79f0 ",Object(r.b)("inlineCode",{parentName:"p"},"DI")),Object(r.b)("h2",{id:"112-\u63a7\u5236\u53cd\u8f6c"},"11.2 \u63a7\u5236\u53cd\u8f6c"),Object(r.b)("p",null,"\u63a7\u5236\u53cd\u8f6c\u53ea\u662f\u4e00\u4e2a\u6982\u5ff5\uff0c\u4e5f\u5c31\u662f\u5c06\u521b\u5efa\u5bf9\u8c61\u5b9e\u4f8b\u7684\u63a7\u5236\u6743\uff08\u539f\u672c\u662f\u7a0b\u5e8f\u5458\uff09\u4ece\u4ee3\u7801\u63a7\u5236\u6743\u5265\u79bb\u5230 ",Object(r.b)("inlineCode",{parentName:"p"},"IOC \u5bb9\u5668")," \u4e2d\u63a7\u5236\u3002"),Object(r.b)("p",null,"\u63a7\u5236\u53cd\u8f6c\u7684\u82f1\u6587\u4e3a\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"Inversion of Control"),"\uff0c\u7b80\u79f0 ",Object(r.b)("inlineCode",{parentName:"p"},"IOC")),Object(r.b)("h2",{id:"113-iocdi-\u4f18\u7f3a\u70b9"},"11.3 ",Object(r.b)("inlineCode",{parentName:"h2"},"IOC/DI")," \u4f18\u7f3a\u70b9"),Object(r.b)("p",null,"\u4f20\u7edf\u7684\u4ee3\u7801\uff0c\u6bcf\u4e2a\u5bf9\u8c61\u8d1f\u8d23\u7ba1\u7406\u4e0e\u81ea\u5df1\u9700\u8981\u4f9d\u8d56\u7684\u5bf9\u8c61\uff0c\u5bfc\u81f4\u5982\u679c\u9700\u8981\u5207\u6362\u4f9d\u8d56\u5bf9\u8c61\u7684\u5b9e\u73b0\u7c7b\u65f6\uff0c\u9700\u8981\u4fee\u6539\u591a\u5904\u5730\u65b9\u3002\u540c\u65f6\uff0c\u8fc7\u5ea6\u8026\u5408\u4e5f\u4f7f\u5f97\u5bf9\u8c61\u96be\u4ee5\u8fdb\u884c\u5355\u5143\u6d4b\u8bd5\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u4f18\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u4f9d\u8d56\u6ce8\u5165\u628a\u5bf9\u8c61\u7684\u521b\u9020\u4ea4\u7ed9\u5916\u90e8\u53bb\u7ba1\u7406,\u5f88\u597d\u7684\u89e3\u51b3\u4e86\u4ee3\u7801\u7d27\u8026\u5408\uff08tight couple\uff09\u7684\u95ee\u9898\uff0c\u662f\u4e00\u79cd\u8ba9\u4ee3\u7801\u5b9e\u73b0\u677e\u8026\u5408\uff08loose couple\uff09\u7684\u673a\u5236"),Object(r.b)("li",{parentName:"ul"},"\u677e\u8026\u5408\u8ba9\u4ee3\u7801\u66f4\u5177\u7075\u6d3b\u6027\uff0c\u80fd\u66f4\u597d\u5730\u5e94\u5bf9\u9700\u6c42\u53d8\u52a8\uff0c\u4ee5\u53ca\u65b9\u4fbf\u5355\u5143\u6d4b\u8bd5"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u7f3a\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u76ee\u524d\u4e3b\u6d41\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"IOC/DI")," \u57fa\u672c\u91c7\u7528\u53cd\u5c04\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u4f9d\u8d56\u6ce8\u5165\uff0c\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4f1a\u5f71\u54cd\u6027\u80fd")))),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u8bf4\u660e")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5728\u672c\u7ae0\u8282\u4e0d\u6253\u7b97\u7ec6\u8bb2 ",Object(r.b)("inlineCode",{parentName:"p"},"\u4f9d\u8d56\u6ce8\u5165/\u63a7\u5236\u53cd\u8f6c")," \u5177\u4f53\u5b9e\u73b0\u548c\u5e94\u7528\u573a\u666f\uff0c\u60f3\u4e86\u89e3\u66f4\u591a\u77e5\u8bc6\uff0c\u53ef\u67e5\u9605 \u3010",Object(r.b)("a",Object(i.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-5.0"}),"ASP.NET Core \u4f9d\u8d56\u6ce8\u5165"),"\u3011 \u5b98\u65b9\u6587\u6863\u3002"))),Object(r.b)("h2",{id:"114-\u4f9d\u8d56\u6ce8\u5165\u7684\u4e09\u79cd\u65b9\u5f0f"},"11.4 \u4f9d\u8d56\u6ce8\u5165\u7684\u4e09\u79cd\u65b9\u5f0f"),Object(r.b)("h3",{id:"1141-\u6784\u9020\u65b9\u6cd5\u6ce8\u5165"},"11.4.1 \u6784\u9020\u65b9\u6cd5\u6ce8\u5165"),Object(r.b)("p",null,"\u76ee\u524d\u6784\u9020\u65b9\u6cd5\u6ce8\u5165\u662f\u4f9d\u8d56\u6ce8\u5165\u63a8\u8350\u4f7f\u7528\u65b9\u5f0f\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u4f18\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u5728\u6784\u9020\u65b9\u6cd5\u4e2d\u4f53\u73b0\u51fa\u5bf9\u5176\u4ed6\u7c7b\u7684\u4f9d\u8d56\uff0c\u4e00\u773c\u5c31\u80fd\u770b\u51fa\u8fd9\u4e2a\u7c7b\u9700\u8981\u5176\u4ed6\u90a3\u4e9b\u7c7b\u624d\u80fd\u5de5\u4f5c"),Object(r.b)("li",{parentName:"ul"},"\u8131\u79bb\u4e86 IOC \u6846\u67b6\uff0c\u8fd9\u4e2a\u7c7b\u4ecd\u7136\u53ef\u4ee5\u5de5\u4f5c\uff0cPOJO \u7684\u6982\u5ff5"),Object(r.b)("li",{parentName:"ul"},"\u4e00\u65e6\u5bf9\u8c61\u521d\u59cb\u5316\u6210\u529f\u4e86\uff0c\u8fd9\u4e2a\u5bf9\u8c61\u7684\u72b6\u6001\u80af\u5b9a\u662f\u6b63\u786e\u7684"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u7f3a\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u6784\u9020\u51fd\u6570\u4f1a\u6709\u5f88\u591a\u53c2\u6570\uff08Bad smell\uff09"),Object(r.b)("li",{parentName:"ul"},"\u6709\u4e9b\u7c7b\u662f\u9700\u8981\u9ed8\u8ba4\u6784\u9020\u51fd\u6570\u7684\uff0c\u6bd4\u5982 MVC \u6846\u67b6\u7684 Controller \u7c7b\uff0c\u4e00\u65e6\u4f7f\u7528\u6784\u9020\u51fd\u6570\u6ce8\u5165\uff0c\u5c31\u65e0\u6cd5\u4f7f\u7528\u9ed8\u8ba4\u6784\u9020\u51fd\u6570"),Object(r.b)("li",{parentName:"ul"},"\u8fd9\u4e2a\u7c7b\u91cc\u9762\u7684\u6709\u4e9b\u65b9\u6cd5\u5e76\u4e0d\u9700\u8981\u7528\u5230\u8fd9\u4e9b\u4f9d\u8d56\uff08Bad smell\uff09")))),Object(r.b)("p",null,"\u4ee3\u7801\u793a\u4f8b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{4}","{4}":!0}),"public class FurService\n{\n private readonly IRepository _repository;\n public FurService(IRepository repository)\n {\n _repository = repository;\n }\n}\n")),Object(r.b)("h3",{id:"1142-\u5c5e\u6027\u65b9\u5f0f\u6ce8\u5165"},"11.4.2 \u5c5e\u6027\u65b9\u5f0f\u6ce8\u5165"),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"\u901a\u8fc7\u5c5e\u6027\u65b9\u5f0f\u6ce8\u5165\u5bb9\u6613\u548c\u7c7b\u7684\u5b9e\u4f8b\u5c5e\u6027\u6df7\u6dc6\uff0c\u4e0d\u5efa\u8bae\u4f7f\u7528\u3002")),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u4f18\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u5728\u5bf9\u8c61\u7684\u6574\u4e2a\u751f\u547d\u5468\u671f\u5185\uff0c\u53ef\u4ee5\u968f\u65f6\u52a8\u6001\u7684\u6539\u53d8\u4f9d\u8d56"),Object(r.b)("li",{parentName:"ul"},"\u975e\u5e38\u7075\u6d3b"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u7f3a\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u5bf9\u8c61\u5728\u521b\u5efa\u540e\uff0c\u88ab\u8bbe\u7f6e\u4f9d\u8d56\u5bf9\u8c61\u4e4b\u524d\u8fd9\u6bb5\u65f6\u95f4\u72b6\u6001\u662f\u4e0d\u5bf9\u7684"),Object(r.b)("li",{parentName:"ul"},"\u4e0d\u76f4\u89c2\uff0c\u65e0\u6cd5\u6e05\u6670\u5730\u8868\u793a\u54ea\u4e9b\u5c5e\u6027\u662f\u5fc5\u987b\u7684")))),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{3}","{3}":!0}),"public class FurService\n{\n public IRepository Repository { get; set; }\n}\n")),Object(r.b)("h3",{id:"1143-\u65b9\u6cd5\u53c2\u6570\u6ce8\u5165"},"11.4.3 \u65b9\u6cd5\u53c2\u6570\u6ce8\u5165"),Object(r.b)("p",null,"\u65b9\u6cd5\u53c2\u6570\u6ce8\u5165\u7684\u610f\u601d\u662f\u5728\u521b\u5efa\u5bf9\u8c61\u540e\uff0c\u901a\u8fc7\u81ea\u52a8\u8c03\u7528\u67d0\u4e2a\u65b9\u6cd5\u6765\u6ce8\u5165\u4f9d\u8d56\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u4f18\u70b9\uff1a"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u6bd4\u8f83\u7075\u6d3b"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u7f3a\u70b9\uff1a"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u65b0\u52a0\u5165\u4f9d\u8d56\u65f6\u4f1a\u7834\u574f\u539f\u6709\u7684\u65b9\u6cd5\u7b7e\u540d\uff0c\u5982\u679c\u8fd9\u4e2a\u65b9\u6cd5\u5df2\u7ecf\u88ab\u5176\u4ed6\u5f88\u591a\u6a21\u5757\u7528\u5230\u5c31\u5f88\u9ebb\u70e6"),Object(r.b)("li",{parentName:"ul"},"\u4e0e\u6784\u9020\u65b9\u6cd5\u6ce8\u5165\u4e00\u6837\uff0c\u4f1a\u6709\u5f88\u591a\u53c2\u6570")))),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{3}","{3}":!0}),"public class FurService\n{\n public Person GetById([FromServices]IRepository repository, int id)\n {\n return repository.Find(id);\n }\n}\n")),Object(r.b)("h2",{id:"115-\u6ce8\u518c\u5bf9\u8c61\u751f\u5b58\u671f"},"11.5 \u6ce8\u518c\u5bf9\u8c61\u751f\u5b58\u671f"),Object(r.b)("h3",{id:"1151-\u6682\u65f6\u77ac\u65f6-\u751f\u5b58\u671f"},"11.5.1 ",Object(r.b)("inlineCode",{parentName:"h3"},"\u6682\u65f6/\u77ac\u65f6")," \u751f\u5b58\u671f"),Object(r.b)("p",null,"\u6682\u65f6\u751f\u5b58\u671f\u670d\u52a1\u662f\u6bcf\u6b21\u4ece\u670d\u52a1\u5bb9\u5668\u8fdb\u884c\u8bf7\u6c42\u65f6\u521b\u5efa\u7684\u3002 \u8fd9\u79cd\u751f\u5b58\u671f\u9002\u5408\u8f7b\u91cf\u7ea7\u3001 \u65e0\u72b6\u6001\u7684\u670d\u52a1\u3002"),Object(r.b)("p",null,"\u5728\u5904\u7406\u8bf7\u6c42\u7684\u5e94\u7528\u4e2d\uff0c\u5728\u8bf7\u6c42\u7ed3\u675f\u65f6\u4f1a\u91ca\u653e\u6682\u65f6\u670d\u52a1\u3002"),Object(r.b)("p",null,"\u901a\u5e38\u6211\u4eec\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"ITransient")," \u63a5\u53e3\u4f9d\u8d56\u8868\u793a\u8be5\u751f\u547d\u5468\u671f\u3002"),Object(r.b)("h3",{id:"1152-\u4f5c\u7528\u57df-\u751f\u5b58\u671f"},"11.5.2 ",Object(r.b)("inlineCode",{parentName:"h3"},"\u4f5c\u7528\u57df")," \u751f\u5b58\u671f"),Object(r.b)("p",null,"\u4f5c\u7528\u57df\u751f\u5b58\u671f\u670d\u52a1\u9488\u5bf9\u6bcf\u4e2a\u5ba2\u6237\u7aef\u8bf7\u6c42\uff08\u8fde\u63a5\uff09\u521b\u5efa\u4e00\u6b21\u3002\u5728\u5904\u7406\u8bf7\u6c42\u7684\u5e94\u7528\u4e2d\uff0c\u5728\u8bf7\u6c42\u7ed3\u675f\u65f6\u4f1a\u91ca\u653e\u6709\u4f5c\u7528\u57df\u7684\u670d\u52a1\u3002"),Object(r.b)("p",null,"\u901a\u5e38\u6211\u4eec\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"IScoped")," \u63a5\u53e3\u4f9d\u8d56\u8868\u793a\u8be5\u751f\u547d\u5468\u671f\u3002"),Object(r.b)("h3",{id:"1153-\u5355\u4f8b-\u751f\u5b58\u671f"},"11.5.3 ",Object(r.b)("inlineCode",{parentName:"h3"},"\u5355\u4f8b")," \u751f\u5b58\u671f"),Object(r.b)("p",null,"\u5728\u9996\u6b21\u8bf7\u6c42\u5b83\u4eec\u65f6\u8fdb\u884c\u521b\u5efa\uff0c\u4e4b\u540e\u6bcf\u4e2a\u540e\u7eed\u8bf7\u6c42\u90fd\u4f7f\u7528\u76f8\u540c\u7684\u5b9e\u4f8b\u3002"),Object(r.b)("p",null,"\u901a\u5e38\u6211\u4eec\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"ISingleton")," \u63a5\u53e3\u4f9d\u8d56\u8868\u793a\u8be5\u751f\u547d\u5468\u671f\u3002"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(r.b)("inlineCode",{parentName:"p"},"\u670d\u52a1\u751f\u5b58\u671f")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(r.b)("a",Object(i.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-5.0#service-lifetimes"}),"ASP.NET Core - \u4f9d\u8d56\u6ce8\u5165 - \u670d\u52a1\u751f\u5b58\u671f")," \u7ae0\u8282\u3002"))),Object(r.b)("h2",{id:"116-\u5185\u7f6e\u4f9d\u8d56\u63a5\u53e3"},"11.6 \u5185\u7f6e\u4f9d\u8d56\u63a5\u53e3"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e09\u4e2a\u63a5\u53e3\u4f9d\u8d56\u5206\u522b\u5bf9\u5e94\u4e0d\u540c\u7684\u670d\u52a1\u751f\u5b58\u671f\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ITransient"),"\uff1a\u5bf9\u5e94\u6682\u65f6/\u77ac\u65f6\u4f5c\u7528\u57df\u670d\u52a1\u751f\u5b58\u671f"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"IScoped"),"\uff1a\u5bf9\u5e94\u8bf7\u6c42\u4f5c\u7528\u57df\u670d\u52a1\u751f\u5b58\u671f"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ISingleton"),"\uff1a\u5bf9\u5e94\u5355\u4f8b\u4f5c\u7528\u57df\u670d\u52a1\u751f\u5b58\u671f")),Object(r.b)("h2",{id:"117-\u5e38\u89c1\u4f7f\u7528"},"11.7 \u5e38\u89c1\u4f7f\u7528"),Object(r.b)("h3",{id:"1172-\u7b2c\u4e00\u4e2a\u4f8b\u5b50"},"11.7.2 \u7b2c\u4e00\u4e2a\u4f8b\u5b50"),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"IBusinessService")," \u63a5\u53e3\u548c ",Object(r.b)("inlineCode",{parentName:"p"},"BusinessService")," \u5b9e\u73b0\u7c7b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,12}","{7,12}":!0}),"using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing Fur.DependencyInjection;\n\nnamespace Fur.Application\n{\n public interface IBusinessService\n {\n Person Get(int id);\n }\n\n public class BusinessService : IBusinessService, ITransient\n {\n private readonly IRepository _personRepository;\n\n public BusinessService(IRepository personRepository)\n {\n _personRepository = personRepository;\n }\n\n public Person Get(int id)\n {\n return _personRepository.Find(id);\n }\n }\n}\n")),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"PersonController")," \u63a7\u5236\u5668\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{11,19}","{11,19}":!0}),'using Fur.Application;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n [ApiController]\n public class PersonController : ControllerBase\n {\n private readonly IBusinessService _businessService;\n public PersonController(IBusinessService businessService)\n {\n _businessService = businessService;\n }\n\n [HttpGet]\n public IActionResult Get(int id)\n {\n var person = _businessService.Get(id);\n return new JsonResult(person);\n }\n }\n}\n')),Object(r.b)("img",{src:Object(c.a)("img/di1.gif")}),Object(r.b)("hr",null),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"\u4f8b\u5b50\u89e3\u8bf4")),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u4e14\u65b9\u4fbf\u7684\u5b9e\u73b0\u4f9d\u8d56\u6ce8\u5165\u7684\u65b9\u5f0f\uff0c\u53ea\u9700\u8981\u5b9e\u4f8b\u7c7b\u7ee7\u627f\u5bf9\u5e94\u751f\u5b58\u671f\u7684\u63a5\u53e3\u5373\u53ef\uff0c\u8fd9\u91cc\u7ee7\u627f\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"ITransient"),"\uff0c\u4e5f\u5c31\u8868\u660e\u4e86\u8fd9\u662f\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"\u6682\u65f6/\u77ac\u65f6")," \u4f5c\u7528\u57df\u5b9e\u4f8b\u7c7b\u3002\u8be5\u7c7b\u5c31\u53ef\u4ee5\u4f5c\u4e3a\u88ab\u6ce8\u5165\u5bf9\u8c61\uff0c\u540c\u65f6\u4e5f\u80fd\u6ce8\u5165\u5176\u4ed6\u63a5\u53e3\u5bf9\u8c61\u3002"),Object(r.b)("p",null,"\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"BusinessService")," \u6ce8\u5165\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"IRepository")," \u4ed3\u50a8\u63a5\u53e3\uff0c\u540c\u65f6 ",Object(r.b)("inlineCode",{parentName:"p"},"PersonController")," \u63a7\u5236\u5668\u6ce8\u5165\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"IBusinessService")," \u63a5\u53e3\u3002"),Object(r.b)("p",null,"\u8fd9\u6837 ",Object(r.b)("inlineCode",{parentName:"p"},"PersonController")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"BusinessService")," \u4e4b\u95f4\u5c31\u5b9e\u73b0\u4e86\u89e3\u8026\uff0c\u4e0d\u518d\u4f9d\u8d56\u4e8e\u5177\u4f53\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"BusinessService")," \u5b9e\u4f8b\u3002"),Object(r.b)("p",null,"\u8fd9\u5c31\u662f\u4f9d\u8d56\u6ce8\u5165/\u63a7\u5236\u53cd\u8f6c\u6700\u7ecf\u5178\u7684\u4f8b\u5b50\u3002"),Object(r.b)("h3",{id:"1173-\u6ce8\u518c\u6cdb\u578b\u5b9e\u4f8b"},"11.7.3 \u6ce8\u518c\u6cdb\u578b\u5b9e\u4f8b"),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"IBusinessService")," \u63a5\u53e3\u548c ",Object(r.b)("inlineCode",{parentName:"p"},"BusinessService")," \u5b9e\u73b0\u7c7b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,12}","{7,12}":!0}),"using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing Fur.DependencyInjection;\n\nnamespace Fur.Application\n{\n public interface IBusinessService\n {\n Person Get(int id);\n }\n\n public class BusinessService : IBusinessService, ITransient\n {\n private readonly IRepository _personRepository;\n\n public BusinessService(IRepository personRepository)\n {\n _personRepository = personRepository;\n }\n\n public Person Get(int id)\n {\n return _personRepository.Find(id);\n }\n }\n}\n")),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"PersonController")," \u63a7\u5236\u5668\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{11,19}","{11,19}":!0}),'using Fur.Application;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n [ApiController]\n public class PersonController : ControllerBase\n {\n private readonly IBusinessService _businessService;\n public PersonController(IBusinessService businessService)\n {\n _businessService = businessService;\n }\n\n [HttpGet]\n public IActionResult Get(int id)\n {\n var person = _businessService.Get(id);\n return new JsonResult(person);\n }\n }\n}\n')),Object(r.b)("h3",{id:"1174-\u4e00\u4e2a\u63a5\u53e3\u591a\u4e2a\u5b9e\u73b0"},"11.7.4 \u4e00\u4e2a\u63a5\u53e3\u591a\u4e2a\u5b9e\u73b0"),Object(r.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e00\u4e2a\u63a5\u53e3\u53ea\u5bf9\u5e94\u4e00\u4e2a\u5b9e\u73b0\u7c7b\uff0c\u4f46\u6709\u4e9b\u7279\u6b8a\u60c5\u51b5\uff0c\u9700\u8981\u9700\u8981\u591a\u4e2a\u5b9e\u73b0\u7c7b\u6ce8\u518c\u540c\u4e00\u4e2a\u63a5\u53e3\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"p"},"DbContext")," \u591a\u6570\u636e\u5e93\u60c5\u51b5\u3002"),Object(r.b)("p",null,"\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4f9d\u8d56\u6ce8\u5165 ",Object(r.b)("inlineCode",{parentName:"p"},"Func")," \u59d4\u6258\u6765\u89e3\u6790\u591a\u4e2a\u5b9e\u4f8b\uff0c\u5176\u4e2d\u59d4\u6258\u7684\u53c2\u6570\u5206\u522b\u4e3a\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u53c2\u6570 1\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"string")," \u7c7b\u578b\uff0c\u4e0d\u540c\u5b9e\u73b0\u7c7b\u552f\u4e00\u6807\u8bc6\uff0c\u9ed8\u8ba4\u4e3a ",Object(r.b)("inlineCode",{parentName:"li"},"nameof(\u5b9e\u73b0\u7c7b)")," \u540d\u79f0"),Object(r.b)("li",{parentName:"ul"},"\u53c2\u6570 2\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Type")," \u7c7b\u578b\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"IPrivateDependency")," \u6d3e\u751f\u63a5\u53e3\uff0c\u4e5f\u5c31\u662f ",Object(r.b)("inlineCode",{parentName:"li"},"ITransient"),"\u3001",Object(r.b)("inlineCode",{parentName:"li"},"IScoped"),"\u3001",Object(r.b)("inlineCode",{parentName:"li"},"ISingleton")),Object(r.b)("li",{parentName:"ul"},"\u8fd4\u56de\u503c\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"object")," \u7c7b\u578b\uff0c\u8fd4\u56de\u5177\u4f53\u7684\u5b9e\u73b0\u7c7b\u5b9e\u4f8b")),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"IBusinessService")," \u63a5\u53e3\u548c ",Object(r.b)("inlineCode",{parentName:"p"},"BusinessService"),"\u3001",Object(r.b)("inlineCode",{parentName:"p"},"OtherBusinessService")," \u4e24\u4e2a\u5b9e\u73b0\u7c7b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,10,18}","{5,10,18}":!0}),'using Fur.DependencyInjection;\n\nnamespace Fur.Application\n{\n public interface IBusinessService\n {\n string GetName();\n }\n\n public class BusinessService : IBusinessService, ITransient\n {\n public string GetName()\n {\n return "\u6211\u662f\uff1a" + nameof(BusinessService);\n }\n }\n\n public class OtherBusinessService : IBusinessService, ITransient\n {\n public string GetName()\n {\n return "\u6211\u662f\uff1a" + nameof(OtherBusinessService);\n }\n }\n}\n')),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"ValueController")," \u63a7\u5236\u5668\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{15,17,18}","{15,17,18}":!0}),'using Fur.Application;\nusing Fur.DependencyInjection;\nusing Microsoft.AspNetCore.Mvc;\nusing System;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n [ApiController]\n public class ValueController : ControllerBase\n {\n private readonly IBusinessService _businessService;\n private readonly IBusinessService _otherBusinessService;\n\n public ValueController(Func resolveNamed)\n {\n _businessService = resolveNamed("BusinessService", default) as IBusinessService;\n _otherBusinessService = resolveNamed("OtherBusinessService", default) as IBusinessService;\n }\n\n [HttpGet]\n public string GetName()\n {\n return _businessService.GetName() + "----------" + _otherBusinessService.GetName();\n }\n }\n}\n')),Object(r.b)("img",{src:Object(c.a)("img/di2.gif")}),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5982\u679c\u9700\u8981\u81ea\u5b9a\u4e49\u89e3\u6790\u540d\u79f0\uff0c\u53ea\u9700\u8981\u8d34 ",Object(r.b)("inlineCode",{parentName:"p"},'[Injection(Named = "\u540d\u79f0")]')," \u5373\u53ef\uff0c\u5982\uff1a"),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,11}","{5,11}":!0}),'using Fur.DependencyInjection;\n\nnamespace Fur.Application\n{\n [Injection(Named = "BusName1")]\n public class BusinessService : IBusinessService, ITransient\n {\n // ...\n }\n\n [Injection(Named = "BusName2")]\n public class OtherBusinessService : IBusinessService, ITransient\n {\n // ...\n }\n}\n')),Object(r.b)("p",{parentName:"div"},"\u89e3\u6790\u670d\u52a1\uff1a"),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs"}),'_businessService = resolveNamed("BusName1", default) as IBusinessService;\n_otherBusinessService = resolveNamed("BusName2", default) as IBusinessService;\n')))),Object(r.b)("h3",{id:"1175-\u65e0\u63a5\u53e3\u65b9\u5f0f"},"11.7.5 \u65e0\u63a5\u53e3\u65b9\u5f0f"),Object(r.b)("p",null,"\u6709\u4e9b\u65f6\u5019\uff0c\u6211\u4eec\u4e0d\u60f3\u5b9a\u4e49\u63a5\u53e3\uff0c\u800c\u662f\u60f3\u628a\u5b9e\u4f8b\u7c7b\u4f5c\u4e3a\u53ef\u4f9d\u8d56\u6ce8\u5165\u7684\u5bf9\u8c61\uff0c\u5982 MVC \u4e2d\u7684\u63a7\u5236\u5668\u3002"),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"SelfService")," \u5b9e\u4f8b\u7c7b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,11}","{7,11}":!0}),"using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing Fur.DependencyInjection;\n\nnamespace Fur.Application\n{\n public class SelfService : ITransient\n {\n private readonly IRepository _personRepository;\n\n public SelfService(IRepository personRepository)\n {\n _personRepository = personRepository;\n }\n\n public Person Get(int id)\n {\n return _personRepository.Find(id);\n }\n }\n}\n")),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"ValueController")," \u63a7\u5236\u5668\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{13,21}","{13,21}":!0}),'using Fur.Application;\nusing Fur.Core;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n [ApiController]\n public class ValueController : ControllerBase\n {\n private readonly SelfService _selfService;\n\n public ValueController(SelfService selfService)\n {\n _selfService = selfService;\n }\n\n [HttpGet]\n public Person Get(int id)\n {\n return _selfService.Get(id);\n }\n }\n}\n')),Object(r.b)("h2",{id:"118-injection-\u7279\u6027\u914d\u7f6e"},"11.8 ",Object(r.b)("inlineCode",{parentName:"h2"},"[Injection]")," \u7279\u6027\u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b ",Object(r.b)("inlineCode",{parentName:"p"},"[Injection]")," \u7279\u6027\u53ef\u4ee5\u6539\u53d8\u6ce8\u518c\u65b9\u5f0f\uff0c\u540c\u65f6\u8fd8\u80fd\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"AOP")," \u62e6\u622a\u3002"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"[Injection]")," \u63d0\u4f9b\u4ee5\u4e0b\u914d\u7f6e\u652f\u6301\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Action"),"\uff1a\u914d\u7f6e\u6ce8\u518c\u884c\u4e3a\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"InjectionActions")," \u7c7b\u578b\uff0c\u53ef\u9009\u503c\uff1a",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Add"),"\uff1a",Object(r.b)("strong",{parentName:"li"},"\u9ed8\u8ba4\u503c"),"\uff0c\u8868\u793a\u65e0\u9650\u5236\u6dfb\u52a0\u6ce8\u518c\u670d\u52a1\uff0c\u8be5\u65b9\u5f0f\u652f\u6301\u4e00\u4e2a\u63a5\u53e3\u591a\u4e2a\u5b9e\u73b0"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"TryAdd"),"\uff1a\u8868\u793a\u6ce8\u518c\u5df2\u5b58\u5728\u5219\u8df3\u8fc7\u6ce8\u518c"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Pattern"),"\uff1a\u914d\u7f6e\u6ce8\u518c\u9009\u9879\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"InjectionPatterns")," \u7c7b\u578b\uff0c\u53ef\u9009\u503c\uff1a",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Self"),"\uff1a\u53ea\u6ce8\u518c\u81ea\u5df1"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"FirstInterface"),"\uff1a\u53ea\u6ce8\u518c\u7b2c\u4e00\u4e2a\u63a5\u53e3"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"SelfWithFirstInterface"),"\uff1a\u6ce8\u518c\u81ea\u5df1\u548c\u7b2c\u4e00\u4e2a\u63a5\u53e3\uff0c",Object(r.b)("strong",{parentName:"li"},"\u9ed8\u8ba4\u503c")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ImplementedInterfaces"),"\uff1a\u6ce8\u518c\u6240\u6709\u63a5\u53e3"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"All"),"\uff1a\u6ce8\u518c\u81ea\u5df1\u5305\u62ec\u6240\u6709\u63a5\u53e3"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Named"),"\uff1a\u914d\u7f6e\u5b9e\u4f8b\u522b\u540d\uff0c\u901a\u8fc7\u522b\u540d\u53ef\u4ee5\u89e3\u6790\u63a5\u53e3\uff0c\u5982\u540c\u4e00\u4e2a\u63a5\u53e3\u6709\u591a\u4e2a\u5b9e\u73b0\uff0c\u90a3\u4e48\u53ef\u4ee5\u901a\u8fc7\u522b\u540d\u89e3\u6790\u4e0d\u540c\u7684\u5b9e\u73b0\uff0c\u9ed8\u8ba4\u53ea\u4e3a\u5b9e\u73b0\u7c7b\u7684\u7c7b\u540d"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Order"),"\uff1a\u6ce8\u518c\u6392\u5e8f\uff0c\u6570\u5b57\u8d8a\u5927\uff0c\u5219\u8d8a\u5728\u6700\u540e\u6ce8\u518c\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"0")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Proxy"),"\uff1a\u914d\u7f6e\u4ee3\u7406\u62e6\u622a\u7c7b\u578b\uff0c\u4e5f\u5c31\u662f ",Object(r.b)("inlineCode",{parentName:"li"},"AOP"),"\uff0c",Object(r.b)("strong",{parentName:"li"},"\u4ee3\u7406\u7c7b\u578b\u5fc5\u987b\u7ee7\u627f ",Object(r.b)("inlineCode",{parentName:"strong"},"DispatchProxy")," \u7c7b\u548c ",Object(r.b)("inlineCode",{parentName:"strong"},"IDispatchProxy")," \u63a5\u53e3"),"\uff0c\u65e0\u9ed8\u8ba4\u503c")),Object(r.b)("h2",{id:"119-\u81ea\u5b9a\u4e49\u9ad8\u7ea7\u6ce8\u518c"},"11.9 \u81ea\u5b9a\u4e49\u9ad8\u7ea7\u6ce8\u518c"),Object(r.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u7684\u6ce8\u518c\u65b9\u5f0f\u53ef\u4ee5\u6ee1\u8db3\u5927\u591a\u6570\u4f9d\u8d56\u6ce8\u5165\u7684\u9700\u6c42\uff0c\u5982\u6709\u7279\u522b\u6ce8\u518c\u9700\u6c42\uff0c\u53ea\u9700\u8981\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Startup")," \u4e2d\u914d\u7f6e\u5373\u53ef\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs"}),"services.AddScoped(typeof(ISpecService), provider = > {\n // \u81ea\u5b9a\u4e49\u4efb\u4f55\u521b\u5efa\u5b9e\u4f8b\u7684\u65b9\u5f0f\n var instance = new SpecService(); // \u6216\u8005\u53ef\u4ee5\u901a\u8fc7 AOP\u63d2\u4ef6\u8fd4\u56de\u4ee3\u7406\u5b9e\u4f8b\n\n return instance;\n});\n")),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u8865\u5145\u8bf4\u660e")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u8fd8\u6709 ",Object(r.b)("inlineCode",{parentName:"p"},"ISqlDispatchProxy")," \u90fd\u662f\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u521b\u5efa\u7684\u3002"))),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u77e5\u8bc6\u5bfc\u822a")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a\u81ea\u5b9a\u4e49\u9ad8\u7ea7\u4e2d\u6ce8\u518c\uff0c\u53ef\u67e5\u9605 \u3010",Object(r.b)("a",Object(i.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-5.0"}),"ASP.NET Core \u4f9d\u8d56\u6ce8\u5165"),"\u3011 \u5b98\u65b9\u6587\u6863\u3002"))),Object(r.b)("h2",{id:"1110-appsettingsjson-\u914d\u7f6e\u6ce8\u518c"},"11.10 ",Object(r.b)("inlineCode",{parentName:"h2"},"appsettings.json")," \u914d\u7f6e\u6ce8\u518c"),Object(r.b)("p",null,"\u9664\u4e86\u5728\u4ee3\u7801\u4e2d\u5b9e\u73b0\u4f9d\u8d56\u6ce8\u5165\uff0c\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u52a8\u6001\u4f9d\u8d56\u6ce8\u5165\uff0c\u65e0\u9700\u4fee\u6539\u4ee3\u7801\u6216\u91cd\u65b0\u7f16\u8bd1\u5373\u53ef\u5b9e\u73b0\u70ed\u62d4\u63d2\uff08\u63d2\u4ef6\uff09\u6548\u679c\u3002\u914d\u7f6e\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-json",metastring:"{3}","{3}":!0}),'{\n "AppSettings": {\n "DependencyInjectionSettings": {\n "Definitions": [\n {\n "Interface": "Fur.Application;Fur.Application.ITestService",\n "Service": "Fur.Application;Fur.Application.TestService",\n "RegisterType": "Transient",\n "Action": "Add",\n "Pattern": "SelfWithFirstInterface",\n "Named": "TestService",\n "Order": 1,\n "Proxy": "Fur.Application;Fur.Application.LogDispathProxy"\n }\n ]\n }\n }\n}\n')),Object(r.b)("p",null,"\u914d\u7f6e\u8bf4\u660e\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DependencyInjectionSettings"),"\uff1a\u4f9d\u8d56\u6ce8\u5165\u914d\u7f6e\u6839\u8282\u70b9",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Definitions"),"\uff1a\u52a8\u6001\u4f9d\u8d56\u6ce8\u5165\u914d\u7f6e\u8282\u70b9\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"ExternalService")," \u6570\u7ec4\u7c7b\u578b",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ExternalService"),"\uff1a\u914d\u7f6e\u5355\u4e2a\u4f9d\u8d56\u6ce8\u5165\u4fe1\u606f",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Interface"),"\uff1a\u914d\u7f6e\u4f9d\u8d56\u63a5\u53e3\u4fe1\u606f\uff0c\u683c\u5f0f\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"\u7a0b\u5e8f\u96c6\u540d\u79f0;\u63a5\u53e3\u5b8c\u6574\u540d\u79f0"),"\uff0c\u5982\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Fur.Application;Fur.Application.ITestService")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Service"),"\uff1a\u914d\u7f6e\u63a5\u53e3\u5b9e\u73b0\u4fe1\u606f\uff0c\u683c\u5f0f\u540c\u4e0a"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"RegisterType"),"\uff1a\u914d\u7f6e\u4f9d\u8d56\u6ce8\u5165\u7684\u5bf9\u8c61\u751f\u5b58\u671f\uff0c\u53d6\u503c\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Transient"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"Scoped"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"Singleton")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Action"),"\uff1a\u6ce8\u518c\u884c\u4e3a\uff0c\u53ef\u9009\u503c\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Add"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"TryAdd"),"\uff0c\u53c2\u89c1 ",Object(r.b)("a",Object(i.a)({parentName:"li"},{href:"#118-injection-%E7%89%B9%E6%80%A7%E9%85%8D%E7%BD%AE"}),"#118-injection-\u7279\u6027\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Pattern"),"\uff1a\u6ce8\u518c\u9009\u9879\uff0c\u53c2\u89c1 ",Object(r.b)("a",Object(i.a)({parentName:"li"},{href:"#118-injection-%E7%89%B9%E6%80%A7%E9%85%8D%E7%BD%AE"}),"#118-injection-\u7279\u6027\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Named"),"\uff1a\u6ce8\u518c\u522b\u540d\uff0c\u53c2\u89c1 ",Object(r.b)("a",Object(i.a)({parentName:"li"},{href:"#118-injection-%E7%89%B9%E6%80%A7%E9%85%8D%E7%BD%AE"}),"#118-injection-\u7279\u6027\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Order"),"\uff1a\u6ce8\u518c\u6392\u5e8f\uff0c\u53c2\u89c1 ",Object(r.b)("a",Object(i.a)({parentName:"li"},{href:"#118-injection-%E7%89%B9%E6%80%A7%E9%85%8D%E7%BD%AE"}),"#118-injection-\u7279\u6027\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Proxy"),"\uff1a\u914d\u7f6e\u4ee3\u7406\u62e6\u622a\uff0c\uff0c\u683c\u5f0f\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"\u7a0b\u5e8f\u96c6\u540d\u79f0;\u4ee3\u7406\u7c7b\u5b8c\u6574\u540d\u79f0"),"\uff0c\u53c2\u89c1 ",Object(r.b)("a",Object(i.a)({parentName:"li"},{href:"#118-injection-%E7%89%B9%E6%80%A7%E9%85%8D%E7%BD%AE"}),"#118-injection-\u7279\u6027\u914d\u7f6e"))))))))),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u5173\u4e8e\u5916\u90e8\u7a0b\u5e8f\u96c6")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5982\u679c\u52a8\u6001\u6ce8\u5165\u7684\u5bf9\u8c61\u662f\u5916\u90e8\u7a0b\u5e8f\u96c6\uff0c\u90a3\u4e48\u9996\u5148\u5148\u6ce8\u518c\u5916\u90e8\u7a0b\u5e8f\u96c6\uff1a"),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-json"}),'{\n "AppSettings": {\n "ExternalAssemblies": ["\u5916\u90e8\u7a0b\u5e8f\u96c6\u540d\u79f0", "Taobao.Pay"] // \u652f\u6301\u591a\u4e2a\n }\n}\n')))),Object(r.b)("h2",{id:"1111-\u6ce8\u518c\u987a\u5e8f\u548c\u4f18\u5148\u7ea7"},"11.11 \u6ce8\u518c\u987a\u5e8f\u548c\u4f18\u5148\u7ea7"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u9ed8\u8ba4\u6ce8\u518c\u987a\u5e8f\u662f\u6309\u7167\u7a0b\u5e8f\u96c6\u626b\u63cf\u987a\u5e8f\u8fdb\u884c\u6ce8\u518c\uff0c\u5982\u679c\u9700\u8981\u6539\u53d8\u6ce8\u518c\u987a\u5e8f\uff0c\u53ef\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"[Injection(Order)]")," \u7279\u6027\u6307\u5b9a\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Order")," \u503c\u8d8a\u5927\uff0c\u5219\u8d8a\u5728\u6700\u540e\u6ce8\u518c\u3002"),Object(r.b)("p",null,"\u53e6\u5916 ",Object(r.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u914d\u7f6e\u7684\u4f18\u5148\u7ea7\u6700\u5927\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u914d\u7f6e\u7684\u6ce8\u518c\u4f1a\u8986\u76d6\u4e4b\u524d\u6240\u6709\u6ce8\u518c\u3002"),Object(r.b)("h2",{id:"1112-aop-\u6ce8\u518c\u62e6\u622a"},"11.12 ",Object(r.b)("inlineCode",{parentName:"h2"},"Aop")," \u6ce8\u518c\u62e6\u622a"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"AOP")," \u662f\u975e\u5e38\u91cd\u8981\u7684\u601d\u60f3\u548c\u6280\u672f\uff0c\u4e5f\u5c31\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"\u9762\u5411\u5207\u9762")," \u7f16\u7a0b\uff0c\u53ef\u4ee5\u8ba9\u6211\u4eec\u5728\u4e0d\u6539\u52a8\u539f\u6765\u4ee3\u7801\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u52a8\u6001\u7be1\u6539\u4e1a\u52a1\u4ee3\u7801\u3002"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"p"},"Aop")," \u975e\u5e38\u7b80\u5355\uff0c\u5982\uff1a"),Object(r.b)("p",null,"\u5047\u8bbe\u6211\u4eec\u6709 ",Object(r.b)("inlineCode",{parentName:"p"},"ITestService")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"TestService")," \u4e24\u4e2a\u7c7b\u578b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs"}),"public class ITestService\n{\n string SayHello(string word);\n}\n")),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs"}),'public class TestService: ITestService, ITransient\n{\n public string SayHello(string word)\n {\n return $"Hello {word}";\n }\n}\n')),Object(r.b)("p",null,"\u73b0\u5728\u6211\u4eec\u6709\u4e00\u4e2a\u9700\u6c42\uff0c\u6211\u4eec\u5e0c\u671b\u8c03\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"SayHello")," \u7684\u65f6\u5019\u53ef\u4ee5\u8bb0\u5f55\u65e5\u5fd7\u548c\u6743\u9650\u63a7\u5236\uff08\u4e4b\u524d\u6ca1\u6709\u8003\u8651\u5230\u7684\u9700\u6c42\uff09\u3002"),Object(r.b)("p",null,"\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u53ea\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u4ee3\u7406\u7c7b\u5373\u53ef\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"p"},"LogDispatchProxy")," "),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,3,7,25}","{1,3,7,25}":!0}),'using Fur.DependencyInjection;\nusing System;\nusing System.Reflection;\n\nnamespace Fur.Application\n{\n public class LogDispatchProxy : DispatchProxy, IDispatchProxy\n {\n /// \n /// \u5f53\u524d\u670d\u52a1\u5b9e\u4f8b\n /// \n public object Target { get; set; }\n\n /// \n /// \u670d\u52a1\u63d0\u4f9b\u5668\uff0c\u53ef\u4ee5\u7528\u6765\u89e3\u6790\u670d\u52a1\uff0c\u5982\uff1aServices.GetService()\n /// \n public IServiceProvider Services { get; set; }\n\n /// \n /// \u62e6\u622a\u65b9\u6cd5\n /// \n /// \n /// \n /// \n protected override object Invoke(MethodInfo targetMethod, object[] args)\n {\n Console.WriteLine("SayHello \u65b9\u6cd5\u88ab\u8c03\u7528\u4e86");\n\n var result = targetMethod.Invoke(Target, args);\n\n Console.WriteLine("SayHello \u65b9\u6cd5\u8fd4\u56de\u503c\uff1a" + result);\n\n return result;\n }\n }\n}\n')),Object(r.b)("p",null,"\u4e4b\u540e\u6211\u4eec\u53ea\u9700\u8981\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"TestService")," \u589e\u52a0 ",Object(r.b)("inlineCode",{parentName:"p"},"[Injection]")," \u7279\u6027\u5373\u53ef\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),'[Injection(Proxy = typeof(LogDispatchProxy))]\npublic class TestService: ITestService, ITransient\n{\n public string SayHello(string word)\n {\n return $"Hello {word}";\n }\n}\n')),Object(r.b)("p",null,"\u4e4b\u540e ",Object(r.b)("inlineCode",{parentName:"p"},"SayHello")," \u65b9\u6cd5\u88ab\u8c03\u7528\u7684\u65f6\u5019\u5c31\u53ef\u4ee5\u5b9e\u73b0\u52a8\u6001\u62e6\u622a\u4e86\uff0c\u6bd4\u5982\u8fd9\u91cc\u5199\u65e5\u5fd7\u3002"),Object(r.b)("h3",{id:"11121-aop-\u7684\u4f5c\u7528"},"11.12.1 ",Object(r.b)("inlineCode",{parentName:"h3"},"AOP")," \u7684\u4f5c\u7528"),Object(r.b)("p",null,"\u8fd9\u79cd\u9762\u5411\u5207\u9762\u7684\u80fd\u529b\uff08\u52a8\u6001\u62e6\u622a/\u4ee3\u7406\uff09\u53ef\u4ee5\u5b9e\u73b0\u5f88\u591a\u5f88\u591a\u529f\u80fd\uff0c\u5982\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u52a8\u6001\u65e5\u5fd7\u8bb0\u5f55"),Object(r.b)("li",{parentName:"ul"},"\u52a8\u6001\u4fee\u6539\u53c2\u6570"),Object(r.b)("li",{parentName:"ul"},"\u52a8\u6001\u4fee\u6539\u8fd4\u56de\u503c"),Object(r.b)("li",{parentName:"ul"},"\u52a8\u6001\u65b9\u6cd5\u91cd\u5b9a\u5411"),Object(r.b)("li",{parentName:"ul"},"\u52a8\u6001\u4fee\u6539\u4ee3\u7801\u903b\u8f91"),Object(r.b)("li",{parentName:"ul"},"\u52a8\u6001\u5b9e\u73b0\u5f02\u5e38\u76d1\u542c")),Object(r.b)("p",null,"\u8fd8\u53ef\u4ee5\u505a\u66f4\u591a\u66f4\u591a\u7684\u4e8b\u60c5\u3002"),Object(r.b)("h2",{id:"1113-\u53cd\u9988\u4e0e\u5efa\u8bae"},"11.13 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(i.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}s.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/5e077782.5c58ae24.js b/handbook/build/5e077782.5c58ae24.js deleted file mode 100644 index 3643a2ef1ea..00000000000 --- a/handbook/build/5e077782.5c58ae24.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[34],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return s})),t.d(n,"b",(function(){return d}));var i=t(0),a=t.n(i);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function b(e){for(var n=1;n=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}var o=a.a.createContext({}),p=function(e){var n=a.a.useContext(o),t=n;return e&&(t="function"==typeof e?e(n):b(b({},n),e)),t},s=function(e){var n=p(e.components);return a.a.createElement(o.Provider,{value:n},e.children)},u={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},j=a.a.forwardRef((function(e,n){var t=e.components,i=e.mdxType,r=e.originalType,c=e.parentName,o=l(e,["components","mdxType","originalType","parentName"]),s=p(t),j=i,d=s["".concat(c,".").concat(j)]||s[j]||u[j]||r;return t?a.a.createElement(d,b(b({ref:n},o),{},{components:t})):a.a.createElement(d,b({ref:n},o))}));function d(e,n){var t=arguments,i=n&&n.mdxType;if("string"==typeof e||i){var r=t.length,c=new Array(r);c[0]=j;var b={};for(var l in n)hasOwnProperty.call(n,l)&&(b[l]=n[l]);b.originalType=e,b.mdxType="string"==typeof e?e:i,c[1]=b;for(var o=2;oIOC/DI \u4f18\u7f3a\u70b9",id:"113-iocdi-\u4f18\u7f3a\u70b9",children:[]},{value:"11.4 \u4f9d\u8d56\u6ce8\u5165\u7684\u4e09\u79cd\u65b9\u5f0f",id:"114-\u4f9d\u8d56\u6ce8\u5165\u7684\u4e09\u79cd\u65b9\u5f0f",children:[{value:"11.4.1 \u6784\u9020\u65b9\u6cd5\u6ce8\u5165",id:"1141-\u6784\u9020\u65b9\u6cd5\u6ce8\u5165",children:[]},{value:"11.4.2 \u5c5e\u6027\u65b9\u5f0f\u6ce8\u5165",id:"1142-\u5c5e\u6027\u65b9\u5f0f\u6ce8\u5165",children:[]},{value:"11.4.3 \u65b9\u6cd5\u53c2\u6570\u6ce8\u5165",id:"1143-\u65b9\u6cd5\u53c2\u6570\u6ce8\u5165",children:[]}]},{value:"11.5 \u6ce8\u518c\u5bf9\u8c61\u751f\u5b58\u671f",id:"115-\u6ce8\u518c\u5bf9\u8c61\u751f\u5b58\u671f",children:[{value:"11.5.1 \u6682\u65f6/\u77ac\u65f6 \u751f\u5b58\u671f",id:"1151-\u6682\u65f6\u77ac\u65f6-\u751f\u5b58\u671f",children:[]},{value:"11.5.2 \u4f5c\u7528\u57df \u751f\u5b58\u671f",id:"1152-\u4f5c\u7528\u57df-\u751f\u5b58\u671f",children:[]},{value:"11.5.3 \u5355\u4f8b \u751f\u5b58\u671f",id:"1153-\u5355\u4f8b-\u751f\u5b58\u671f",children:[]}]},{value:"11.6 \u5185\u7f6e\u4f9d\u8d56\u63a5\u53e3",id:"116-\u5185\u7f6e\u4f9d\u8d56\u63a5\u53e3",children:[]},{value:"11.7 \u5e38\u89c1\u4f7f\u7528",id:"117-\u5e38\u89c1\u4f7f\u7528",children:[{value:"11.7.2 \u7b2c\u4e00\u4e2a\u4f8b\u5b50",id:"1172-\u7b2c\u4e00\u4e2a\u4f8b\u5b50",children:[]},{value:"11.7.3 \u6ce8\u518c\u6cdb\u578b\u5b9e\u4f8b",id:"1173-\u6ce8\u518c\u6cdb\u578b\u5b9e\u4f8b",children:[]},{value:"11.7.4 \u4e00\u4e2a\u63a5\u53e3\u591a\u4e2a\u5b9e\u73b0",id:"1174-\u4e00\u4e2a\u63a5\u53e3\u591a\u4e2a\u5b9e\u73b0",children:[]},{value:"11.7.5 \u65e0\u63a5\u53e3\u65b9\u5f0f",id:"1175-\u65e0\u63a5\u53e3\u65b9\u5f0f",children:[]}]},{value:"11.8 [Injection] \u7279\u6027\u914d\u7f6e",id:"118-injection-\u7279\u6027\u914d\u7f6e",children:[]},{value:"11.9 \u81ea\u5b9a\u4e49\u9ad8\u7ea7\u6ce8\u518c",id:"119-\u81ea\u5b9a\u4e49\u9ad8\u7ea7\u6ce8\u518c",children:[]},{value:"11.10 appsettings.json \u914d\u7f6e\u6ce8\u518c",id:"1110-appsettingsjson-\u914d\u7f6e\u6ce8\u518c",children:[]},{value:"11.11 \u6ce8\u518c\u987a\u5e8f\u548c\u4f18\u5148\u7ea7",id:"1111-\u6ce8\u518c\u987a\u5e8f\u548c\u4f18\u5148\u7ea7",children:[]},{value:"11.12 Aop \u6ce8\u518c\u62e6\u622a",id:"1112-aop-\u6ce8\u518c\u62e6\u622a",children:[{value:"11.12.1 AOP \u7684\u4f5c\u7528",id:"11121-aop-\u7684\u4f5c\u7528",children:[]}]},{value:"11.13 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"1113-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],p={rightToc:o};function s(e){var n=e.components,t=Object(a.a)(e,["components"]);return Object(r.b)("wrapper",Object(i.a)({},p,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"111-\u4f9d\u8d56\u6ce8\u5165"},"11.1 \u4f9d\u8d56\u6ce8\u5165"),Object(r.b)("p",null,"\u6240\u8c13\u4f9d\u8d56\u6ce8\u5165\uff0c\u662f\u6307\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\uff0c\u5982\u679c\u9700\u8981\u8c03\u7528\u53e6\u4e00\u4e2a\u5bf9\u8c61\u534f\u52a9\u65f6\uff0c\u65e0\u987b\u5728\u4ee3\u7801\u4e2d\u521b\u5efa\u88ab\u8c03\u7528\u8005\uff0c\u800c\u662f\u4f9d\u8d56\u4e8e\u5916\u90e8\u7684\u6ce8\u5165\u3002"),Object(r.b)("p",null,"\u901a\u4fd7\u6765\u8bb2\uff0c\u5c31\u662f\u628a\u6709\u4f9d\u8d56\u5173\u7cfb\u7684\u7c7b\u653e\u5230\u5bb9\u5668\u4e2d\uff0c\u7136\u540e\u5728\u6211\u4eec\u9700\u8981\u8fd9\u4e9b\u7c7b\u65f6\uff0c\u5bb9\u5668\u81ea\u52a8\u89e3\u6790\u51fa\u8fd9\u4e9b\u7c7b\u7684\u5b9e\u4f8b\u3002"),Object(r.b)("p",null,"\u4f9d\u8d56\u6ce8\u5165\u6700\u5927\u7684\u597d\u5904\u65f6\u5b9e\u73b0\u7c7b\u7684\u89e3\u8026\uff0c\u5229\u4e8e\u7a0b\u5e8f\u62d3\u5c55\u3001\u5355\u5143\u6d4b\u8bd5\u3001\u81ea\u52a8\u5316\u6a21\u62df\u6d4b\u8bd5\u7b49\u3002"),Object(r.b)("p",null,"\u4f9d\u8d56\u6ce8\u5165\u7684\u82f1\u6587\u4e3a\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"Dependency Injection"),"\uff0c\u7b80\u79f0 ",Object(r.b)("inlineCode",{parentName:"p"},"DI")),Object(r.b)("h2",{id:"112-\u63a7\u5236\u53cd\u8f6c"},"11.2 \u63a7\u5236\u53cd\u8f6c"),Object(r.b)("p",null,"\u63a7\u5236\u53cd\u8f6c\u53ea\u662f\u4e00\u4e2a\u6982\u5ff5\uff0c\u4e5f\u5c31\u662f\u5c06\u521b\u5efa\u5bf9\u8c61\u5b9e\u4f8b\u7684\u63a7\u5236\u6743\uff08\u539f\u672c\u662f\u7a0b\u5e8f\u5458\uff09\u4ece\u4ee3\u7801\u63a7\u5236\u6743\u5265\u79bb\u5230 ",Object(r.b)("inlineCode",{parentName:"p"},"IOC \u5bb9\u5668")," \u4e2d\u63a7\u5236\u3002"),Object(r.b)("p",null,"\u63a7\u5236\u53cd\u8f6c\u7684\u82f1\u6587\u4e3a\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"Inversion of Control"),"\uff0c\u7b80\u79f0 ",Object(r.b)("inlineCode",{parentName:"p"},"IOC")),Object(r.b)("h2",{id:"113-iocdi-\u4f18\u7f3a\u70b9"},"11.3 ",Object(r.b)("inlineCode",{parentName:"h2"},"IOC/DI")," \u4f18\u7f3a\u70b9"),Object(r.b)("p",null,"\u4f20\u7edf\u7684\u4ee3\u7801\uff0c\u6bcf\u4e2a\u5bf9\u8c61\u8d1f\u8d23\u7ba1\u7406\u4e0e\u81ea\u5df1\u9700\u8981\u4f9d\u8d56\u7684\u5bf9\u8c61\uff0c\u5bfc\u81f4\u5982\u679c\u9700\u8981\u5207\u6362\u4f9d\u8d56\u5bf9\u8c61\u7684\u5b9e\u73b0\u7c7b\u65f6\uff0c\u9700\u8981\u4fee\u6539\u591a\u5904\u5730\u65b9\u3002\u540c\u65f6\uff0c\u8fc7\u5ea6\u8026\u5408\u4e5f\u4f7f\u5f97\u5bf9\u8c61\u96be\u4ee5\u8fdb\u884c\u5355\u5143\u6d4b\u8bd5\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u4f18\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u4f9d\u8d56\u6ce8\u5165\u628a\u5bf9\u8c61\u7684\u521b\u9020\u4ea4\u7ed9\u5916\u90e8\u53bb\u7ba1\u7406,\u5f88\u597d\u7684\u89e3\u51b3\u4e86\u4ee3\u7801\u7d27\u8026\u5408\uff08tight couple\uff09\u7684\u95ee\u9898\uff0c\u662f\u4e00\u79cd\u8ba9\u4ee3\u7801\u5b9e\u73b0\u677e\u8026\u5408\uff08loose couple\uff09\u7684\u673a\u5236"),Object(r.b)("li",{parentName:"ul"},"\u677e\u8026\u5408\u8ba9\u4ee3\u7801\u66f4\u5177\u7075\u6d3b\u6027\uff0c\u80fd\u66f4\u597d\u5730\u5e94\u5bf9\u9700\u6c42\u53d8\u52a8\uff0c\u4ee5\u53ca\u65b9\u4fbf\u5355\u5143\u6d4b\u8bd5"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u7f3a\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u76ee\u524d\u4e3b\u6d41\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"IOC/DI")," \u57fa\u672c\u91c7\u7528\u53cd\u5c04\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u4f9d\u8d56\u6ce8\u5165\uff0c\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4f1a\u5f71\u54cd\u6027\u80fd")))),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u8bf4\u660e")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5728\u672c\u7ae0\u8282\u4e0d\u6253\u7b97\u7ec6\u8bb2 ",Object(r.b)("inlineCode",{parentName:"p"},"\u4f9d\u8d56\u6ce8\u5165/\u63a7\u5236\u53cd\u8f6c")," \u5177\u4f53\u5b9e\u73b0\u548c\u5e94\u7528\u573a\u666f\uff0c\u60f3\u4e86\u89e3\u66f4\u591a\u77e5\u8bc6\uff0c\u53ef\u67e5\u9605 \u3010",Object(r.b)("a",Object(i.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-5.0"}),"ASP.NET Core \u4f9d\u8d56\u6ce8\u5165"),"\u3011 \u5b98\u65b9\u6587\u6863\u3002"))),Object(r.b)("h2",{id:"114-\u4f9d\u8d56\u6ce8\u5165\u7684\u4e09\u79cd\u65b9\u5f0f"},"11.4 \u4f9d\u8d56\u6ce8\u5165\u7684\u4e09\u79cd\u65b9\u5f0f"),Object(r.b)("h3",{id:"1141-\u6784\u9020\u65b9\u6cd5\u6ce8\u5165"},"11.4.1 \u6784\u9020\u65b9\u6cd5\u6ce8\u5165"),Object(r.b)("p",null,"\u76ee\u524d\u6784\u9020\u65b9\u6cd5\u6ce8\u5165\u662f\u4f9d\u8d56\u6ce8\u5165\u63a8\u8350\u4f7f\u7528\u65b9\u5f0f\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u4f18\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u5728\u6784\u9020\u65b9\u6cd5\u4e2d\u4f53\u73b0\u51fa\u5bf9\u5176\u4ed6\u7c7b\u7684\u4f9d\u8d56\uff0c\u4e00\u773c\u5c31\u80fd\u770b\u51fa\u8fd9\u4e2a\u7c7b\u9700\u8981\u5176\u4ed6\u90a3\u4e9b\u7c7b\u624d\u80fd\u5de5\u4f5c"),Object(r.b)("li",{parentName:"ul"},"\u8131\u79bb\u4e86 IOC \u6846\u67b6\uff0c\u8fd9\u4e2a\u7c7b\u4ecd\u7136\u53ef\u4ee5\u5de5\u4f5c\uff0cPOJO \u7684\u6982\u5ff5"),Object(r.b)("li",{parentName:"ul"},"\u4e00\u65e6\u5bf9\u8c61\u521d\u59cb\u5316\u6210\u529f\u4e86\uff0c\u8fd9\u4e2a\u5bf9\u8c61\u7684\u72b6\u6001\u80af\u5b9a\u662f\u6b63\u786e\u7684"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u7f3a\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u6784\u9020\u51fd\u6570\u4f1a\u6709\u5f88\u591a\u53c2\u6570\uff08Bad smell\uff09"),Object(r.b)("li",{parentName:"ul"},"\u6709\u4e9b\u7c7b\u662f\u9700\u8981\u9ed8\u8ba4\u6784\u9020\u51fd\u6570\u7684\uff0c\u6bd4\u5982 MVC \u6846\u67b6\u7684 Controller \u7c7b\uff0c\u4e00\u65e6\u4f7f\u7528\u6784\u9020\u51fd\u6570\u6ce8\u5165\uff0c\u5c31\u65e0\u6cd5\u4f7f\u7528\u9ed8\u8ba4\u6784\u9020\u51fd\u6570"),Object(r.b)("li",{parentName:"ul"},"\u8fd9\u4e2a\u7c7b\u91cc\u9762\u7684\u6709\u4e9b\u65b9\u6cd5\u5e76\u4e0d\u9700\u8981\u7528\u5230\u8fd9\u4e9b\u4f9d\u8d56\uff08Bad smell\uff09")))),Object(r.b)("p",null,"\u4ee3\u7801\u793a\u4f8b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{4}","{4}":!0}),"public class FurService\n{\n private readonly IRepository _repository;\n public FurService(IRepository repository)\n {\n _repository = repository;\n }\n}\n")),Object(r.b)("h3",{id:"1142-\u5c5e\u6027\u65b9\u5f0f\u6ce8\u5165"},"11.4.2 \u5c5e\u6027\u65b9\u5f0f\u6ce8\u5165"),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"\u901a\u8fc7\u5c5e\u6027\u65b9\u5f0f\u6ce8\u5165\u5bb9\u6613\u548c\u7c7b\u7684\u5b9e\u4f8b\u5c5e\u6027\u6df7\u6dc6\uff0c\u4e0d\u5efa\u8bae\u4f7f\u7528\u3002")),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u4f18\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u5728\u5bf9\u8c61\u7684\u6574\u4e2a\u751f\u547d\u5468\u671f\u5185\uff0c\u53ef\u4ee5\u968f\u65f6\u52a8\u6001\u7684\u6539\u53d8\u4f9d\u8d56"),Object(r.b)("li",{parentName:"ul"},"\u975e\u5e38\u7075\u6d3b"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u7f3a\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u5bf9\u8c61\u5728\u521b\u5efa\u540e\uff0c\u88ab\u8bbe\u7f6e\u4f9d\u8d56\u5bf9\u8c61\u4e4b\u524d\u8fd9\u6bb5\u65f6\u95f4\u72b6\u6001\u662f\u4e0d\u5bf9\u7684"),Object(r.b)("li",{parentName:"ul"},"\u4e0d\u76f4\u89c2\uff0c\u65e0\u6cd5\u6e05\u6670\u5730\u8868\u793a\u54ea\u4e9b\u5c5e\u6027\u662f\u5fc5\u987b\u7684")))),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{3}","{3}":!0}),"public class FurService\n{\n public IRepository Repository { get; set; }\n}\n")),Object(r.b)("h3",{id:"1143-\u65b9\u6cd5\u53c2\u6570\u6ce8\u5165"},"11.4.3 \u65b9\u6cd5\u53c2\u6570\u6ce8\u5165"),Object(r.b)("p",null,"\u65b9\u6cd5\u53c2\u6570\u6ce8\u5165\u7684\u610f\u601d\u662f\u5728\u521b\u5efa\u5bf9\u8c61\u540e\uff0c\u901a\u8fc7\u81ea\u52a8\u8c03\u7528\u67d0\u4e2a\u65b9\u6cd5\u6765\u6ce8\u5165\u4f9d\u8d56\u3002"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u4f18\u70b9\uff1a"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u6bd4\u8f83\u7075\u6d3b"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u7f3a\u70b9\uff1a"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u65b0\u52a0\u5165\u4f9d\u8d56\u65f6\u4f1a\u7834\u574f\u539f\u6709\u7684\u65b9\u6cd5\u7b7e\u540d\uff0c\u5982\u679c\u8fd9\u4e2a\u65b9\u6cd5\u5df2\u7ecf\u88ab\u5176\u4ed6\u5f88\u591a\u6a21\u5757\u7528\u5230\u5c31\u5f88\u9ebb\u70e6"),Object(r.b)("li",{parentName:"ul"},"\u4e0e\u6784\u9020\u65b9\u6cd5\u6ce8\u5165\u4e00\u6837\uff0c\u4f1a\u6709\u5f88\u591a\u53c2\u6570")))),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{3}","{3}":!0}),"public class FurService\n{\n public Person GetById([FromServices]IRepository repository, int id)\n {\n return repository.Find(id);\n }\n}\n")),Object(r.b)("h2",{id:"115-\u6ce8\u518c\u5bf9\u8c61\u751f\u5b58\u671f"},"11.5 \u6ce8\u518c\u5bf9\u8c61\u751f\u5b58\u671f"),Object(r.b)("h3",{id:"1151-\u6682\u65f6\u77ac\u65f6-\u751f\u5b58\u671f"},"11.5.1 ",Object(r.b)("inlineCode",{parentName:"h3"},"\u6682\u65f6/\u77ac\u65f6")," \u751f\u5b58\u671f"),Object(r.b)("p",null,"\u6682\u65f6\u751f\u5b58\u671f\u670d\u52a1\u662f\u6bcf\u6b21\u4ece\u670d\u52a1\u5bb9\u5668\u8fdb\u884c\u8bf7\u6c42\u65f6\u521b\u5efa\u7684\u3002 \u8fd9\u79cd\u751f\u5b58\u671f\u9002\u5408\u8f7b\u91cf\u7ea7\u3001 \u65e0\u72b6\u6001\u7684\u670d\u52a1\u3002"),Object(r.b)("p",null,"\u5728\u5904\u7406\u8bf7\u6c42\u7684\u5e94\u7528\u4e2d\uff0c\u5728\u8bf7\u6c42\u7ed3\u675f\u65f6\u4f1a\u91ca\u653e\u6682\u65f6\u670d\u52a1\u3002"),Object(r.b)("p",null,"\u901a\u5e38\u6211\u4eec\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"ITransient")," \u63a5\u53e3\u4f9d\u8d56\u8868\u793a\u8be5\u751f\u547d\u5468\u671f\u3002"),Object(r.b)("h3",{id:"1152-\u4f5c\u7528\u57df-\u751f\u5b58\u671f"},"11.5.2 ",Object(r.b)("inlineCode",{parentName:"h3"},"\u4f5c\u7528\u57df")," \u751f\u5b58\u671f"),Object(r.b)("p",null,"\u4f5c\u7528\u57df\u751f\u5b58\u671f\u670d\u52a1\u9488\u5bf9\u6bcf\u4e2a\u5ba2\u6237\u7aef\u8bf7\u6c42\uff08\u8fde\u63a5\uff09\u521b\u5efa\u4e00\u6b21\u3002\u5728\u5904\u7406\u8bf7\u6c42\u7684\u5e94\u7528\u4e2d\uff0c\u5728\u8bf7\u6c42\u7ed3\u675f\u65f6\u4f1a\u91ca\u653e\u6709\u4f5c\u7528\u57df\u7684\u670d\u52a1\u3002"),Object(r.b)("p",null,"\u901a\u5e38\u6211\u4eec\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"IScoped")," \u63a5\u53e3\u4f9d\u8d56\u8868\u793a\u8be5\u751f\u547d\u5468\u671f\u3002"),Object(r.b)("h3",{id:"1153-\u5355\u4f8b-\u751f\u5b58\u671f"},"11.5.3 ",Object(r.b)("inlineCode",{parentName:"h3"},"\u5355\u4f8b")," \u751f\u5b58\u671f"),Object(r.b)("p",null,"\u5728\u9996\u6b21\u8bf7\u6c42\u5b83\u4eec\u65f6\u8fdb\u884c\u521b\u5efa\uff0c\u4e4b\u540e\u6bcf\u4e2a\u540e\u7eed\u8bf7\u6c42\u90fd\u4f7f\u7528\u76f8\u540c\u7684\u5b9e\u4f8b\u3002"),Object(r.b)("p",null,"\u901a\u5e38\u6211\u4eec\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"ISingleton")," \u63a5\u53e3\u4f9d\u8d56\u8868\u793a\u8be5\u751f\u547d\u5468\u671f\u3002"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(r.b)("inlineCode",{parentName:"p"},"\u670d\u52a1\u751f\u5b58\u671f")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(r.b)("a",Object(i.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-5.0#service-lifetimes"}),"ASP.NET Core - \u4f9d\u8d56\u6ce8\u5165 - \u670d\u52a1\u751f\u5b58\u671f")," \u7ae0\u8282\u3002"))),Object(r.b)("h2",{id:"116-\u5185\u7f6e\u4f9d\u8d56\u63a5\u53e3"},"11.6 \u5185\u7f6e\u4f9d\u8d56\u63a5\u53e3"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e09\u4e2a\u63a5\u53e3\u4f9d\u8d56\u5206\u522b\u5bf9\u5e94\u4e0d\u540c\u7684\u670d\u52a1\u751f\u5b58\u671f\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ITransient"),"\uff1a\u5bf9\u5e94\u6682\u65f6/\u77ac\u65f6\u4f5c\u7528\u57df\u670d\u52a1\u751f\u5b58\u671f"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"IScoped"),"\uff1a\u5bf9\u5e94\u8bf7\u6c42\u4f5c\u7528\u57df\u670d\u52a1\u751f\u5b58\u671f"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ISingleton"),"\uff1a\u5bf9\u5e94\u5355\u4f8b\u4f5c\u7528\u57df\u670d\u52a1\u751f\u5b58\u671f")),Object(r.b)("h2",{id:"117-\u5e38\u89c1\u4f7f\u7528"},"11.7 \u5e38\u89c1\u4f7f\u7528"),Object(r.b)("h3",{id:"1172-\u7b2c\u4e00\u4e2a\u4f8b\u5b50"},"11.7.2 \u7b2c\u4e00\u4e2a\u4f8b\u5b50"),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"IBusinessService")," \u63a5\u53e3\u548c ",Object(r.b)("inlineCode",{parentName:"p"},"BusinessService")," \u5b9e\u73b0\u7c7b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,12}","{7,12}":!0}),"using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing Fur.DependencyInjection;\n\nnamespace Fur.Application\n{\n public interface IBusinessService\n {\n Person Get(int id);\n }\n\n public class BusinessService : IBusinessService, ITransient\n {\n private readonly IRepository _personRepository;\n\n public BusinessService(IRepository personRepository)\n {\n _personRepository = personRepository;\n }\n\n public Person Get(int id)\n {\n return _personRepository.Find(id);\n }\n }\n}\n")),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"PersonController")," \u63a7\u5236\u5668\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{11,19}","{11,19}":!0}),'using Fur.Application;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n [ApiController]\n public class PersonController : ControllerBase\n {\n private readonly IBusinessService _businessService;\n public PersonController(IBusinessService businessService)\n {\n _businessService = businessService;\n }\n\n [HttpGet]\n public IActionResult Get(int id)\n {\n var person = _businessService.Get(id);\n return new JsonResult(person);\n }\n }\n}\n')),Object(r.b)("img",{src:Object(c.a)("img/di1.gif")}),Object(r.b)("hr",null),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"\u4f8b\u5b50\u89e3\u8bf4")),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u4e14\u65b9\u4fbf\u7684\u5b9e\u73b0\u4f9d\u8d56\u6ce8\u5165\u7684\u65b9\u5f0f\uff0c\u53ea\u9700\u8981\u5b9e\u4f8b\u7c7b\u7ee7\u627f\u5bf9\u5e94\u751f\u5b58\u671f\u7684\u63a5\u53e3\u5373\u53ef\uff0c\u8fd9\u91cc\u7ee7\u627f\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"ITransient"),"\uff0c\u4e5f\u5c31\u8868\u660e\u4e86\u8fd9\u662f\u4e00\u4e2a ",Object(r.b)("inlineCode",{parentName:"p"},"\u6682\u65f6/\u77ac\u65f6")," \u4f5c\u7528\u57df\u5b9e\u4f8b\u7c7b\u3002\u8be5\u7c7b\u5c31\u53ef\u4ee5\u4f5c\u4e3a\u88ab\u6ce8\u5165\u5bf9\u8c61\uff0c\u540c\u65f6\u4e5f\u80fd\u6ce8\u5165\u5176\u4ed6\u63a5\u53e3\u5bf9\u8c61\u3002"),Object(r.b)("p",null,"\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"BusinessService")," \u6ce8\u5165\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"IRepository")," \u4ed3\u50a8\u63a5\u53e3\uff0c\u540c\u65f6 ",Object(r.b)("inlineCode",{parentName:"p"},"PersonController")," \u63a7\u5236\u5668\u6ce8\u5165\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"IBusinessService")," \u63a5\u53e3\u3002"),Object(r.b)("p",null,"\u8fd9\u6837 ",Object(r.b)("inlineCode",{parentName:"p"},"PersonController")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"BusinessService")," \u4e4b\u95f4\u5c31\u5b9e\u73b0\u4e86\u89e3\u8026\uff0c\u4e0d\u518d\u4f9d\u8d56\u4e8e\u5177\u4f53\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"BusinessService")," \u5b9e\u4f8b\u3002"),Object(r.b)("p",null,"\u8fd9\u5c31\u662f\u4f9d\u8d56\u6ce8\u5165/\u63a7\u5236\u53cd\u8f6c\u6700\u7ecf\u5178\u7684\u4f8b\u5b50\u3002"),Object(r.b)("h3",{id:"1173-\u6ce8\u518c\u6cdb\u578b\u5b9e\u4f8b"},"11.7.3 \u6ce8\u518c\u6cdb\u578b\u5b9e\u4f8b"),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"IBusinessService")," \u63a5\u53e3\u548c ",Object(r.b)("inlineCode",{parentName:"p"},"BusinessService")," \u5b9e\u73b0\u7c7b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,12}","{7,12}":!0}),"using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing Fur.DependencyInjection;\n\nnamespace Fur.Application\n{\n public interface IBusinessService\n {\n Person Get(int id);\n }\n\n public class BusinessService : IBusinessService, ITransient\n {\n private readonly IRepository _personRepository;\n\n public BusinessService(IRepository personRepository)\n {\n _personRepository = personRepository;\n }\n\n public Person Get(int id)\n {\n return _personRepository.Find(id);\n }\n }\n}\n")),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"PersonController")," \u63a7\u5236\u5668\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{11,19}","{11,19}":!0}),'using Fur.Application;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n [ApiController]\n public class PersonController : ControllerBase\n {\n private readonly IBusinessService _businessService;\n public PersonController(IBusinessService businessService)\n {\n _businessService = businessService;\n }\n\n [HttpGet]\n public IActionResult Get(int id)\n {\n var person = _businessService.Get(id);\n return new JsonResult(person);\n }\n }\n}\n')),Object(r.b)("h3",{id:"1174-\u4e00\u4e2a\u63a5\u53e3\u591a\u4e2a\u5b9e\u73b0"},"11.7.4 \u4e00\u4e2a\u63a5\u53e3\u591a\u4e2a\u5b9e\u73b0"),Object(r.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4e00\u4e2a\u63a5\u53e3\u53ea\u5bf9\u5e94\u4e00\u4e2a\u5b9e\u73b0\u7c7b\uff0c\u4f46\u6709\u4e9b\u7279\u6b8a\u60c5\u51b5\uff0c\u9700\u8981\u9700\u8981\u591a\u4e2a\u5b9e\u73b0\u7c7b\u6ce8\u518c\u540c\u4e00\u4e2a\u63a5\u53e3\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"p"},"DbContext")," \u591a\u6570\u636e\u5e93\u60c5\u51b5\u3002"),Object(r.b)("p",null,"\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4f9d\u8d56\u6ce8\u5165 ",Object(r.b)("inlineCode",{parentName:"p"},"Func")," \u59d4\u6258\u6765\u89e3\u6790\u591a\u4e2a\u5b9e\u4f8b\uff0c\u5176\u4e2d\u59d4\u6258\u7684\u53c2\u6570\u5206\u522b\u4e3a\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u53c2\u6570 1\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"string")," \u7c7b\u578b\uff0c\u4e0d\u540c\u5b9e\u73b0\u7c7b\u552f\u4e00\u6807\u8bc6\uff0c\u9ed8\u8ba4\u4e3a ",Object(r.b)("inlineCode",{parentName:"li"},"nameof(\u5b9e\u73b0\u7c7b)")," \u540d\u79f0"),Object(r.b)("li",{parentName:"ul"},"\u53c2\u6570 2\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Type")," \u7c7b\u578b\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"IPrivateDependency")," \u6d3e\u751f\u63a5\u53e3\uff0c\u4e5f\u5c31\u662f ",Object(r.b)("inlineCode",{parentName:"li"},"ITransient"),"\u3001",Object(r.b)("inlineCode",{parentName:"li"},"IScoped"),"\u3001",Object(r.b)("inlineCode",{parentName:"li"},"ISingleton")),Object(r.b)("li",{parentName:"ul"},"\u8fd4\u56de\u503c\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"object")," \u7c7b\u578b\uff0c\u8fd4\u56de\u5177\u4f53\u7684\u5b9e\u73b0\u7c7b\u5b9e\u4f8b")),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"IBusinessService")," \u63a5\u53e3\u548c ",Object(r.b)("inlineCode",{parentName:"p"},"BusinessService"),"\u3001",Object(r.b)("inlineCode",{parentName:"p"},"OtherBusinessService")," \u4e24\u4e2a\u5b9e\u73b0\u7c7b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,10,18}","{5,10,18}":!0}),'using Fur.DependencyInjection;\n\nnamespace Fur.Application\n{\n public interface IBusinessService\n {\n string GetName();\n }\n\n public class BusinessService : IBusinessService, ITransient\n {\n public string GetName()\n {\n return "\u6211\u662f\uff1a" + nameof(BusinessService);\n }\n }\n\n public class OtherBusinessService : IBusinessService, ITransient\n {\n public string GetName()\n {\n return "\u6211\u662f\uff1a" + nameof(OtherBusinessService);\n }\n }\n}\n')),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"ValueController")," \u63a7\u5236\u5668\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{15,17,18}","{15,17,18}":!0}),'using Fur.Application;\nusing Fur.DependencyInjection;\nusing Microsoft.AspNetCore.Mvc;\nusing System;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n [ApiController]\n public class ValueController : ControllerBase\n {\n private readonly IBusinessService _businessService;\n private readonly IBusinessService _otherBusinessService;\n\n public ValueController(Func resolveNamed)\n {\n _businessService = resolveNamed("BusinessService", default) as IBusinessService;\n _otherBusinessService = resolveNamed("OtherBusinessService", default) as IBusinessService;\n }\n\n [HttpGet]\n public string GetName()\n {\n return _businessService.GetName() + "----------" + _otherBusinessService.GetName();\n }\n }\n}\n')),Object(r.b)("img",{src:Object(c.a)("img/di2.gif")}),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5982\u679c\u9700\u8981\u81ea\u5b9a\u4e49\u89e3\u6790\u540d\u79f0\uff0c\u53ea\u9700\u8981\u8d34 ",Object(r.b)("inlineCode",{parentName:"p"},'[Injection(Named = "\u540d\u79f0")]')," \u5373\u53ef\uff0c\u5982\uff1a"),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,11}","{5,11}":!0}),'using Fur.DependencyInjection;\n\nnamespace Fur.Application\n{\n [Injection(Named = "BusName1")]\n public class BusinessService : IBusinessService, ITransient\n {\n // ...\n }\n\n [Injection(Named = "BusName2")]\n public class OtherBusinessService : IBusinessService, ITransient\n {\n // ...\n }\n}\n')),Object(r.b)("p",{parentName:"div"},"\u89e3\u6790\u670d\u52a1\uff1a"),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs"}),'_businessService = resolveNamed("BusName1", default) as IBusinessService;\n_otherBusinessService = resolveNamed("BusName2", default) as IBusinessService;\n')))),Object(r.b)("h3",{id:"1175-\u65e0\u63a5\u53e3\u65b9\u5f0f"},"11.7.5 \u65e0\u63a5\u53e3\u65b9\u5f0f"),Object(r.b)("p",null,"\u6709\u4e9b\u65f6\u5019\uff0c\u6211\u4eec\u4e0d\u60f3\u5b9a\u4e49\u63a5\u53e3\uff0c\u800c\u662f\u60f3\u628a\u5b9e\u4f8b\u7c7b\u4f5c\u4e3a\u53ef\u4f9d\u8d56\u6ce8\u5165\u7684\u5bf9\u8c61\uff0c\u5982 MVC \u4e2d\u7684\u63a7\u5236\u5668\u3002"),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"SelfService")," \u5b9e\u4f8b\u7c7b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,11}","{7,11}":!0}),"using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing Fur.DependencyInjection;\n\nnamespace Fur.Application\n{\n public class SelfService : ITransient\n {\n private readonly IRepository _personRepository;\n\n public SelfService(IRepository personRepository)\n {\n _personRepository = personRepository;\n }\n\n public Person Get(int id)\n {\n return _personRepository.Find(id);\n }\n }\n}\n")),Object(r.b)("p",null,"\u521b\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"ValueController")," \u63a7\u5236\u5668\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{13,21}","{13,21}":!0}),'using Fur.Application;\nusing Fur.Core;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n [ApiController]\n public class ValueController : ControllerBase\n {\n private readonly SelfService _selfService;\n\n public ValueController(SelfService selfService)\n {\n _selfService = selfService;\n }\n\n [HttpGet]\n public Person Get(int id)\n {\n return _selfService.Get(id);\n }\n }\n}\n')),Object(r.b)("h2",{id:"118-injection-\u7279\u6027\u914d\u7f6e"},"11.8 ",Object(r.b)("inlineCode",{parentName:"h2"},"[Injection]")," \u7279\u6027\u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b ",Object(r.b)("inlineCode",{parentName:"p"},"[Injection]")," \u7279\u6027\u53ef\u4ee5\u6539\u53d8\u6ce8\u518c\u65b9\u5f0f\uff0c\u540c\u65f6\u8fd8\u80fd\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"AOP")," \u62e6\u622a\u3002"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"[Injection]")," \u63d0\u4f9b\u4ee5\u4e0b\u914d\u7f6e\u652f\u6301\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Action"),"\uff1a\u914d\u7f6e\u6ce8\u518c\u884c\u4e3a\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"InjectionActions")," \u7c7b\u578b\uff0c\u53ef\u9009\u503c\uff1a",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Add"),"\uff1a",Object(r.b)("strong",{parentName:"li"},"\u9ed8\u8ba4\u503c"),"\uff0c\u8868\u793a\u65e0\u9650\u5236\u6dfb\u52a0\u6ce8\u518c\u670d\u52a1\uff0c\u8be5\u65b9\u5f0f\u652f\u6301\u4e00\u4e2a\u63a5\u53e3\u591a\u4e2a\u5b9e\u73b0"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"TryAdd"),"\uff1a\u8868\u793a\u6ce8\u518c\u5df2\u5b58\u5728\u5219\u8df3\u8fc7\u6ce8\u518c"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Pattern"),"\uff1a\u914d\u7f6e\u6ce8\u518c\u9009\u9879\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"InjectionPatterns")," \u7c7b\u578b\uff0c\u53ef\u9009\u503c\uff1a",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Self"),"\uff1a\u53ea\u6ce8\u518c\u81ea\u5df1"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"FirstInterface"),"\uff1a\u53ea\u6ce8\u518c\u7b2c\u4e00\u4e2a\u63a5\u53e3"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"SelfWithFirstInterface"),"\uff1a\u6ce8\u518c\u81ea\u5df1\u548c\u7b2c\u4e00\u4e2a\u63a5\u53e3\uff0c",Object(r.b)("strong",{parentName:"li"},"\u9ed8\u8ba4\u503c")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ImplementedInterfaces"),"\uff1a\u6ce8\u518c\u6240\u6709\u63a5\u53e3"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"All"),"\uff1a\u6ce8\u518c\u81ea\u5df1\u5305\u62ec\u6240\u6709\u63a5\u53e3"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Named"),"\uff1a\u914d\u7f6e\u5b9e\u4f8b\u522b\u540d\uff0c\u901a\u8fc7\u522b\u540d\u53ef\u4ee5\u89e3\u6790\u63a5\u53e3\uff0c\u5982\u540c\u4e00\u4e2a\u63a5\u53e3\u6709\u591a\u4e2a\u5b9e\u73b0\uff0c\u90a3\u4e48\u53ef\u4ee5\u901a\u8fc7\u522b\u540d\u89e3\u6790\u4e0d\u540c\u7684\u5b9e\u73b0\uff0c\u9ed8\u8ba4\u53ea\u4e3a\u5b9e\u73b0\u7c7b\u7684\u7c7b\u540d"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Order"),"\uff1a\u6ce8\u518c\u6392\u5e8f\uff0c\u6570\u5b57\u8d8a\u5927\uff0c\u5219\u8d8a\u5728\u6700\u540e\u6ce8\u518c\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"0")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Proxy"),"\uff1a\u914d\u7f6e\u4ee3\u7406\u62e6\u622a\u7c7b\u578b\uff0c\u4e5f\u5c31\u662f ",Object(r.b)("inlineCode",{parentName:"li"},"AOP"),"\uff0c",Object(r.b)("strong",{parentName:"li"},"\u4ee3\u7406\u7c7b\u578b\u5fc5\u987b\u7ee7\u627f ",Object(r.b)("inlineCode",{parentName:"strong"},"DispatchProxy")," \u7c7b\u548c ",Object(r.b)("inlineCode",{parentName:"strong"},"IDispatchProxy")," \u63a5\u53e3"),"\uff0c\u65e0\u9ed8\u8ba4\u503c")),Object(r.b)("h2",{id:"119-\u81ea\u5b9a\u4e49\u9ad8\u7ea7\u6ce8\u518c"},"11.9 \u81ea\u5b9a\u4e49\u9ad8\u7ea7\u6ce8\u518c"),Object(r.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u7684\u6ce8\u518c\u65b9\u5f0f\u53ef\u4ee5\u6ee1\u8db3\u5927\u591a\u6570\u4f9d\u8d56\u6ce8\u5165\u7684\u9700\u6c42\uff0c\u5982\u6709\u7279\u522b\u6ce8\u518c\u9700\u6c42\uff0c\u53ea\u9700\u8981\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Startup")," \u4e2d\u914d\u7f6e\u5373\u53ef\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs"}),"services.AddScoped(typeof(ISpecService), provider = > {\n // \u81ea\u5b9a\u4e49\u4efb\u4f55\u521b\u5efa\u5b9e\u4f8b\u7684\u65b9\u5f0f\n var instance = new SpecService(); // \u6216\u8005\u53ef\u4ee5\u901a\u8fc7 AOP\u63d2\u4ef6\u8fd4\u56de\u4ee3\u7406\u5b9e\u4f8b\n\n return instance;\n});\n")),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u8865\u5145\u8bf4\u660e")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u8fd8\u6709 ",Object(r.b)("inlineCode",{parentName:"p"},"ISqlDispatchProxy")," \u90fd\u662f\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u521b\u5efa\u7684\u3002"))),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u77e5\u8bc6\u5bfc\u822a")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a\u81ea\u5b9a\u4e49\u9ad8\u7ea7\u4e2d\u6ce8\u518c\uff0c\u53ef\u67e5\u9605 \u3010",Object(r.b)("a",Object(i.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-5.0"}),"ASP.NET Core \u4f9d\u8d56\u6ce8\u5165"),"\u3011 \u5b98\u65b9\u6587\u6863\u3002"))),Object(r.b)("h2",{id:"1110-appsettingsjson-\u914d\u7f6e\u6ce8\u518c"},"11.10 ",Object(r.b)("inlineCode",{parentName:"h2"},"appsettings.json")," \u914d\u7f6e\u6ce8\u518c"),Object(r.b)("p",null,"\u9664\u4e86\u5728\u4ee3\u7801\u4e2d\u5b9e\u73b0\u4f9d\u8d56\u6ce8\u5165\uff0c\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u52a8\u6001\u4f9d\u8d56\u6ce8\u5165\uff0c\u65e0\u9700\u4fee\u6539\u4ee3\u7801\u6216\u91cd\u65b0\u7f16\u8bd1\u5373\u53ef\u5b9e\u73b0\u70ed\u62d4\u63d2\uff08\u63d2\u4ef6\uff09\u6548\u679c\u3002\u914d\u7f6e\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-json",metastring:"{3}","{3}":!0}),'{\n "AppSettings": {\n "DependencyInjectionSettings": {\n "Definitions": [\n {\n "Interface": "Fur.Application;Fur.Application.ITestService",\n "Service": "Fur.Application;Fur.Application.TestService",\n "RegisterType": "Transient",\n "Action": "Add",\n "Pattern": "SelfWithFirstInterface",\n "Named": "TestService",\n "Order": 1,\n "Proxy": "Fur.Application;Fur.Application.LogDispathProxy"\n }\n ]\n }\n }\n}\n')),Object(r.b)("p",null,"\u914d\u7f6e\u8bf4\u660e\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DependencyInjectionSettings"),"\uff1a\u4f9d\u8d56\u6ce8\u5165\u914d\u7f6e\u6839\u8282\u70b9",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Definitions"),"\uff1a\u52a8\u6001\u4f9d\u8d56\u6ce8\u5165\u914d\u7f6e\u8282\u70b9\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"ExternalService")," \u6570\u7ec4\u7c7b\u578b",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"ExternalService"),"\uff1a\u914d\u7f6e\u5355\u4e2a\u4f9d\u8d56\u6ce8\u5165\u4fe1\u606f",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Interface"),"\uff1a\u914d\u7f6e\u4f9d\u8d56\u63a5\u53e3\u4fe1\u606f\uff0c\u683c\u5f0f\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"\u7a0b\u5e8f\u96c6\u540d\u79f0;\u63a5\u53e3\u5b8c\u6574\u540d\u79f0"),"\uff0c\u5982\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Fur.Application;Fur.Application.ITestService")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Service"),"\uff1a\u914d\u7f6e\u63a5\u53e3\u5b9e\u73b0\u4fe1\u606f\uff0c\u683c\u5f0f\u540c\u4e0a"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"RegisterType"),"\uff1a\u914d\u7f6e\u4f9d\u8d56\u6ce8\u5165\u7684\u5bf9\u8c61\u751f\u5b58\u671f\uff0c\u53d6\u503c\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Transient"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"Scoped"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"Singleton")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Action"),"\uff1a\u6ce8\u518c\u884c\u4e3a\uff0c\u53ef\u9009\u503c\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Add"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"TryAdd"),"\uff0c\u53c2\u89c1 ",Object(r.b)("a",Object(i.a)({parentName:"li"},{href:"#118-injection-%E7%89%B9%E6%80%A7%E9%85%8D%E7%BD%AE"}),"#118-injection-\u7279\u6027\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Pattern"),"\uff1a\u6ce8\u518c\u9009\u9879\uff0c\u53c2\u89c1 ",Object(r.b)("a",Object(i.a)({parentName:"li"},{href:"#118-injection-%E7%89%B9%E6%80%A7%E9%85%8D%E7%BD%AE"}),"#118-injection-\u7279\u6027\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Named"),"\uff1a\u6ce8\u518c\u522b\u540d\uff0c\u53c2\u89c1 ",Object(r.b)("a",Object(i.a)({parentName:"li"},{href:"#118-injection-%E7%89%B9%E6%80%A7%E9%85%8D%E7%BD%AE"}),"#118-injection-\u7279\u6027\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Order"),"\uff1a\u6ce8\u518c\u6392\u5e8f\uff0c\u53c2\u89c1 ",Object(r.b)("a",Object(i.a)({parentName:"li"},{href:"#118-injection-%E7%89%B9%E6%80%A7%E9%85%8D%E7%BD%AE"}),"#118-injection-\u7279\u6027\u914d\u7f6e")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Proxy"),"\uff1a\u914d\u7f6e\u4ee3\u7406\u62e6\u622a\uff0c\uff0c\u683c\u5f0f\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"\u7a0b\u5e8f\u96c6\u540d\u79f0;\u4ee3\u7406\u7c7b\u5b8c\u6574\u540d\u79f0"),"\uff0c\u53c2\u89c1 ",Object(r.b)("a",Object(i.a)({parentName:"li"},{href:"#118-injection-%E7%89%B9%E6%80%A7%E9%85%8D%E7%BD%AE"}),"#118-injection-\u7279\u6027\u914d\u7f6e"))))))))),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u5173\u4e8e\u5916\u90e8\u7a0b\u5e8f\u96c6")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5982\u679c\u52a8\u6001\u6ce8\u5165\u7684\u5bf9\u8c61\u662f\u5916\u90e8\u7a0b\u5e8f\u96c6\uff0c\u90a3\u4e48\u9996\u5148\u5148\u6ce8\u518c\u5916\u90e8\u7a0b\u5e8f\u96c6\uff1a"),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-json"}),'{\n "AppSettings": {\n "ExternalAssemblies": ["\u5916\u90e8\u7a0b\u5e8f\u96c6\u540d\u79f0", "Taobao.Pay"] // \u652f\u6301\u591a\u4e2a\n }\n}\n')))),Object(r.b)("h2",{id:"1111-\u6ce8\u518c\u987a\u5e8f\u548c\u4f18\u5148\u7ea7"},"11.11 \u6ce8\u518c\u987a\u5e8f\u548c\u4f18\u5148\u7ea7"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u9ed8\u8ba4\u6ce8\u518c\u987a\u5e8f\u662f\u6309\u7167\u7a0b\u5e8f\u96c6\u626b\u63cf\u987a\u5e8f\u8fdb\u884c\u6ce8\u518c\uff0c\u5982\u679c\u9700\u8981\u6539\u53d8\u6ce8\u518c\u987a\u5e8f\uff0c\u53ef\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"[Injection(Order)]")," \u7279\u6027\u6307\u5b9a\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Order")," \u503c\u8d8a\u5927\uff0c\u5219\u8d8a\u5728\u6700\u540e\u6ce8\u518c\u3002"),Object(r.b)("p",null,"\u53e6\u5916 ",Object(r.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u914d\u7f6e\u7684\u4f18\u5148\u7ea7\u6700\u5927\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u914d\u7f6e\u7684\u6ce8\u518c\u4f1a\u8986\u76d6\u4e4b\u524d\u6240\u6709\u6ce8\u518c\u3002"),Object(r.b)("h2",{id:"1112-aop-\u6ce8\u518c\u62e6\u622a"},"11.12 ",Object(r.b)("inlineCode",{parentName:"h2"},"Aop")," \u6ce8\u518c\u62e6\u622a"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"AOP")," \u662f\u975e\u5e38\u91cd\u8981\u7684\u601d\u60f3\u548c\u6280\u672f\uff0c\u4e5f\u5c31\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"\u9762\u5411\u5207\u9762")," \u7f16\u7a0b\uff0c\u53ef\u4ee5\u8ba9\u6211\u4eec\u5728\u4e0d\u6539\u52a8\u539f\u6765\u4ee3\u7801\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u52a8\u6001\u7be1\u6539\u4e1a\u52a1\u4ee3\u7801\u3002"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"p"},"Aop")," \u975e\u5e38\u7b80\u5355\uff0c\u5982\uff1a"),Object(r.b)("p",null,"\u5047\u8bbe\u6211\u4eec\u6709 ",Object(r.b)("inlineCode",{parentName:"p"},"ITestService")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"TestService")," \u4e24\u4e2a\u7c7b\u578b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs"}),"public class ITestService\n{\n string SayHello(string word);\n}\n")),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs"}),'public class TestService: ITestService, ITransient\n{\n public string SayHello(string word)\n {\n return $"Hello {word}";\n }\n}\n')),Object(r.b)("p",null,"\u73b0\u5728\u6211\u4eec\u6709\u4e00\u4e2a\u9700\u6c42\uff0c\u6211\u4eec\u5e0c\u671b\u8c03\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"SayHello")," \u7684\u65f6\u5019\u53ef\u4ee5\u8bb0\u5f55\u65e5\u5fd7\u548c\u6743\u9650\u63a7\u5236\uff08\u4e4b\u524d\u6ca1\u6709\u8003\u8651\u5230\u7684\u9700\u6c42\uff09\u3002"),Object(r.b)("p",null,"\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u53ea\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u4ee3\u7406\u7c7b\u5373\u53ef\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"p"},"LogDispatchProxy")," "),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,3,7,25}","{1,3,7,25}":!0}),'using Fur.DependencyInjection;\nusing System;\nusing System.Reflection;\n\nnamespace Fur.Application\n{\n public class LogDispatchProxy : DispatchProxy, IDispatchProxy\n {\n /// \n /// \u5f53\u524d\u670d\u52a1\u5b9e\u4f8b\n /// \n public object Target { get; set; }\n\n /// \n /// \u670d\u52a1\u63d0\u4f9b\u5668\uff0c\u53ef\u4ee5\u7528\u6765\u89e3\u6790\u670d\u52a1\uff0c\u5982\uff1aServices.GetService()\n /// \n public IServiceProvider Services { get; set; }\n\n /// \n /// \u62e6\u622a\u65b9\u6cd5\n /// \n /// \n /// \n /// \n protected override object Invoke(MethodInfo targetMethod, object[] args)\n {\n Console.WriteLine("SayHello \u65b9\u6cd5\u88ab\u8c03\u7528\u4e86");\n\n var result = targetMethod.Invoke(Target, args);\n\n Console.WriteLine("SayHello \u65b9\u6cd5\u8fd4\u56de\u503c\uff1a" + result);\n\n return result;\n }\n }\n}\n')),Object(r.b)("p",null,"\u4e4b\u540e\u6211\u4eec\u53ea\u9700\u8981\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"TestService")," \u589e\u52a0 ",Object(r.b)("inlineCode",{parentName:"p"},"[Injection]")," \u7279\u6027\u5373\u53ef\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),'[Injection(Proxy = typeof(LogDispatchProxy))]\npublic class TestService: ITestService, ITransient\n{\n public string SayHello(string word)\n {\n return $"Hello {word}";\n }\n}\n')),Object(r.b)("p",null,"\u4e4b\u540e ",Object(r.b)("inlineCode",{parentName:"p"},"SayHello")," \u65b9\u6cd5\u88ab\u8c03\u7528\u7684\u65f6\u5019\u5c31\u53ef\u4ee5\u5b9e\u73b0\u52a8\u6001\u62e6\u622a\u4e86\uff0c\u6bd4\u5982\u8fd9\u91cc\u5199\u65e5\u5fd7\u3002"),Object(r.b)("h3",{id:"11121-aop-\u7684\u4f5c\u7528"},"11.12.1 ",Object(r.b)("inlineCode",{parentName:"h3"},"AOP")," \u7684\u4f5c\u7528"),Object(r.b)("p",null,"\u8fd9\u79cd\u9762\u5411\u5207\u9762\u7684\u80fd\u529b\uff08\u52a8\u6001\u62e6\u622a/\u4ee3\u7406\uff09\u53ef\u4ee5\u5b9e\u73b0\u5f88\u591a\u5f88\u591a\u529f\u80fd\uff0c\u5982\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u52a8\u6001\u65e5\u5fd7\u8bb0\u5f55"),Object(r.b)("li",{parentName:"ul"},"\u52a8\u6001\u4fee\u6539\u53c2\u6570"),Object(r.b)("li",{parentName:"ul"},"\u52a8\u6001\u4fee\u6539\u8fd4\u56de\u503c"),Object(r.b)("li",{parentName:"ul"},"\u52a8\u6001\u65b9\u6cd5\u91cd\u5b9a\u5411"),Object(r.b)("li",{parentName:"ul"},"\u52a8\u6001\u4fee\u6539\u4ee3\u7801\u903b\u8f91"),Object(r.b)("li",{parentName:"ul"},"\u52a8\u6001\u5b9e\u73b0\u5f02\u5e38\u76d1\u542c")),Object(r.b)("p",null,"\u8fd8\u53ef\u4ee5\u505a\u66f4\u591a\u66f4\u591a\u7684\u4e8b\u60c5\u3002"),Object(r.b)("h2",{id:"1113-\u53cd\u9988\u4e0e\u5efa\u8bae"},"11.13 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(i.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}s.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/62953dcd.c8565443.js b/handbook/build/62953dcd.c8565443.js new file mode 100644 index 00000000000..3799c3f1442 --- /dev/null +++ b/handbook/build/62953dcd.c8565443.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[37],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return s})),t.d(n,"b",(function(){return u}));var a=t(0),r=t.n(a);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function o(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var b=r.a.createContext({}),l=function(e){var n=r.a.useContext(b),t=n;return e&&(t="function"==typeof e?e(n):o(o({},n),e)),t},s=function(e){var n=l(e.components);return r.a.createElement(b.Provider,{value:n},e.children)},d={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},m=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,i=e.originalType,c=e.parentName,b=p(e,["components","mdxType","originalType","parentName"]),s=l(t),m=a,u=s["".concat(c,".").concat(m)]||s[m]||d[m]||i;return t?r.a.createElement(u,o(o({ref:n},b),{},{components:t})):r.a.createElement(u,o({ref:n},b))}));function u(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var i=t.length,c=new Array(i);c[0]=m;var o={};for(var p in n)hasOwnProperty.call(n,p)&&(o[p]=n[p]);o.originalType=e,o.mdxType="string"==typeof e?e:a,c[1]=o;for(var b=2;bOops.Oh \u91cd\u8f7d\u65b9\u6cd5",id:"762-oopsoh-\u91cd\u8f7d\u65b9\u6cd5",children:[]}]},{value:"7.6 \u6700\u4f73\u5b9e\u8df5 \ud83e\udd17",id:"76-\u6700\u4f73\u5b9e\u8df5-",children:[{value:"7.6.1 \u521b\u5efa\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b",id:"761-\u521b\u5efa\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b",children:[]},{value:"7.6.2 \u5173\u4e8e [ErrorCodeItemMetadata]",id:"762-\u5173\u4e8e-errorcodeitemmetadata",children:[]},{value:"7.6.3 \u9759\u6001\u5f02\u5e38\u7c7b\u4f7f\u7528",id:"763-\u9759\u6001\u5f02\u5e38\u7c7b\u4f7f\u7528",children:[]},{value:"7.6.4 \u66f4\u591a\u4f8b\u5b50",id:"764-\u66f4\u591a\u4f8b\u5b50",children:[]}]},{value:"7.7 \u591a\u4e2a\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b",id:"77-\u591a\u4e2a\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b",children:[]},{value:"7.8 IErrorCodeTypeProvider \u63d0\u4f9b\u5668",id:"78-ierrorcodetypeprovider-\u63d0\u4f9b\u5668",children:[]},{value:"7.9 appsetting.json \u4e2d\u914d\u7f6e",id:"79-appsettingjson-\u4e2d\u914d\u7f6e",children:[]},{value:"7.10 [IfException] \u4f7f\u7528",id:"710-ifexception-\u4f7f\u7528",children:[{value:"7.10.1 \u4f7f\u7528\u793a\u4f8b",id:"7101-\u4f7f\u7528\u793a\u4f8b",children:[]},{value:"7.10.2 \u66f4\u591a\u4f8b\u5b50",id:"7102-\u66f4\u591a\u4f8b\u5b50",children:[]}]},{value:"7.11 \u5f02\u5e38\u6d88\u606f\u4f18\u5148\u7ea7",id:"711-\u5f02\u5e38\u6d88\u606f\u4f18\u5148\u7ea7",children:[]},{value:"7.12 \u591a\u8bed\u8a00\u652f\u6301",id:"712-\u591a\u8bed\u8a00\u652f\u6301",children:[]},{value:"7.13 \u5f02\u5e38\u6a21\u578b\u63d0\u4f9b\u5668",id:"713-\u5f02\u5e38\u6a21\u578b\u63d0\u4f9b\u5668",children:[]},{value:"7.14 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"714-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],l={rightToc:b};function s(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},l,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"71-\u4ec0\u4e48\u662f\u5f02\u5e38"},"7.1 \u4ec0\u4e48\u662f\u5f02\u5e38"),Object(i.b)("p",null,"\u5f02\u5e38\u4e00\u822c\u662f\u6307\u8fd0\u884c\u671f\uff08\u6b64\u5904\u7279\u6307 ",Object(i.b)("inlineCode",{parentName:"p"},"Exception")," \u7c7b\uff09\u4f1a\u53d1\u751f\u7684\u5bfc\u81f4\u7a0b\u5e8f\u610f\u5916\u4e2d\u6b62\u7684\u95ee\u9898\uff0c\u662f\u4e00\u79cd\u5bf9\u95ee\u9898\u7684\u63cf\u8ff0\u540e\u7684\u5c01\u88c5\u5bf9\u8c61\u3002"),Object(i.b)("p",null,"\u5728\u8fc7\u53bb\u5f00\u53d1\u4e2d\uff0c\u901a\u5e38\u5f02\u5e38\u7531\u7cfb\u7edf\u8fd0\u884c\u65f6\u51fa\u9519\u629b\u51fa\uff0c\u4f46\u73b0\u5728\u7684\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u5e94\u5728\u7a0b\u5e8f\u5f00\u53d1\u4e2d\u5408\u7406\u7684\u629b\u51fa\u5f02\u5e38\uff0c\u6bd4\u5982\u66f4\u65b0\u4e00\u6761\u4e0d\u5b58\u5728\u7684\u5b9e\u4f53\uff0c\u6216\u67e5\u8be2\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u6570\u636e\u7b49\u7b49\u3002"),Object(i.b)("h2",{id:"72-\u5904\u7406\u5f02\u5e38\u65b9\u5f0f"},"7.2 \u5904\u7406\u5f02\u5e38\u65b9\u5f0f"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u4e0d\u5904\u7406\uff0c\u76f4\u63a5\u4e2d\u65ad\u7a0b\u5e8f\u6267\u884c\uff08\u4e0d\u63a8\u8350\uff09"),Object(i.b)("li",{parentName:"ul"},"\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"li"},"try catch finally")," \u5904\u7406\uff08\u4e0d\u63a8\u8350\uff09"),Object(i.b)("li",{parentName:"ul"},"\u5168\u5c40\u7edf\u4e00\u5904\u7406\uff0c\u5e76\u8bb0\u5f55\u5f02\u5e38\u4fe1\u606f",Object(i.b)("strong",{parentName:"li"},"\uff08\u63a8\u8350\uff09")),Object(i.b)("li",{parentName:"ul"},"\u5f02\u5e38\u6ce8\u89e3\u65b9\u5f0f\u5904\u7406\uff0c\u652f\u6301",Object(i.b)("strong",{parentName:"li"},"\u672c\u5730\u5316")," ",Object(i.b)("strong",{parentName:"li"},"\uff08\u63a8\u8350\uff09"))),Object(i.b)("h2",{id:"73-\u4ec0\u4e48\u662f\u53cb\u597d\u5f02\u5e38\u5904\u7406"},"7.3 \u4ec0\u4e48\u662f\u53cb\u597d\u5f02\u5e38\u5904\u7406"),Object(i.b)("h3",{id:"731-\u975e\u53cb\u597d\u5f02\u5e38\u5904\u7406"},"7.3.1 \u975e\u53cb\u597d\u5f02\u5e38\u5904\u7406"),Object(i.b)("p",null,"\u5728\u4e86\u89e3\u53cb\u597d\u5f02\u5e38\u5904\u7406\u4e4b\u524d\u53ef\u4ee5\u770b\u770b\u975e\u53cb\u597d\u5f02\u5e38\u5904\u7406\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u5bf9\u7ec8\u7aef\u7528\u6237\u629b\u51fa ",Object(i.b)("inlineCode",{parentName:"li"},"500\u72b6\u6001\u7801")," \u5806\u6808\u4fe1\u606f"),Object(i.b)("li",{parentName:"ul"},"\u5927\u91cf\u7684 ",Object(i.b)("inlineCode",{parentName:"li"},"try catch")," \u4ee3\u7801\uff0c\u6c61\u67d3\u6b63\u5e38\u4e1a\u52a1\u903b\u8f91"),Object(i.b)("li",{parentName:"ul"},"\u6ca1\u6709\u89c4\u8303\u5316\u7684\u5f02\u5e38\u72b6\u6001\u7801\u548c\u5f02\u5e38\u6d88\u606f\u7ba1\u7406"),Object(i.b)("li",{parentName:"ul"},"\u6ca1\u6709\u5f02\u5e38\u65e5\u5fd7\u6536\u96c6\u8bb0\u5f55"),Object(i.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\u5f02\u5e38\u6d88\u606f\u672c\u5730\u5316\u5904\u7406"),Object(i.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\u5f02\u5e38\u7b56\u7565\uff0c\u5931\u8d25\u540e\u7a0b\u5e8f\u7acb\u5373\u7ec8\u6b62"),Object(i.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\u5206\u5e03\u5f0f\u4e8b\u52a1 CAP"),Object(i.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\u5f02\u5e38\u4f20\u64ad"),Object(i.b)("li",{parentName:"ul"},"\u8fd4\u56de\u7684\u5f02\u5e38\u683c\u5f0f\u6742\u4e71")),Object(i.b)("h3",{id:"732-\u53cb\u597d\u5f02\u5e38\u5904\u7406"},"7.3.2 \u53cb\u597d\u5f02\u5e38\u5904\u7406"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u5bf9\u7ec8\u7aef\u7528\u6237\u63d0\u793a\u53cb\u597d"),Object(i.b)("li",{parentName:"ul"},"\u5bf9\u540e\u7aef\u5f00\u53d1\u4eba\u5458\u63d0\u4f9b\u8be6\u7ec6\u7684\u5f02\u5e38\u5806\u6808"),Object(i.b)("li",{parentName:"ul"},"\u4e0d\u5e72\u6270\u6b63\u5e38\u4e1a\u52a1\u903b\u8f91\u4ee3\u7801\uff0c\u5982 \u6ca1\u6709 ",Object(i.b)("inlineCode",{parentName:"li"},"try catch")," \u4ee3\u7801"),Object(i.b)("li",{parentName:"ul"},"\u652f\u6301\u5f02\u5e38\u72b6\u6001\u7801\u591a\u65b9\u8bbe\u7f6e"),Object(i.b)("li",{parentName:"ul"},"\u652f\u6301\u5f02\u5e38\u6d88\u606f\u672c\u5730\u5316"),Object(i.b)("li",{parentName:"ul"},"\u5f02\u5e38\u4fe1\u606f\u7edf\u4e00\u914d\u7f6e\u7ba1\u7406"),Object(i.b)("li",{parentName:"ul"},"\u652f\u6301\u5f02\u5e38\u7b56\u7565\uff0c\u5982\u91cd\u8bd5"),Object(i.b)("li",{parentName:"ul"},"\u652f\u6301\u5f02\u5e38\u65e5\u5fd7\u6536\u96c6\u8bb0\u5f55"),Object(i.b)("li",{parentName:"ul"},"\u652f\u6301 CAP \u5206\u5e03\u5f0f\u4e8b\u52a1\u5173\u8054"),Object(i.b)("li",{parentName:"ul"},"\u652f\u6301\u5185\u90e8\u5f02\u5e38\u5916\u90e8\u4f20\u64ad"),Object(i.b)("li",{parentName:"ul"},"\u652f\u6301\u8fd4\u56de\u7edf\u4e00\u7684\u5f02\u5e38\u683c\u5f0f\u6570\u636e")),Object(i.b)("h2",{id:"74-\u53cb\u597d\u5f02\u5e38\u5904\u7406\u4f7f\u7528\u793a\u4f8b"},"7.4 \u53cb\u597d\u5f02\u5e38\u5904\u7406\u4f7f\u7528\u793a\u4f8b"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u7684\u53cb\u597d\u5f02\u5e38\u5904\u7406\u65b9\u5f0f\u3002"),Object(i.b)("h3",{id:"741-\u6ce8\u518c\u53cb\u597d\u5f02\u5e38\u670d\u52a1"},"7.4.1 \u6ce8\u518c\u53cb\u597d\u5f02\u5e38\u670d\u52a1"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{11} title="Fur.Web.Core\\FurWebCoreStartup.cs"',"{11}":!0,title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddControllers()\n .AddFriendlyException();\n }\n }\n}\n")),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},".AddFriendlyException()")," \u9700\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"services.AddControllers()")," \u4e4b\u540e\u6ce8\u518c\u3002"))),Object(i.b)("h3",{id:"742-\u4e24\u4e2a\u4f8b\u5b50"},"7.4.2 \u4e24\u4e2a\u4f8b\u5b50"),Object(i.b)("h4",{id:"\u7b80\u5355\u629b\u4e2a\u5f02\u5e38"},"\u7b80\u5355\u629b\u4e2a\u5f02\u5e38"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,12}","{2,12}":!0}),'using Fur.DynamicApiController;\nusing Fur.FriendlyException;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public int Get(int id)\n {\n if (id < 3)\n {\n throw Oops.Oh($"{id} \u4e0d\u80fd\u5c0f\u4e8e3");\n }\n\n return id;\n }\n }\n}\n')),Object(i.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(i.b)("img",{src:Object(c.a)("img/yhyc1.gif")}),Object(i.b)("h4",{id:"\u629b\u51fa\u7279\u5b9a\u7c7b\u578b\u5f02\u5e38"},"\u629b\u51fa\u7279\u5b9a\u7c7b\u578b\u5f02\u5e38"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,13}","{2,13}":!0}),'using Fur.DynamicApiController;\nusing Fur.FriendlyException;\nusing System;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public int Get(int id)\n {\n if (id < 3)\n {\n throw Oops.Oh($"{id} \u4e0d\u80fd\u5c0f\u4e8e3\u3002", typeof(InvalidOperationException));\n }\n\n return id;\n }\n }\n}\n')),Object(i.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(i.b)("img",{src:Object(c.a)("img/yhyc2.png")}),Object(i.b)("h2",{id:"75-\u5173\u4e8e-oopsoh"},"7.5 \u5173\u4e8e Oops.Oh"),Object(i.b)("p",null,"\u901a\u8fc7\u4e0a\u9762\u7684\u4f8b\u5b50\u53ef\u4ee5\u770b\u51fa\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"Oops.Oh(errorMessage)")," \u53ef\u4ee5\u7ed3\u5408 ",Object(i.b)("inlineCode",{parentName:"p"},"throw")," \u629b\u51fa\u5f02\u5e38\u3002\u5bf9\u4e8e\u719f\u6089",Object(i.b)("inlineCode",{parentName:"p"},"C#"),"\u7684\u4eba\u5458\u6765\u8bf4\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"throw")," \u540e\u9762\u53ea\u80fd ",Object(i.b)("inlineCode",{parentName:"p"},"Exception")," \u5b9e\u4f8b\u3002",Object(i.b)("inlineCode",{parentName:"p"},"Oops.Oh(...)")," \u65b9\u6cd5\u8fd4\u56de\u6b63\u662f ",Object(i.b)("inlineCode",{parentName:"p"},"Exception")," \u5b9e\u4f8b\u3002"),Object(i.b)("h3",{id:"761-\u4e3a\u4ec0\u4e48\u8d77\u8fd9\u4e2a\u540d\u5b57\uff1f"},"7.6.1 \u4e3a\u4ec0\u4e48\u8d77\u8fd9\u4e2a\u540d\u5b57\uff1f"),Object(i.b)("p",null,"\u8fd9\u4e2a\u540d\u5b57\u6765\u6e90\u4e8e\u4e00\u4e2a\u82f1\u8bed\u53e5\u5b50\uff1a",Object(i.b)("inlineCode",{parentName:"p"},"Oh, Oops!"),"\uff0c\u610f\u601d\u662f ",Object(i.b)("strong",{parentName:"p"},"\u5662\uff08\u54ce\uff09\uff0c\u51fa\u9519\u4e86\uff01"),"\uff0c\u6240\u4ee5\u5c31\u6709\u4e86 ",Object(i.b)("inlineCode",{parentName:"p"},"Oops.Oh"),"\u3002"),Object(i.b)("h3",{id:"762-oopsoh-\u91cd\u8f7d\u65b9\u6cd5"},"7.6.2 ",Object(i.b)("inlineCode",{parentName:"h3"},"Oops.Oh")," \u91cd\u8f7d\u65b9\u6cd5"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{13,22,30,39}","{13,22,30,39}":!0}),'using System;\n\nnamespace Fur.FriendlyException\n{\n public static class Oops\n {\n /// \n /// \u629b\u51fa\u5b57\u7b26\u4e32\u5f02\u5e38\n /// \n /// \u5f02\u5e38\u6d88\u606f\n /// String.Format \u53c2\u6570\n /// \u5f02\u5e38\u5b9e\u4f8b\n public static Exception Oh(string errorMessage, params object[] args);\n\n /// \n /// \u629b\u51fa\u5b57\u7b26\u4e32\u5f02\u5e38\n /// \n /// \u5f02\u5e38\u6d88\u606f\n /// \u5177\u4f53\u5f02\u5e38\u7c7b\u578b\n /// String.Format \u53c2\u6570\n /// \u5f02\u5e38\u5b9e\u4f8b\n public static Exception Oh(string errorMessage, Type exceptionType, params object[] args);\n\n /// \n /// \u629b\u51fa\u9519\u8bef\u7801\u5f02\u5e38\n /// \n /// \u9519\u8bef\u7801\n /// String.Format \u53c2\u6570\n /// \u5f02\u5e38\u5b9e\u4f8b\n public static Exception Oh(object errorCode, params object[] args);\n\n /// \n /// \u629b\u51fa\u9519\u8bef\u7801\u5f02\u5e38\n /// \n /// \u9519\u8bef\u7801\n /// \u5177\u4f53\u5f02\u5e38\u7c7b\u578b\n /// String.Format \u53c2\u6570\n /// \u5f02\u5e38\u5b9e\u4f8b\n public static Exception Oh(object errorCode, Type exceptionType, params object[] args);\n }\n}\n')),Object(i.b)("h2",{id:"76-\u6700\u4f73\u5b9e\u8df5-"},"7.6 \u6700\u4f73\u5b9e\u8df5 \ud83e\udd17"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u4e14\u89c4\u8303\u5316\u7684\u53cb\u597d\u5f02\u5e38\u5904\u7406\u65b9\u5f0f\uff0c\u901a\u8fc7\u8fd9\u4e2a\u65b9\u5f0f\u53ef\u4ee5\u65b9\u4fbf\u7ba1\u7406\u5f02\u5e38\u72b6\u6001\u7801\u3001\u5f02\u5e38\u4fe1\u606f\u53ca\u5f02\u5e38\u672c\u5730\u5316\u3002"),Object(i.b)("h3",{id:"761-\u521b\u5efa\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b"},"7.6.1 \u521b\u5efa\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b"),Object(i.b)("p",null,"\u5b9e\u73b0\u81ea\u5b9a\u4e49\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b\u5fc5\u987b\u9075\u5faa\u4ee5\u4e0b\u914d\u7f6e\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u7c7b\u578b\u5fc5\u987b\u662f\u516c\u5f00\u4e14\u65f6 ",Object(i.b)("inlineCode",{parentName:"li"},"Enum")," \u679a\u4e3e\u7c7b\u578b"),Object(i.b)("li",{parentName:"ul"},"\u679a\u4e3e\u7c7b\u578b\u5fc5\u987b\u8d34\u6709 ",Object(i.b)("inlineCode",{parentName:"li"},"[ErrorCodeType]")," \u7279\u6027"),Object(i.b)("li",{parentName:"ul"},"\u679a\u4e3e\u4e2d\u6bcf\u4e00\u9879\u5fc5\u987b\u8d34\u6709 ",Object(i.b)("inlineCode",{parentName:"li"},"[ErrorCodeItemMetadata]")," \u7279\u6027")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,8,11,14,17}","{1,5,8,11,14,17}":!0}),'using Fur.FriendlyException;\n\nnamespace Fur.Application\n{\n [ErrorCodeType]\n public enum ErrorCodes\n {\n [ErrorCodeItemMetadata("{0} \u4e0d\u80fd\u5c0f\u4e8e {1}")]\n z1000,\n\n [ErrorCodeItemMetadata("\u6570\u636e\u4e0d\u5b58\u5728")]\n x1000,\n\n [ErrorCodeItemMetadata("{0} \u53d1\u73b0 {1} \u4e2a\u5f02\u5e38", "\u767e\u5c0f\u50e7", 2)]\n x1001,\n\n [ErrorCodeItemMetadata("\u670d\u52a1\u5668\u8fd0\u884c\u5f02\u5e38", ErrorCode = "Error")]\n SERVER_ERROR\n }\n}\n')),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"important")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86 ",Object(i.b)("inlineCode",{parentName:"p"},"[ErrorCodeType]")," \u7279\u6027\u548c ",Object(i.b)("inlineCode",{parentName:"p"},"IErrorCodeTypeProvider")," \u63d0\u4f9b\u5668\u63a5\u53e3\u6765\u63d0\u4f9b\u5f02\u5e38\u4fe1\u606f\u626b\u63cf\uff0c\u8fd9\u91cc\u7528\u7684\u662f ",Object(i.b)("inlineCode",{parentName:"p"},"[ErrorCodeType]")," \u7279\u6027\u7c7b\u3002"))),Object(i.b)("h3",{id:"762-\u5173\u4e8e-errorcodeitemmetadata"},"7.6.2 \u5173\u4e8e ",Object(i.b)("inlineCode",{parentName:"h3"},"[ErrorCodeItemMetadata]")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86",Object(i.b)("inlineCode",{parentName:"p"},"[ErrorCodeItemMetadata]")," \u7279\u6027\u7528\u6765\u6807\u8bc6",Object(i.b)("strong",{parentName:"p"},"\u679a\u4e3e\u5b57\u6bb5"),"\u5f02\u5e38\u5143\u6570\u636e\uff0c\u8be5\u7279\u6027\u652f\u6301\u4f20\u5165 ",Object(i.b)("inlineCode",{parentName:"p"},"\u6d88\u606f\u5185\u5bb9")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"\u683c\u5f0f\u5316\u53c2\u6570"),"\u3002\u6700\u7ec8\u4f1a\u4f7f\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"String.Format(\u6d88\u606f\u5185\u5bb9\uff0c\u683c\u5f0f\u5316\u53c2\u6570)")," \u8fdb\u884c\u683c\u5f0f\u5316\u3002"),Object(i.b)("p",null,"\u5982\u679c\u6d88\u606f\u5185\u5bb9\u4e2d\u5305\u542b",Object(i.b)("inlineCode",{parentName:"p"},"\u683c\u5f0f\u5316\u5360\u4f4d\u7b26"),"\u4f46\u672a\u6307\u5b9a",Object(i.b)("inlineCode",{parentName:"p"},"\u683c\u5f0f\u5316\u53c2\u6570"),"\uff0c\u90a3\u4e48\u4f1a\u67e5\u627e\u5f02\u5e38\u6240\u5728\u65b9\u6cd5\u662f\u5426\u8d34\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"[IfException]")," \u7279\u6027\u4e14\u542b\u6709\u683c\u5f0f\u5316\u53c2\u6570\uff0c\u63a5\u7740\u5c31\u4f1a\u67e5\u627e ",Object(i.b)("inlineCode",{parentName:"p"},"Oops.Oh")," \u4e2d\u6307\u5b9a\u7684 ",Object(i.b)("inlineCode",{parentName:"p"},"\u683c\u5f0f\u5316\u53c2\u6570"),"\u3002"),Object(i.b)("h3",{id:"763-\u9759\u6001\u5f02\u5e38\u7c7b\u4f7f\u7528"},"7.6.3 \u9759\u6001\u5f02\u5e38\u7c7b\u4f7f\u7528"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,12}","{2,12}":!0}),"using Fur.DynamicApiController;\nusing Fur.FriendlyException;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public int Get(int id)\n {\n if (id < 3)\n {\n throw Oops.Oh(ErrorCodes.z1000, id, 3);\n }\n\n return id;\n }\n }\n}\n")),Object(i.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(i.b)("img",{src:Object(c.a)("img/yhyc3.gif")}),Object(i.b)("h3",{id:"764-\u66f4\u591a\u4f8b\u5b50"},"7.6.4 \u66f4\u591a\u4f8b\u5b50"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'throw Oops.Oh(1000);\nthrow Oops.Oh(ErrorCodes.x1000);\nthrow Oops.Oh("\u54c8\u54c8\u54c8\u54c8");\nthrow Oops.Oh(errorCode: "x1001");\nthrow Oops.Oh(1000, typeof(Exception));\n')),Object(i.b)("h2",{id:"77-\u591a\u4e2a\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b"},"7.7 \u591a\u4e2a\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5-6,21-22}","{5-6,21-22}":!0}),'using Fur.FriendlyException;\n\nnamespace Fur.Application\n{\n [ErrorCodeType]\n public enum ErrorCodes\n {\n [ErrorCodeItemMetadata("{0} \u4e0d\u80fd\u5c0f\u4e8e {1}")]\n z1000,\n\n [ErrorCodeItemMetadata("\u6570\u636e\u4e0d\u5b58\u5728")]\n x1000,\n\n [ErrorCodeItemMetadata("{0} \u53d1\u73b0 {1} \u4e2a\u5f02\u5e38", "\u767e\u5c0f\u50e7", 2)]\n x1001,\n\n [ErrorCodeItemMetadata("\u670d\u52a1\u5668\u8fd0\u884c\u5f02\u5e38", ErrorCode = "Error")]\n SERVER_ERROR\n }\n\n [ErrorCodeType]\n public enum UserErrorCodes\n {\n [ErrorCodeItemMetadata("\u7528\u6237\u6570\u636e\u4e0d\u5b58\u5728")]\n u1000,\n\n [ErrorCodeItemMetadata("\u5176\u4ed6\u5f02\u5e38")]\n u1001\n }\n}\n')),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u591a\u4e2a\u5f02\u5e38\u9759\u6001\u7c7b\u4e2d\u4e5f\u5fc5\u987b\u4fdd\u8bc1\u5e38\u91cf\u503c\u552f\u4e00\u6027\uff0c\u4e0d\u53ef\u91cd\u590d\u3002"))),Object(i.b)("h2",{id:"78-ierrorcodetypeprovider-\u63d0\u4f9b\u5668"},"7.8 ",Object(i.b)("inlineCode",{parentName:"h2"},"IErrorCodeTypeProvider")," \u63d0\u4f9b\u5668"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u8fd8\u63d0\u4f9b\u4e86 ",Object(i.b)("inlineCode",{parentName:"p"},"IErrorCodeTypeProvider")," \u5f02\u5e38\u6d88\u606f\u63d0\u4f9b\u5668\u63a5\u53e3\uff0c\u65b9\u4fbf\u5728\u4e0d\u80fd\u8d34 ",Object(i.b)("inlineCode",{parentName:"p"},"[ErrorCodeType]")," \u7279\u6027\u60c5\u51b5\u4e0b\u4f7f\u7528\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,6,8-11}","{2,6,8-11}":!0}),"using Fur.FriendlyException;\nusing System;\n\nnamespace Fur.Application\n{\n public class CustomErrorCodeTypeProvider : IErrorCodeTypeProvider\n {\n public Type[] Definitions => new[] {\n typeof(ErrorCodes),\n typeof(ErrorCodes2)\n };\n }\n}\n")),Object(i.b)("p",null,"\u542f\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"IErrorCodeTypeProvider")," \u63d0\u4f9b\u5668\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{11} title="Fur.Web.Core\\FurWebCoreStartup.cs"',"{11}":!0,title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddControllers()\n .AddFriendlyException();\n }\n }\n}\n")),Object(i.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u53ea\u6709\u4f7f\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"IErrorCodeTypeProvider")," \u65b9\u5f0f\u624d\u9700\u4f7f\u7528\u6cdb\u578b\u65b9\u5f0f\u6ce8\u518c\u3002\u901a\u8fc7\u4e0a\u9762\u7684\u65b9\u5f0f\u6ce8\u518c\u53ef\u4ee5\u540c\u65f6\u652f\u6301 ",Object(i.b)("inlineCode",{parentName:"p"},"IErrorCodeTypeProvider")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"[ErrorCodeType]")," \u65b9\u5f0f\u3002"))),Object(i.b)("h2",{id:"79-appsettingjson-\u4e2d\u914d\u7f6e"},"7.9 ",Object(i.b)("inlineCode",{parentName:"h2"},"appsetting.json")," \u4e2d\u914d\u7f6e"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u8fd8\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u7684\u914d\u7f6e\u6587\u4ef6\u914d\u7f6e\u5f02\u5e38\uff0c\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u5b9e\u73b0\u5f02\u5e38\u4fe1\u606f\u540e\u671f\u914d\u7f6e\uff0c\u4e5f\u5c31\u662f\u65e0\u9700\u5728\u5f00\u53d1\u9636\u6bb5\u9884\u5148\u5b9a\u4e49\u3002"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:'{2-9} title="Fur.Web.Entry/appsettings.json"',"{2-9}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "ErrorCodeMessageSettings": {\n "Definitions": [\n [5000, "{0} \u4e0d\u80fd\u5c0f\u4e8e {1}"],\n [5001, "\u6211\u53eb {0} \u540d\u5b57", "\u767e\u5c0f\u50e7"],\n [5002, "Oops! \u51fa\u9519\u4e86"]\n ]\n }\n }\n}\n')),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Definitions")," \u7c7b\u578b\u4e3a\u4e8c\u7ef4\u6570\u7ec4\uff0c\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e00\u4e2a\u6570\u7ec4\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a ",Object(i.b)("inlineCode",{parentName:"p"},"ErrorCode")," \u4e5f\u5c31\u662f\u9519\u8bef\u7801\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a ",Object(i.b)("inlineCode",{parentName:"p"},"ErrorMessage")," \u6d88\u606f\u5185\u5bb9\uff0c\u5269\u4f59\u53c2\u6570\u4f5c\u4e3a ",Object(i.b)("inlineCode",{parentName:"p"},"ErrorMessage")," \u7684\u683c\u5f0f\u5316\u53c2\u6570\u3002"),Object(i.b)("h4",{id:"\u4f7f\u7528\u793a\u4f8b"},"\u4f7f\u7528\u793a\u4f8b"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,12}","{2,12}":!0}),"using Fur.DynamicApiController;\nusing Fur.FriendlyException;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public int Get(int id)\n {\n if (id < 3)\n {\n throw Oops.Oh(5000, id, 3); // \u53ef\u4ee5\u5c06 5000\u4f5c\u4e3a\u5e38\u91cf\u914d\u7f6e\u8d77\u6765\n }\n\n return id;\n }\n }\n}\n")),Object(i.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"[ErrorCodeType]")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"IErrorCodeTypeProvider")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u53ef\u4ee5\u540c\u65f6\u4f7f\u7528\u3002"))),Object(i.b)("h2",{id:"710-ifexception-\u4f7f\u7528"},"7.10 ",Object(i.b)("inlineCode",{parentName:"h2"},"[IfException]")," \u4f7f\u7528"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86 ",Object(i.b)("inlineCode",{parentName:"p"},"[IfException]")," \u7279\u6027\u53ef\u4ee5",Object(i.b)("strong",{parentName:"p"},"\u8986\u76d6\u9ed8\u8ba4\u6d88\u606f\u914d\u7f6e"),"\u3002\u4e5f\u5c31\u662f\u8986\u76d6 ",Object(i.b)("inlineCode",{parentName:"p"},"\u5f02\u5e38\u6d88\u606f\u7c7b\u578b")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u4e2d\u7684\u914d\u7f6e\u3002"),Object(i.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"[IfException]")," \u53ea\u80fd\u8d34\u5728\u65b9\u6cd5\u4e0a\uff0c\u652f\u6301\u591a\u4e2a\uff0c\u800c\u4e14\u8be5\u65b9\u6cd5\u6240\u5728\u7684\u7c7b\u7c7b\u578b\u5fc5\u987b\u662f ",Object(i.b)("inlineCode",{parentName:"p"},"ControllerBase")," \u5b50\u7c7b \u6216 \u5b9e\u73b0 ",Object(i.b)("inlineCode",{parentName:"p"},"IDynamicApiController")," \u63a5\u53e3\u3002"))),Object(i.b)("h3",{id:"7101-\u4f7f\u7528\u793a\u4f8b"},"7.10.1 \u4f7f\u7528\u793a\u4f8b"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u5f02\u5e38\u6d88\u606f\u7c7b\u5b9a\u4e49")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,4}","{1,4}":!0}),'[ErrorCodeType]\npublic static class ErrorCodes\n{\n [ErrorCodeItemMetadata("{0} \u4e0d\u80fd\u5c0f\u4e8e {1}")]\n z1000\n}\n')),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u8986\u76d6\u9ed8\u8ba4\u914d\u7f6e")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8}","{8}":!0}),'using Fur.DynamicApiController;\nusing Fur.FriendlyException;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [IfException(ErrorCodes.z1000, ErrorMessage = "\u6211\u8986\u76d6\u4e86\u9ed8\u8ba4\u7684\uff1a{0} \u4e0d\u80fd\u5c0f\u4e8e {1}")]\n public int Get(int id)\n {\n if (id < 3)\n {\n throw Oops.Oh(ErrorCodes.z1000, id, 3);\n }\n\n return id;\n }\n }\n}\n')),Object(i.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(i.b)("img",{src:Object(c.a)("img/yhyc4.png")}),Object(i.b)("h3",{id:"7102-\u66f4\u591a\u4f8b\u5b50"},"7.10.2 \u66f4\u591a\u4f8b\u5b50"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,8-11}","{2,8-11}":!0}),'using Fur.DynamicApiController;\nusing Fur.FriendlyException;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [IfException(ErrorCodes.z1000, ErrorMessage = "\u6211\u8986\u76d6\u4e86\u9ed8\u8ba4\u7684\uff1a{0} \u4e0d\u80fd\u5c0f\u4e8e {1}")]\n [IfException(ErrorCodes.x1001, "\u683c\u5f0f\u5316\u53c2\u65701", "\u683c\u5f0f\u5316\u53c2\u65702", ErrorMessage = "\u6211\u8986\u76d6\u4e86\u9ed8\u8ba4\u7684\uff1a{0} \u4e0d\u80fd\u5c0f\u4e8e {1}")]\n [IfException(ErrorCodes.x1000, "\u683c\u5f0f\u5316\u53c2\u65701", "\u683c\u5f0f\u5316\u53c2\u65702")]\n [IfException(ErrorCodes.SERVER_ERROR, "\u683c\u5f0f\u5316\u53c2\u65701", "\u683c\u5f0f\u5316\u53c2\u65702")]\n public int Get(int id)\n {\n if (id < 3)\n {\n throw Oops.Oh(ErrorCodes.z1000, id, 3);\n }\n\n return id;\n }\n }\n}\n')),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u683c\u5f0f\u5316\u6d41\u7a0b")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u5982\u679c\u6d88\u606f\u5185\u5bb9\u4e2d\u5305\u542b",Object(i.b)("inlineCode",{parentName:"p"},"\u683c\u5f0f\u5316\u5360\u4f4d\u7b26"),"\u4f46\u672a\u6307\u5b9a",Object(i.b)("inlineCode",{parentName:"p"},"\u683c\u5f0f\u5316\u53c2\u6570"),"\uff0c\u90a3\u4e48\u4f1a\u67e5\u627e\u5f02\u5e38\u6240\u5728\u65b9\u6cd5\u662f\u5426\u8d34\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"[IfException]")," \u7279\u6027\u4e14\u542b\u6709\u683c\u5f0f\u5316\u53c2\u6570\uff0c\u63a5\u7740\u5c31\u4f1a\u67e5\u627e ",Object(i.b)("inlineCode",{parentName:"p"},"Oops.Oh")," \u4e2d\u6307\u5b9a\u7684 ",Object(i.b)("inlineCode",{parentName:"p"},"\u683c\u5f0f\u5316\u53c2\u6570"),"\u3002"))),Object(i.b)("h2",{id:"711-\u5f02\u5e38\u6d88\u606f\u4f18\u5148\u7ea7"},"7.11 \u5f02\u5e38\u6d88\u606f\u4f18\u5148\u7ea7"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"[ErrorCodeItemMetadata]")," -> ",Object(i.b)("inlineCode",{parentName:"p"},"appsettings.json")," -> ",Object(i.b)("inlineCode",{parentName:"p"},"[IfException]"),"\u3002",Object(i.b)("strong",{parentName:"p"},"\uff08\u4f4e -> \u9ad8\uff09")),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"[IfException]")," \u4f1a\u8986\u76d6 ",Object(i.b)("inlineCode",{parentName:"li"},"appsettings.json")," \u5b9a\u4e49\u7684\u72b6\u6001\u7801\u6d88\u606f\u3002"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"appsettings.json")," \u4f1a\u8986\u76d6 ",Object(i.b)("inlineCode",{parentName:"li"},"[ErrorCodeItemMetadata]")," \u5b9a\u4e49\u7684\u6d88\u606f\u3002")),Object(i.b)("h2",{id:"712-\u591a\u8bed\u8a00\u652f\u6301"},"7.12 \u591a\u8bed\u8a00\u652f\u6301"),Object(i.b)("p",null,"\u6587\u6863\u6574\u7406\u4e2d..."),Object(i.b)("h2",{id:"713-\u5f02\u5e38\u6a21\u578b\u63d0\u4f9b\u5668"},"7.13 \u5f02\u5e38\u6a21\u578b\u63d0\u4f9b\u5668"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b ",Object(i.b)("inlineCode",{parentName:"p"},"\u89c4\u8303\u5316\u7ed3\u679c")," \u529f\u80fd\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b9e\u73b0 ",Object(i.b)("inlineCode",{parentName:"p"},"IUnifyResultProvider")," \u63d0\u4f9b\u5668\u5b9e\u73b0\u5f02\u5e38\u8fd4\u56de\u503c\u5b9a\u5236\uff0c\u5982\uff1a",Object(i.b)("inlineCode",{parentName:"p"},"RESTfulResultProvider"),"\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'using Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.AspNetCore.Mvc.Filters;\nusing Microsoft.AspNetCore.Mvc.ModelBinding;\nusing System.Collections.Generic;\n\nnamespace Fur.UnifyResult\n{\n /// \n /// RESTful \u98ce\u683c\u8fd4\u56de\u503c\n /// \n public class RESTfulResultProvider : IUnifyResultProvider\n {\n /// \n /// \u5f02\u5e38\u8fd4\u56de\u503c\n /// \n /// \n /// \n public IActionResult OnException(ExceptionContext context)\n {\n return new JsonResult(new RESTfulResult\n {\n StatusCode = StatusCodes.Status500InternalServerError,\n Successed = false,\n Data = null,\n Errors = context.Exception.Message\n });\n }\n\n /// \n /// \u6210\u529f\u8fd4\u56de\u503c\n /// \n /// \n /// \n public IActionResult OnSuccessed(ActionExecutedContext context)\n {\n object data;\n // \u5904\u7406\u5185\u5bb9\u7ed3\u679c\n if (context.Result is ContentResult contentResult) data = contentResult.Content;\n // \u5904\u7406\u5bf9\u8c61\u7ed3\u679c\n else if (context.Result is ObjectResult objectResult) data = objectResult.Value;\n else return null;\n\n return new JsonResult(new RESTfulResult\n {\n StatusCode = context.Result is EmptyResult ? StatusCodes.Status204NoContent : StatusCodes.Status200OK,\n Successed = true,\n Data = data,\n Errors = null\n });\n }\n\n /// \n /// \u9a8c\u8bc1\u5931\u8d25\u8fd4\u56de\u503c\n /// \n /// \n /// \n /// \n /// \n /// \n public IActionResult OnValidateFailed(ActionExecutingContext context, ModelStateDictionary modelStates, Dictionary> validationResults, string validateFaildMessage)\n {\n return new JsonResult(new RESTfulResult\n {\n StatusCode = StatusCodes.Status400BadRequest,\n Successed = false,\n Data = null,\n Errors = validationResults\n });\n }\n }\n}\n')),Object(i.b)("p",null,"\u4e4b\u540e\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Startup.cs")," \u4e2d\u6ce8\u518c\u5373\u53ef\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"services.AddControllers().AddUnifyResult();\n")),Object(i.b)("h2",{id:"714-\u53cd\u9988\u4e0e\u5efa\u8bae"},"7.14 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}s.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/62953dcd.dc05b734.js b/handbook/build/62953dcd.dc05b734.js deleted file mode 100644 index fa71bcbb095..00000000000 --- a/handbook/build/62953dcd.dc05b734.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[35],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return s})),t.d(n,"b",(function(){return u}));var a=t(0),r=t.n(a);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function o(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var b=r.a.createContext({}),l=function(e){var n=r.a.useContext(b),t=n;return e&&(t="function"==typeof e?e(n):o(o({},n),e)),t},s=function(e){var n=l(e.components);return r.a.createElement(b.Provider,{value:n},e.children)},d={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},m=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,i=e.originalType,c=e.parentName,b=p(e,["components","mdxType","originalType","parentName"]),s=l(t),m=a,u=s["".concat(c,".").concat(m)]||s[m]||d[m]||i;return t?r.a.createElement(u,o(o({ref:n},b),{},{components:t})):r.a.createElement(u,o({ref:n},b))}));function u(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var i=t.length,c=new Array(i);c[0]=m;var o={};for(var p in n)hasOwnProperty.call(n,p)&&(o[p]=n[p]);o.originalType=e,o.mdxType="string"==typeof e?e:a,c[1]=o;for(var b=2;bOops.Oh \u91cd\u8f7d\u65b9\u6cd5",id:"762-oopsoh-\u91cd\u8f7d\u65b9\u6cd5",children:[]}]},{value:"7.6 \u6700\u4f73\u5b9e\u8df5 \ud83e\udd17",id:"76-\u6700\u4f73\u5b9e\u8df5-",children:[{value:"7.6.1 \u521b\u5efa\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b",id:"761-\u521b\u5efa\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b",children:[]},{value:"7.6.2 \u5173\u4e8e [ErrorCodeItemMetadata]",id:"762-\u5173\u4e8e-errorcodeitemmetadata",children:[]},{value:"7.6.3 \u9759\u6001\u5f02\u5e38\u7c7b\u4f7f\u7528",id:"763-\u9759\u6001\u5f02\u5e38\u7c7b\u4f7f\u7528",children:[]},{value:"7.6.4 \u66f4\u591a\u4f8b\u5b50",id:"764-\u66f4\u591a\u4f8b\u5b50",children:[]}]},{value:"7.7 \u591a\u4e2a\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b",id:"77-\u591a\u4e2a\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b",children:[]},{value:"7.8 IErrorCodeTypeProvider \u63d0\u4f9b\u5668",id:"78-ierrorcodetypeprovider-\u63d0\u4f9b\u5668",children:[]},{value:"7.9 appsetting.json \u4e2d\u914d\u7f6e",id:"79-appsettingjson-\u4e2d\u914d\u7f6e",children:[]},{value:"7.10 [IfException] \u4f7f\u7528",id:"710-ifexception-\u4f7f\u7528",children:[{value:"7.10.1 \u4f7f\u7528\u793a\u4f8b",id:"7101-\u4f7f\u7528\u793a\u4f8b",children:[]},{value:"7.10.2 \u66f4\u591a\u4f8b\u5b50",id:"7102-\u66f4\u591a\u4f8b\u5b50",children:[]}]},{value:"7.11 \u5f02\u5e38\u6d88\u606f\u4f18\u5148\u7ea7",id:"711-\u5f02\u5e38\u6d88\u606f\u4f18\u5148\u7ea7",children:[]},{value:"7.12 \u591a\u8bed\u8a00\u652f\u6301",id:"712-\u591a\u8bed\u8a00\u652f\u6301",children:[]},{value:"7.13 \u5f02\u5e38\u6a21\u578b\u63d0\u4f9b\u5668",id:"713-\u5f02\u5e38\u6a21\u578b\u63d0\u4f9b\u5668",children:[]},{value:"7.14 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"714-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],l={rightToc:b};function s(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},l,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"71-\u4ec0\u4e48\u662f\u5f02\u5e38"},"7.1 \u4ec0\u4e48\u662f\u5f02\u5e38"),Object(i.b)("p",null,"\u5f02\u5e38\u4e00\u822c\u662f\u6307\u8fd0\u884c\u671f\uff08\u6b64\u5904\u7279\u6307 ",Object(i.b)("inlineCode",{parentName:"p"},"Exception")," \u7c7b\uff09\u4f1a\u53d1\u751f\u7684\u5bfc\u81f4\u7a0b\u5e8f\u610f\u5916\u4e2d\u6b62\u7684\u95ee\u9898\uff0c\u662f\u4e00\u79cd\u5bf9\u95ee\u9898\u7684\u63cf\u8ff0\u540e\u7684\u5c01\u88c5\u5bf9\u8c61\u3002"),Object(i.b)("p",null,"\u5728\u8fc7\u53bb\u5f00\u53d1\u4e2d\uff0c\u901a\u5e38\u5f02\u5e38\u7531\u7cfb\u7edf\u8fd0\u884c\u65f6\u51fa\u9519\u629b\u51fa\uff0c\u4f46\u73b0\u5728\u7684\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u5e94\u5728\u7a0b\u5e8f\u5f00\u53d1\u4e2d\u5408\u7406\u7684\u629b\u51fa\u5f02\u5e38\uff0c\u6bd4\u5982\u66f4\u65b0\u4e00\u6761\u4e0d\u5b58\u5728\u7684\u5b9e\u4f53\uff0c\u6216\u67e5\u8be2\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u6570\u636e\u7b49\u7b49\u3002"),Object(i.b)("h2",{id:"72-\u5904\u7406\u5f02\u5e38\u65b9\u5f0f"},"7.2 \u5904\u7406\u5f02\u5e38\u65b9\u5f0f"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u4e0d\u5904\u7406\uff0c\u76f4\u63a5\u4e2d\u65ad\u7a0b\u5e8f\u6267\u884c\uff08\u4e0d\u63a8\u8350\uff09"),Object(i.b)("li",{parentName:"ul"},"\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"li"},"try catch finally")," \u5904\u7406\uff08\u4e0d\u63a8\u8350\uff09"),Object(i.b)("li",{parentName:"ul"},"\u5168\u5c40\u7edf\u4e00\u5904\u7406\uff0c\u5e76\u8bb0\u5f55\u5f02\u5e38\u4fe1\u606f",Object(i.b)("strong",{parentName:"li"},"\uff08\u63a8\u8350\uff09")),Object(i.b)("li",{parentName:"ul"},"\u5f02\u5e38\u6ce8\u89e3\u65b9\u5f0f\u5904\u7406\uff0c\u652f\u6301",Object(i.b)("strong",{parentName:"li"},"\u672c\u5730\u5316")," ",Object(i.b)("strong",{parentName:"li"},"\uff08\u63a8\u8350\uff09"))),Object(i.b)("h2",{id:"73-\u4ec0\u4e48\u662f\u53cb\u597d\u5f02\u5e38\u5904\u7406"},"7.3 \u4ec0\u4e48\u662f\u53cb\u597d\u5f02\u5e38\u5904\u7406"),Object(i.b)("h3",{id:"731-\u975e\u53cb\u597d\u5f02\u5e38\u5904\u7406"},"7.3.1 \u975e\u53cb\u597d\u5f02\u5e38\u5904\u7406"),Object(i.b)("p",null,"\u5728\u4e86\u89e3\u53cb\u597d\u5f02\u5e38\u5904\u7406\u4e4b\u524d\u53ef\u4ee5\u770b\u770b\u975e\u53cb\u597d\u5f02\u5e38\u5904\u7406\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u5bf9\u7ec8\u7aef\u7528\u6237\u629b\u51fa ",Object(i.b)("inlineCode",{parentName:"li"},"500\u72b6\u6001\u7801")," \u5806\u6808\u4fe1\u606f"),Object(i.b)("li",{parentName:"ul"},"\u5927\u91cf\u7684 ",Object(i.b)("inlineCode",{parentName:"li"},"try catch")," \u4ee3\u7801\uff0c\u6c61\u67d3\u6b63\u5e38\u4e1a\u52a1\u903b\u8f91"),Object(i.b)("li",{parentName:"ul"},"\u6ca1\u6709\u89c4\u8303\u5316\u7684\u5f02\u5e38\u72b6\u6001\u7801\u548c\u5f02\u5e38\u6d88\u606f\u7ba1\u7406"),Object(i.b)("li",{parentName:"ul"},"\u6ca1\u6709\u5f02\u5e38\u65e5\u5fd7\u6536\u96c6\u8bb0\u5f55"),Object(i.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\u5f02\u5e38\u6d88\u606f\u672c\u5730\u5316\u5904\u7406"),Object(i.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\u5f02\u5e38\u7b56\u7565\uff0c\u5931\u8d25\u540e\u7a0b\u5e8f\u7acb\u5373\u7ec8\u6b62"),Object(i.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\u5206\u5e03\u5f0f\u4e8b\u52a1 CAP"),Object(i.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\u5f02\u5e38\u4f20\u64ad"),Object(i.b)("li",{parentName:"ul"},"\u8fd4\u56de\u7684\u5f02\u5e38\u683c\u5f0f\u6742\u4e71")),Object(i.b)("h3",{id:"732-\u53cb\u597d\u5f02\u5e38\u5904\u7406"},"7.3.2 \u53cb\u597d\u5f02\u5e38\u5904\u7406"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u5bf9\u7ec8\u7aef\u7528\u6237\u63d0\u793a\u53cb\u597d"),Object(i.b)("li",{parentName:"ul"},"\u5bf9\u540e\u7aef\u5f00\u53d1\u4eba\u5458\u63d0\u4f9b\u8be6\u7ec6\u7684\u5f02\u5e38\u5806\u6808"),Object(i.b)("li",{parentName:"ul"},"\u4e0d\u5e72\u6270\u6b63\u5e38\u4e1a\u52a1\u903b\u8f91\u4ee3\u7801\uff0c\u5982 \u6ca1\u6709 ",Object(i.b)("inlineCode",{parentName:"li"},"try catch")," \u4ee3\u7801"),Object(i.b)("li",{parentName:"ul"},"\u652f\u6301\u5f02\u5e38\u72b6\u6001\u7801\u591a\u65b9\u8bbe\u7f6e"),Object(i.b)("li",{parentName:"ul"},"\u652f\u6301\u5f02\u5e38\u6d88\u606f\u672c\u5730\u5316"),Object(i.b)("li",{parentName:"ul"},"\u5f02\u5e38\u4fe1\u606f\u7edf\u4e00\u914d\u7f6e\u7ba1\u7406"),Object(i.b)("li",{parentName:"ul"},"\u652f\u6301\u5f02\u5e38\u7b56\u7565\uff0c\u5982\u91cd\u8bd5"),Object(i.b)("li",{parentName:"ul"},"\u652f\u6301\u5f02\u5e38\u65e5\u5fd7\u6536\u96c6\u8bb0\u5f55"),Object(i.b)("li",{parentName:"ul"},"\u652f\u6301 CAP \u5206\u5e03\u5f0f\u4e8b\u52a1\u5173\u8054"),Object(i.b)("li",{parentName:"ul"},"\u652f\u6301\u5185\u90e8\u5f02\u5e38\u5916\u90e8\u4f20\u64ad"),Object(i.b)("li",{parentName:"ul"},"\u652f\u6301\u8fd4\u56de\u7edf\u4e00\u7684\u5f02\u5e38\u683c\u5f0f\u6570\u636e")),Object(i.b)("h2",{id:"74-\u53cb\u597d\u5f02\u5e38\u5904\u7406\u4f7f\u7528\u793a\u4f8b"},"7.4 \u53cb\u597d\u5f02\u5e38\u5904\u7406\u4f7f\u7528\u793a\u4f8b"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u7684\u53cb\u597d\u5f02\u5e38\u5904\u7406\u65b9\u5f0f\u3002"),Object(i.b)("h3",{id:"741-\u6ce8\u518c\u53cb\u597d\u5f02\u5e38\u670d\u52a1"},"7.4.1 \u6ce8\u518c\u53cb\u597d\u5f02\u5e38\u670d\u52a1"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{11} title="Fur.Web.Core\\FurWebCoreStartup.cs"',"{11}":!0,title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddControllers()\n .AddFriendlyException();\n }\n }\n}\n")),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},".AddFriendlyException()")," \u9700\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"services.AddControllers()")," \u4e4b\u540e\u6ce8\u518c\u3002"))),Object(i.b)("h3",{id:"742-\u4e24\u4e2a\u4f8b\u5b50"},"7.4.2 \u4e24\u4e2a\u4f8b\u5b50"),Object(i.b)("h4",{id:"\u7b80\u5355\u629b\u4e2a\u5f02\u5e38"},"\u7b80\u5355\u629b\u4e2a\u5f02\u5e38"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,12}","{2,12}":!0}),'using Fur.DynamicApiController;\nusing Fur.FriendlyException;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public int Get(int id)\n {\n if (id < 3)\n {\n throw Oops.Oh($"{id} \u4e0d\u80fd\u5c0f\u4e8e3");\n }\n\n return id;\n }\n }\n}\n')),Object(i.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(i.b)("img",{src:Object(c.a)("img/yhyc1.gif")}),Object(i.b)("h4",{id:"\u629b\u51fa\u7279\u5b9a\u7c7b\u578b\u5f02\u5e38"},"\u629b\u51fa\u7279\u5b9a\u7c7b\u578b\u5f02\u5e38"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,13}","{2,13}":!0}),'using Fur.DynamicApiController;\nusing Fur.FriendlyException;\nusing System;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public int Get(int id)\n {\n if (id < 3)\n {\n throw Oops.Oh($"{id} \u4e0d\u80fd\u5c0f\u4e8e3\u3002", typeof(InvalidOperationException));\n }\n\n return id;\n }\n }\n}\n')),Object(i.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(i.b)("img",{src:Object(c.a)("img/yhyc2.png")}),Object(i.b)("h2",{id:"75-\u5173\u4e8e-oopsoh"},"7.5 \u5173\u4e8e Oops.Oh"),Object(i.b)("p",null,"\u901a\u8fc7\u4e0a\u9762\u7684\u4f8b\u5b50\u53ef\u4ee5\u770b\u51fa\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"Oops.Oh(errorMessage)")," \u53ef\u4ee5\u7ed3\u5408 ",Object(i.b)("inlineCode",{parentName:"p"},"throw")," \u629b\u51fa\u5f02\u5e38\u3002\u5bf9\u4e8e\u719f\u6089",Object(i.b)("inlineCode",{parentName:"p"},"C#"),"\u7684\u4eba\u5458\u6765\u8bf4\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"throw")," \u540e\u9762\u53ea\u80fd ",Object(i.b)("inlineCode",{parentName:"p"},"Exception")," \u5b9e\u4f8b\u3002",Object(i.b)("inlineCode",{parentName:"p"},"Oops.Oh(...)")," \u65b9\u6cd5\u8fd4\u56de\u6b63\u662f ",Object(i.b)("inlineCode",{parentName:"p"},"Exception")," \u5b9e\u4f8b\u3002"),Object(i.b)("h3",{id:"761-\u4e3a\u4ec0\u4e48\u8d77\u8fd9\u4e2a\u540d\u5b57\uff1f"},"7.6.1 \u4e3a\u4ec0\u4e48\u8d77\u8fd9\u4e2a\u540d\u5b57\uff1f"),Object(i.b)("p",null,"\u8fd9\u4e2a\u540d\u5b57\u6765\u6e90\u4e8e\u4e00\u4e2a\u82f1\u8bed\u53e5\u5b50\uff1a",Object(i.b)("inlineCode",{parentName:"p"},"Oh, Oops!"),"\uff0c\u610f\u601d\u662f ",Object(i.b)("strong",{parentName:"p"},"\u5662\uff08\u54ce\uff09\uff0c\u51fa\u9519\u4e86\uff01"),"\uff0c\u6240\u4ee5\u5c31\u6709\u4e86 ",Object(i.b)("inlineCode",{parentName:"p"},"Oops.Oh"),"\u3002"),Object(i.b)("h3",{id:"762-oopsoh-\u91cd\u8f7d\u65b9\u6cd5"},"7.6.2 ",Object(i.b)("inlineCode",{parentName:"h3"},"Oops.Oh")," \u91cd\u8f7d\u65b9\u6cd5"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{13,22,30,39}","{13,22,30,39}":!0}),'using System;\n\nnamespace Fur.FriendlyException\n{\n public static class Oops\n {\n /// \n /// \u629b\u51fa\u5b57\u7b26\u4e32\u5f02\u5e38\n /// \n /// \u5f02\u5e38\u6d88\u606f\n /// String.Format \u53c2\u6570\n /// \u5f02\u5e38\u5b9e\u4f8b\n public static Exception Oh(string errorMessage, params object[] args);\n\n /// \n /// \u629b\u51fa\u5b57\u7b26\u4e32\u5f02\u5e38\n /// \n /// \u5f02\u5e38\u6d88\u606f\n /// \u5177\u4f53\u5f02\u5e38\u7c7b\u578b\n /// String.Format \u53c2\u6570\n /// \u5f02\u5e38\u5b9e\u4f8b\n public static Exception Oh(string errorMessage, Type exceptionType, params object[] args);\n\n /// \n /// \u629b\u51fa\u9519\u8bef\u7801\u5f02\u5e38\n /// \n /// \u9519\u8bef\u7801\n /// String.Format \u53c2\u6570\n /// \u5f02\u5e38\u5b9e\u4f8b\n public static Exception Oh(object errorCode, params object[] args);\n\n /// \n /// \u629b\u51fa\u9519\u8bef\u7801\u5f02\u5e38\n /// \n /// \u9519\u8bef\u7801\n /// \u5177\u4f53\u5f02\u5e38\u7c7b\u578b\n /// String.Format \u53c2\u6570\n /// \u5f02\u5e38\u5b9e\u4f8b\n public static Exception Oh(object errorCode, Type exceptionType, params object[] args);\n }\n}\n')),Object(i.b)("h2",{id:"76-\u6700\u4f73\u5b9e\u8df5-"},"7.6 \u6700\u4f73\u5b9e\u8df5 \ud83e\udd17"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u4e14\u89c4\u8303\u5316\u7684\u53cb\u597d\u5f02\u5e38\u5904\u7406\u65b9\u5f0f\uff0c\u901a\u8fc7\u8fd9\u4e2a\u65b9\u5f0f\u53ef\u4ee5\u65b9\u4fbf\u7ba1\u7406\u5f02\u5e38\u72b6\u6001\u7801\u3001\u5f02\u5e38\u4fe1\u606f\u53ca\u5f02\u5e38\u672c\u5730\u5316\u3002"),Object(i.b)("h3",{id:"761-\u521b\u5efa\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b"},"7.6.1 \u521b\u5efa\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b"),Object(i.b)("p",null,"\u5b9e\u73b0\u81ea\u5b9a\u4e49\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b\u5fc5\u987b\u9075\u5faa\u4ee5\u4e0b\u914d\u7f6e\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u7c7b\u578b\u5fc5\u987b\u662f\u516c\u5f00\u4e14\u65f6 ",Object(i.b)("inlineCode",{parentName:"li"},"Enum")," \u679a\u4e3e\u7c7b\u578b"),Object(i.b)("li",{parentName:"ul"},"\u679a\u4e3e\u7c7b\u578b\u5fc5\u987b\u8d34\u6709 ",Object(i.b)("inlineCode",{parentName:"li"},"[ErrorCodeType]")," \u7279\u6027"),Object(i.b)("li",{parentName:"ul"},"\u679a\u4e3e\u4e2d\u6bcf\u4e00\u9879\u5fc5\u987b\u8d34\u6709 ",Object(i.b)("inlineCode",{parentName:"li"},"[ErrorCodeItemMetadata]")," \u7279\u6027")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,8,11,14,17}","{1,5,8,11,14,17}":!0}),'using Fur.FriendlyException;\n\nnamespace Fur.Application\n{\n [ErrorCodeType]\n public enum ErrorCodes\n {\n [ErrorCodeItemMetadata("{0} \u4e0d\u80fd\u5c0f\u4e8e {1}")]\n z1000,\n\n [ErrorCodeItemMetadata("\u6570\u636e\u4e0d\u5b58\u5728")]\n x1000,\n\n [ErrorCodeItemMetadata("{0} \u53d1\u73b0 {1} \u4e2a\u5f02\u5e38", "\u767e\u5c0f\u50e7", 2)]\n x1001,\n\n [ErrorCodeItemMetadata("\u670d\u52a1\u5668\u8fd0\u884c\u5f02\u5e38", ErrorCode = "Error")]\n SERVER_ERROR\n }\n}\n')),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"important")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86 ",Object(i.b)("inlineCode",{parentName:"p"},"[ErrorCodeType]")," \u7279\u6027\u548c ",Object(i.b)("inlineCode",{parentName:"p"},"IErrorCodeTypeProvider")," \u63d0\u4f9b\u5668\u63a5\u53e3\u6765\u63d0\u4f9b\u5f02\u5e38\u4fe1\u606f\u626b\u63cf\uff0c\u8fd9\u91cc\u7528\u7684\u662f ",Object(i.b)("inlineCode",{parentName:"p"},"[ErrorCodeType]")," \u7279\u6027\u7c7b\u3002"))),Object(i.b)("h3",{id:"762-\u5173\u4e8e-errorcodeitemmetadata"},"7.6.2 \u5173\u4e8e ",Object(i.b)("inlineCode",{parentName:"h3"},"[ErrorCodeItemMetadata]")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86",Object(i.b)("inlineCode",{parentName:"p"},"[ErrorCodeItemMetadata]")," \u7279\u6027\u7528\u6765\u6807\u8bc6",Object(i.b)("strong",{parentName:"p"},"\u679a\u4e3e\u5b57\u6bb5"),"\u5f02\u5e38\u5143\u6570\u636e\uff0c\u8be5\u7279\u6027\u652f\u6301\u4f20\u5165 ",Object(i.b)("inlineCode",{parentName:"p"},"\u6d88\u606f\u5185\u5bb9")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"\u683c\u5f0f\u5316\u53c2\u6570"),"\u3002\u6700\u7ec8\u4f1a\u4f7f\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"String.Format(\u6d88\u606f\u5185\u5bb9\uff0c\u683c\u5f0f\u5316\u53c2\u6570)")," \u8fdb\u884c\u683c\u5f0f\u5316\u3002"),Object(i.b)("p",null,"\u5982\u679c\u6d88\u606f\u5185\u5bb9\u4e2d\u5305\u542b",Object(i.b)("inlineCode",{parentName:"p"},"\u683c\u5f0f\u5316\u5360\u4f4d\u7b26"),"\u4f46\u672a\u6307\u5b9a",Object(i.b)("inlineCode",{parentName:"p"},"\u683c\u5f0f\u5316\u53c2\u6570"),"\uff0c\u90a3\u4e48\u4f1a\u67e5\u627e\u5f02\u5e38\u6240\u5728\u65b9\u6cd5\u662f\u5426\u8d34\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"[IfException]")," \u7279\u6027\u4e14\u542b\u6709\u683c\u5f0f\u5316\u53c2\u6570\uff0c\u63a5\u7740\u5c31\u4f1a\u67e5\u627e ",Object(i.b)("inlineCode",{parentName:"p"},"Oops.Oh")," \u4e2d\u6307\u5b9a\u7684 ",Object(i.b)("inlineCode",{parentName:"p"},"\u683c\u5f0f\u5316\u53c2\u6570"),"\u3002"),Object(i.b)("h3",{id:"763-\u9759\u6001\u5f02\u5e38\u7c7b\u4f7f\u7528"},"7.6.3 \u9759\u6001\u5f02\u5e38\u7c7b\u4f7f\u7528"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,12}","{2,12}":!0}),"using Fur.DynamicApiController;\nusing Fur.FriendlyException;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public int Get(int id)\n {\n if (id < 3)\n {\n throw Oops.Oh(ErrorCodes.z1000, id, 3);\n }\n\n return id;\n }\n }\n}\n")),Object(i.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(i.b)("img",{src:Object(c.a)("img/yhyc3.gif")}),Object(i.b)("h3",{id:"764-\u66f4\u591a\u4f8b\u5b50"},"7.6.4 \u66f4\u591a\u4f8b\u5b50"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'throw Oops.Oh(1000);\nthrow Oops.Oh(ErrorCodes.x1000);\nthrow Oops.Oh("\u54c8\u54c8\u54c8\u54c8");\nthrow Oops.Oh(errorCode: "x1001");\nthrow Oops.Oh(1000, typeof(Exception));\n')),Object(i.b)("h2",{id:"77-\u591a\u4e2a\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b"},"7.7 \u591a\u4e2a\u5f02\u5e38\u4fe1\u606f\u7c7b\u578b"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5-6,21-22}","{5-6,21-22}":!0}),'using Fur.FriendlyException;\n\nnamespace Fur.Application\n{\n [ErrorCodeType]\n public enum ErrorCodes\n {\n [ErrorCodeItemMetadata("{0} \u4e0d\u80fd\u5c0f\u4e8e {1}")]\n z1000,\n\n [ErrorCodeItemMetadata("\u6570\u636e\u4e0d\u5b58\u5728")]\n x1000,\n\n [ErrorCodeItemMetadata("{0} \u53d1\u73b0 {1} \u4e2a\u5f02\u5e38", "\u767e\u5c0f\u50e7", 2)]\n x1001,\n\n [ErrorCodeItemMetadata("\u670d\u52a1\u5668\u8fd0\u884c\u5f02\u5e38", ErrorCode = "Error")]\n SERVER_ERROR\n }\n\n [ErrorCodeType]\n public enum UserErrorCodes\n {\n [ErrorCodeItemMetadata("\u7528\u6237\u6570\u636e\u4e0d\u5b58\u5728")]\n u1000,\n\n [ErrorCodeItemMetadata("\u5176\u4ed6\u5f02\u5e38")]\n u1001\n }\n}\n')),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u591a\u4e2a\u5f02\u5e38\u9759\u6001\u7c7b\u4e2d\u4e5f\u5fc5\u987b\u4fdd\u8bc1\u5e38\u91cf\u503c\u552f\u4e00\u6027\uff0c\u4e0d\u53ef\u91cd\u590d\u3002"))),Object(i.b)("h2",{id:"78-ierrorcodetypeprovider-\u63d0\u4f9b\u5668"},"7.8 ",Object(i.b)("inlineCode",{parentName:"h2"},"IErrorCodeTypeProvider")," \u63d0\u4f9b\u5668"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u8fd8\u63d0\u4f9b\u4e86 ",Object(i.b)("inlineCode",{parentName:"p"},"IErrorCodeTypeProvider")," \u5f02\u5e38\u6d88\u606f\u63d0\u4f9b\u5668\u63a5\u53e3\uff0c\u65b9\u4fbf\u5728\u4e0d\u80fd\u8d34 ",Object(i.b)("inlineCode",{parentName:"p"},"[ErrorCodeType]")," \u7279\u6027\u60c5\u51b5\u4e0b\u4f7f\u7528\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,6,8-11}","{2,6,8-11}":!0}),"using Fur.FriendlyException;\nusing System;\n\nnamespace Fur.Application\n{\n public class CustomErrorCodeTypeProvider : IErrorCodeTypeProvider\n {\n public Type[] Definitions => new[] {\n typeof(ErrorCodes),\n typeof(ErrorCodes2)\n };\n }\n}\n")),Object(i.b)("p",null,"\u542f\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"IErrorCodeTypeProvider")," \u63d0\u4f9b\u5668\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{11} title="Fur.Web.Core\\FurWebCoreStartup.cs"',"{11}":!0,title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddControllers()\n .AddFriendlyException();\n }\n }\n}\n")),Object(i.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u53ea\u6709\u4f7f\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"IErrorCodeTypeProvider")," \u65b9\u5f0f\u624d\u9700\u4f7f\u7528\u6cdb\u578b\u65b9\u5f0f\u6ce8\u518c\u3002\u901a\u8fc7\u4e0a\u9762\u7684\u65b9\u5f0f\u6ce8\u518c\u53ef\u4ee5\u540c\u65f6\u652f\u6301 ",Object(i.b)("inlineCode",{parentName:"p"},"IErrorCodeTypeProvider")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"[ErrorCodeType]")," \u65b9\u5f0f\u3002"))),Object(i.b)("h2",{id:"79-appsettingjson-\u4e2d\u914d\u7f6e"},"7.9 ",Object(i.b)("inlineCode",{parentName:"h2"},"appsetting.json")," \u4e2d\u914d\u7f6e"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u8fd8\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u7684\u914d\u7f6e\u6587\u4ef6\u914d\u7f6e\u5f02\u5e38\uff0c\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u5b9e\u73b0\u5f02\u5e38\u4fe1\u606f\u540e\u671f\u914d\u7f6e\uff0c\u4e5f\u5c31\u662f\u65e0\u9700\u5728\u5f00\u53d1\u9636\u6bb5\u9884\u5148\u5b9a\u4e49\u3002"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:'{2-9} title="Fur.Web.Entry/appsettings.json"',"{2-9}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "ErrorCodeMessageSettings": {\n "Definitions": [\n [5000, "{0} \u4e0d\u80fd\u5c0f\u4e8e {1}"],\n [5001, "\u6211\u53eb {0} \u540d\u5b57", "\u767e\u5c0f\u50e7"],\n [5002, "Oops! \u51fa\u9519\u4e86"]\n ]\n }\n }\n}\n')),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Definitions")," \u7c7b\u578b\u4e3a\u4e8c\u7ef4\u6570\u7ec4\uff0c\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e00\u4e2a\u6570\u7ec4\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a ",Object(i.b)("inlineCode",{parentName:"p"},"ErrorCode")," \u4e5f\u5c31\u662f\u9519\u8bef\u7801\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a ",Object(i.b)("inlineCode",{parentName:"p"},"ErrorMessage")," \u6d88\u606f\u5185\u5bb9\uff0c\u5269\u4f59\u53c2\u6570\u4f5c\u4e3a ",Object(i.b)("inlineCode",{parentName:"p"},"ErrorMessage")," \u7684\u683c\u5f0f\u5316\u53c2\u6570\u3002"),Object(i.b)("h4",{id:"\u4f7f\u7528\u793a\u4f8b"},"\u4f7f\u7528\u793a\u4f8b"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,12}","{2,12}":!0}),"using Fur.DynamicApiController;\nusing Fur.FriendlyException;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public int Get(int id)\n {\n if (id < 3)\n {\n throw Oops.Oh(5000, id, 3); // \u53ef\u4ee5\u5c06 5000\u4f5c\u4e3a\u5e38\u91cf\u914d\u7f6e\u8d77\u6765\n }\n\n return id;\n }\n }\n}\n")),Object(i.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"[ErrorCodeType]")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"IErrorCodeTypeProvider")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u53ef\u4ee5\u540c\u65f6\u4f7f\u7528\u3002"))),Object(i.b)("h2",{id:"710-ifexception-\u4f7f\u7528"},"7.10 ",Object(i.b)("inlineCode",{parentName:"h2"},"[IfException]")," \u4f7f\u7528"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86 ",Object(i.b)("inlineCode",{parentName:"p"},"[IfException]")," \u7279\u6027\u53ef\u4ee5",Object(i.b)("strong",{parentName:"p"},"\u8986\u76d6\u9ed8\u8ba4\u6d88\u606f\u914d\u7f6e"),"\u3002\u4e5f\u5c31\u662f\u8986\u76d6 ",Object(i.b)("inlineCode",{parentName:"p"},"\u5f02\u5e38\u6d88\u606f\u7c7b\u578b")," \u548c ",Object(i.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u4e2d\u7684\u914d\u7f6e\u3002"),Object(i.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"[IfException]")," \u53ea\u80fd\u8d34\u5728\u65b9\u6cd5\u4e0a\uff0c\u652f\u6301\u591a\u4e2a\uff0c\u800c\u4e14\u8be5\u65b9\u6cd5\u6240\u5728\u7684\u7c7b\u7c7b\u578b\u5fc5\u987b\u662f ",Object(i.b)("inlineCode",{parentName:"p"},"ControllerBase")," \u5b50\u7c7b \u6216 \u5b9e\u73b0 ",Object(i.b)("inlineCode",{parentName:"p"},"IDynamicApiController")," \u63a5\u53e3\u3002"))),Object(i.b)("h3",{id:"7101-\u4f7f\u7528\u793a\u4f8b"},"7.10.1 \u4f7f\u7528\u793a\u4f8b"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u5f02\u5e38\u6d88\u606f\u7c7b\u5b9a\u4e49")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,4}","{1,4}":!0}),'[ErrorCodeType]\npublic static class ErrorCodes\n{\n [ErrorCodeItemMetadata("{0} \u4e0d\u80fd\u5c0f\u4e8e {1}")]\n z1000\n}\n')),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"\u8986\u76d6\u9ed8\u8ba4\u914d\u7f6e")),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8}","{8}":!0}),'using Fur.DynamicApiController;\nusing Fur.FriendlyException;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [IfException(ErrorCodes.z1000, ErrorMessage = "\u6211\u8986\u76d6\u4e86\u9ed8\u8ba4\u7684\uff1a{0} \u4e0d\u80fd\u5c0f\u4e8e {1}")]\n public int Get(int id)\n {\n if (id < 3)\n {\n throw Oops.Oh(ErrorCodes.z1000, id, 3);\n }\n\n return id;\n }\n }\n}\n')),Object(i.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(i.b)("img",{src:Object(c.a)("img/yhyc4.png")}),Object(i.b)("h3",{id:"7102-\u66f4\u591a\u4f8b\u5b50"},"7.10.2 \u66f4\u591a\u4f8b\u5b50"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,8-11}","{2,8-11}":!0}),'using Fur.DynamicApiController;\nusing Fur.FriendlyException;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [IfException(ErrorCodes.z1000, ErrorMessage = "\u6211\u8986\u76d6\u4e86\u9ed8\u8ba4\u7684\uff1a{0} \u4e0d\u80fd\u5c0f\u4e8e {1}")]\n [IfException(ErrorCodes.x1001, "\u683c\u5f0f\u5316\u53c2\u65701", "\u683c\u5f0f\u5316\u53c2\u65702", ErrorMessage = "\u6211\u8986\u76d6\u4e86\u9ed8\u8ba4\u7684\uff1a{0} \u4e0d\u80fd\u5c0f\u4e8e {1}")]\n [IfException(ErrorCodes.x1000, "\u683c\u5f0f\u5316\u53c2\u65701", "\u683c\u5f0f\u5316\u53c2\u65702")]\n [IfException(ErrorCodes.SERVER_ERROR, "\u683c\u5f0f\u5316\u53c2\u65701", "\u683c\u5f0f\u5316\u53c2\u65702")]\n public int Get(int id)\n {\n if (id < 3)\n {\n throw Oops.Oh(ErrorCodes.z1000, id, 3);\n }\n\n return id;\n }\n }\n}\n')),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u683c\u5f0f\u5316\u6d41\u7a0b")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u5982\u679c\u6d88\u606f\u5185\u5bb9\u4e2d\u5305\u542b",Object(i.b)("inlineCode",{parentName:"p"},"\u683c\u5f0f\u5316\u5360\u4f4d\u7b26"),"\u4f46\u672a\u6307\u5b9a",Object(i.b)("inlineCode",{parentName:"p"},"\u683c\u5f0f\u5316\u53c2\u6570"),"\uff0c\u90a3\u4e48\u4f1a\u67e5\u627e\u5f02\u5e38\u6240\u5728\u65b9\u6cd5\u662f\u5426\u8d34\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"[IfException]")," \u7279\u6027\u4e14\u542b\u6709\u683c\u5f0f\u5316\u53c2\u6570\uff0c\u63a5\u7740\u5c31\u4f1a\u67e5\u627e ",Object(i.b)("inlineCode",{parentName:"p"},"Oops.Oh")," \u4e2d\u6307\u5b9a\u7684 ",Object(i.b)("inlineCode",{parentName:"p"},"\u683c\u5f0f\u5316\u53c2\u6570"),"\u3002"))),Object(i.b)("h2",{id:"711-\u5f02\u5e38\u6d88\u606f\u4f18\u5148\u7ea7"},"7.11 \u5f02\u5e38\u6d88\u606f\u4f18\u5148\u7ea7"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"[ErrorCodeItemMetadata]")," -> ",Object(i.b)("inlineCode",{parentName:"p"},"appsettings.json")," -> ",Object(i.b)("inlineCode",{parentName:"p"},"[IfException]"),"\u3002",Object(i.b)("strong",{parentName:"p"},"\uff08\u4f4e -> \u9ad8\uff09")),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"[IfException]")," \u4f1a\u8986\u76d6 ",Object(i.b)("inlineCode",{parentName:"li"},"appsettings.json")," \u5b9a\u4e49\u7684\u72b6\u6001\u7801\u6d88\u606f\u3002"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"appsettings.json")," \u4f1a\u8986\u76d6 ",Object(i.b)("inlineCode",{parentName:"li"},"[ErrorCodeItemMetadata]")," \u5b9a\u4e49\u7684\u6d88\u606f\u3002")),Object(i.b)("h2",{id:"712-\u591a\u8bed\u8a00\u652f\u6301"},"7.12 \u591a\u8bed\u8a00\u652f\u6301"),Object(i.b)("p",null,"\u6587\u6863\u6574\u7406\u4e2d..."),Object(i.b)("h2",{id:"713-\u5f02\u5e38\u6a21\u578b\u63d0\u4f9b\u5668"},"7.13 \u5f02\u5e38\u6a21\u578b\u63d0\u4f9b\u5668"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b ",Object(i.b)("inlineCode",{parentName:"p"},"\u89c4\u8303\u5316\u7ed3\u679c")," \u529f\u80fd\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b9e\u73b0 ",Object(i.b)("inlineCode",{parentName:"p"},"IUnifyResultProvider")," \u63d0\u4f9b\u5668\u5b9e\u73b0\u5f02\u5e38\u8fd4\u56de\u503c\u5b9a\u5236\uff0c\u5982\uff1a",Object(i.b)("inlineCode",{parentName:"p"},"RESTfulResultProvider"),"\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'using Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.AspNetCore.Mvc.Filters;\nusing Microsoft.AspNetCore.Mvc.ModelBinding;\nusing System.Collections.Generic;\n\nnamespace Fur.UnifyResult\n{\n /// \n /// RESTful \u98ce\u683c\u8fd4\u56de\u503c\n /// \n public class RESTfulResultProvider : IUnifyResultProvider\n {\n /// \n /// \u5f02\u5e38\u8fd4\u56de\u503c\n /// \n /// \n /// \n public IActionResult OnException(ExceptionContext context)\n {\n return new JsonResult(new RESTfulResult\n {\n StatusCode = StatusCodes.Status500InternalServerError,\n Successed = false,\n Data = null,\n Errors = context.Exception.Message\n });\n }\n\n /// \n /// \u6210\u529f\u8fd4\u56de\u503c\n /// \n /// \n /// \n public IActionResult OnSuccessed(ActionExecutedContext context)\n {\n object data;\n // \u5904\u7406\u5185\u5bb9\u7ed3\u679c\n if (context.Result is ContentResult contentResult) data = contentResult.Content;\n // \u5904\u7406\u5bf9\u8c61\u7ed3\u679c\n else if (context.Result is ObjectResult objectResult) data = objectResult.Value;\n else return null;\n\n return new JsonResult(new RESTfulResult\n {\n StatusCode = context.Result is EmptyResult ? StatusCodes.Status204NoContent : StatusCodes.Status200OK,\n Successed = true,\n Data = data,\n Errors = null\n });\n }\n\n /// \n /// \u9a8c\u8bc1\u5931\u8d25\u8fd4\u56de\u503c\n /// \n /// \n /// \n /// \n /// \n /// \n public IActionResult OnValidateFailed(ActionExecutingContext context, ModelStateDictionary modelStates, Dictionary> validationResults, string validateFaildMessage)\n {\n return new JsonResult(new RESTfulResult\n {\n StatusCode = StatusCodes.Status400BadRequest,\n Successed = false,\n Data = null,\n Errors = validationResults\n });\n }\n }\n}\n')),Object(i.b)("p",null,"\u4e4b\u540e\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Startup.cs")," \u4e2d\u6ce8\u518c\u5373\u53ef\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"services.AddControllers().AddUnifyResult();\n")),Object(i.b)("h2",{id:"714-\u53cd\u9988\u4e0e\u5efa\u8bae"},"7.14 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}s.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/654ac364.b869a9ae.js b/handbook/build/654ac364.56187509.js similarity index 78% rename from handbook/build/654ac364.b869a9ae.js rename to handbook/build/654ac364.56187509.js index cd43a6db55b..3baeef89e71 100644 --- a/handbook/build/654ac364.b869a9ae.js +++ b/handbook/build/654ac364.56187509.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[36],{142:function(e,r,t){"use strict";t.d(r,"a",(function(){return l})),t.d(r,"b",(function(){return m}));var n=t(0),o=t.n(n);function a(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function i(e){for(var r=1;r=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=o.a.createContext({}),s=function(e){var r=o.a.useContext(p),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},l=function(e){var r=s(e.components);return o.a.createElement(p.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),l=s(t),d=n,m=l["".concat(c,".").concat(d)]||l[d]||f[d]||a;return t?o.a.createElement(m,i(i({ref:r},p),{},{components:t})):o.a.createElement(m,i({ref:r},p))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,c=new Array(a);c[0]=d;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var p=2;p=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=o.a.createContext({}),s=function(e){var r=o.a.useContext(p),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},l=function(e){var r=s(e.components);return o.a.createElement(p.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),l=s(t),d=n,m=l["".concat(c,".").concat(d)]||l[d]||f[d]||a;return t?o.a.createElement(m,i(i({ref:r},p),{},{components:t})):o.a.createElement(m,i({ref:r},p))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,c=new Array(a);c[0]=d;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var p=2;p0||f)&&n.a.createElement("footer",{className:"row margin-vert--lg"},k.length>0&&n.a.createElement("div",{className:"col"},n.a.createElement("strong",null,"Tags:"),k.map((function(e){var a=e.label,t=e.permalink;return n.a.createElement(o.a,{key:t,className:"margin-horiz--sm",to:t},a)}))),f&&n.a.createElement("div",{className:"col text--right"},n.a.createElement(o.a,{to:p.permalink,"aria-label":"Read more about "+M},n.a.createElement("strong",null,"Read More"))))))}},93:function(e,a,t){"use strict";t.r(a);var r=t(0),n=t.n(r),l=t(153),m=t(156),c=t(151);a.default=function(e){var a=e.metadata,t=e.items,r=a.allTagsPath,o=a.name,s=a.count;return n.a.createElement(l.a,{title:'Posts tagged "'+o+'"',description:'Blog | Tagged "'+o+'"'},n.a.createElement("div",{className:"container margin-vert--lg"},n.a.createElement("div",{className:"row"},n.a.createElement("main",{className:"col col--8 col--offset-2"},n.a.createElement("h1",null,s," ",function(e,a){return e>1?a+"s":a}(s,"post"),' tagged with "',o,'"'),n.a.createElement(c.a,{href:r},"View All Tags"),n.a.createElement("div",{className:"margin-vert--xl"},t.map((function(e){var a=e.content;return n.a.createElement(m.a,{key:a.metadata.permalink,frontMatter:a.frontMatter,metadata:a.metadata,truncated:!0},n.a.createElement(a,null))})))))))}}}]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([[40],{154:function(e,a,t){"use strict";var r=t(152);t.d(a,"a",(function(){return r.a}))},156:function(e,a,t){"use strict";var r=t(0),n=t.n(r),l=t(146),m=t(142),c=t(155),o=t(151),s=t(159),i=t(144),u=t(48),g=t.n(u),E=["January","February","March","April","May","June","July","August","September","October","November","December"];a.a=function(e){var a,t,r,u,d,v=e.children,h=e.frontMatter,p=e.metadata,f=e.truncated,b=e.isBlogPostPage,N=void 0!==b&&b,_=p.date,w=p.permalink,k=p.tags,y=p.readingTime,T=h.author,M=h.title,P=h.image,J=h.keywords,F=h.author_url||h.authorURL,I=h.author_title||h.authorTitle,R=h.author_image_url||h.authorImageURL,j=Object(i.a)(P,{absolute:!0});return n.a.createElement(n.a.Fragment,null,n.a.createElement(c.a,null,J&&J.length&&n.a.createElement("meta",{name:"keywords",content:J.join(",")}),P&&n.a.createElement("meta",{property:"og:image",content:j}),P&&n.a.createElement("meta",{property:"twitter:image",content:j}),P&&n.a.createElement("meta",{name:"twitter:image:alt",content:"Image for "+M})),n.a.createElement("article",{className:N?void 0:"margin-bottom--xl"},(a=N?"h1":"h2",t=_.substring(0,10).split("-"),r=t[0],u=E[parseInt(t[1],10)-1],d=parseInt(t[2],10),n.a.createElement("header",null,n.a.createElement(a,{className:Object(l.a)("margin-bottom--sm",g.a.blogPostTitle)},N?M:n.a.createElement(o.a,{to:w},M)),n.a.createElement("div",{className:"margin-vert--md"},n.a.createElement("time",{dateTime:_,className:g.a.blogPostDate},u," ",d,", ",r," ",y&&n.a.createElement(n.a.Fragment,null," \xb7 ",Math.ceil(y)," min read"))),n.a.createElement("div",{className:"avatar margin-vert--md"},R&&n.a.createElement("a",{className:"avatar__photo-link avatar__photo",href:F,target:"_blank",rel:"noreferrer noopener"},n.a.createElement("img",{src:R,alt:T})),n.a.createElement("div",{className:"avatar__intro"},T&&n.a.createElement(n.a.Fragment,null,n.a.createElement("h4",{className:"avatar__name"},n.a.createElement("a",{href:F,target:"_blank",rel:"noreferrer noopener"},T)),n.a.createElement("small",{className:"avatar__subtitle"},I)))))),n.a.createElement("section",{className:"markdown"},n.a.createElement(m.a,{components:s.a},v)),(k.length>0||f)&&n.a.createElement("footer",{className:"row margin-vert--lg"},k.length>0&&n.a.createElement("div",{className:"col"},n.a.createElement("strong",null,"Tags:"),k.map((function(e){var a=e.label,t=e.permalink;return n.a.createElement(o.a,{key:t,className:"margin-horiz--sm",to:t},a)}))),f&&n.a.createElement("div",{className:"col text--right"},n.a.createElement(o.a,{to:p.permalink,"aria-label":"Read more about "+M},n.a.createElement("strong",null,"Read More"))))))}},96:function(e,a,t){"use strict";t.r(a);var r=t(0),n=t.n(r),l=t(153),m=t(156),c=t(151);a.default=function(e){var a=e.metadata,t=e.items,r=a.allTagsPath,o=a.name,s=a.count;return n.a.createElement(l.a,{title:'Posts tagged "'+o+'"',description:'Blog | Tagged "'+o+'"'},n.a.createElement("div",{className:"container margin-vert--lg"},n.a.createElement("div",{className:"row"},n.a.createElement("main",{className:"col col--8 col--offset-2"},n.a.createElement("h1",null,s," ",function(e,a){return e>1?a+"s":a}(s,"post"),' tagged with "',o,'"'),n.a.createElement(c.a,{href:r},"View All Tags"),n.a.createElement("div",{className:"margin-vert--xl"},t.map((function(e){var a=e.content;return n.a.createElement(m.a,{key:a.metadata.permalink,frontMatter:a.frontMatter,metadata:a.metadata,truncated:!0},n.a.createElement(a,null))})))))))}}}]); \ No newline at end of file diff --git a/handbook/build/70699f3e.0d9dc710.js b/handbook/build/70699f3e.ab80af1c.js similarity index 79% rename from handbook/build/70699f3e.0d9dc710.js rename to handbook/build/70699f3e.ab80af1c.js index ba20463f90f..a58e5cb199c 100644 --- a/handbook/build/70699f3e.0d9dc710.js +++ b/handbook/build/70699f3e.ab80af1c.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[38],{142:function(e,r,t){"use strict";t.d(r,"a",(function(){return s})),t.d(r,"b",(function(){return m}));var n=t(0),o=t.n(n);function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function i(e){for(var r=1;r=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var l=o.a.createContext({}),p=function(e){var r=o.a.useContext(l),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},s=function(e){var r=p(e.components);return o.a.createElement(l.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,c=e.originalType,a=e.parentName,l=u(e,["components","mdxType","originalType","parentName"]),s=p(t),d=n,m=s["".concat(a,".").concat(d)]||s[d]||f[d]||c;return t?o.a.createElement(m,i(i({ref:r},l),{},{components:t})):o.a.createElement(m,i({ref:r},l))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var c=t.length,a=new Array(c);a[0]=d;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,a[1]=i;for(var l=2;l=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var l=o.a.createContext({}),p=function(e){var r=o.a.useContext(l),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},s=function(e){var r=p(e.components);return o.a.createElement(l.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,c=e.originalType,a=e.parentName,l=u(e,["components","mdxType","originalType","parentName"]),s=p(t),d=n,m=s["".concat(a,".").concat(d)]||s[d]||f[d]||c;return t?o.a.createElement(m,i(i({ref:r},l),{},{components:t})):o.a.createElement(m,i({ref:r},l))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var c=t.length,a=new Array(c);a[0]=d;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,a[1]=i;for(var l=2;l=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var p=o.a.createContext({}),l=function(e){var t=o.a.useContext(p),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},s=function(e){var t=l(e.components);return o.a.createElement(p.Provider,{value:t},e.children)},f={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},b=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,c=e.originalType,a=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),s=l(r),b=n,d=s["".concat(a,".").concat(b)]||s[b]||f[b]||c;return r?o.a.createElement(d,i(i({ref:t},p),{},{components:r})):o.a.createElement(d,i({ref:t},p))}));function d(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var c=r.length,a=new Array(c);a[0]=b;var i={};for(var u in t)hasOwnProperty.call(t,u)&&(i[u]=t[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,a[1]=i;for(var p=2;p=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var p=o.a.createContext({}),l=function(e){var t=o.a.useContext(p),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},f=function(e){var t=l(e.components);return o.a.createElement(p.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},b=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,c=e.originalType,a=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),f=l(r),b=n,d=f["".concat(a,".").concat(b)]||f[b]||s[b]||c;return r?o.a.createElement(d,i(i({ref:t},p),{},{components:r})):o.a.createElement(d,i({ref:t},p))}));function d(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var c=r.length,a=new Array(c);a[0]=b;var i={};for(var u in t)hasOwnProperty.call(t,u)&&(i[u]=t[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,a[1]=i;for(var p=2;p=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var s=o.a.createContext({}),d=function(e){var n=o.a.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):i(i({},n),e)),t},u=function(e){var n=d(e.components);return o.a.createElement(s.Provider,{value:n},e.children)},b={inlineCode:"code",wrapper:function(e){var n=e.children;return o.a.createElement(o.a.Fragment,{},n)}},m=o.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,r=e.originalType,c=e.parentName,s=l(e,["components","mdxType","originalType","parentName"]),u=d(t),m=a,p=u["".concat(c,".").concat(m)]||u[m]||b[m]||r;return t?o.a.createElement(p,i(i({ref:n},s),{},{components:t})):o.a.createElement(p,i({ref:n},s))}));function p(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var r=t.length,c=new Array(r);c[0]=m;var i={};for(var l in n)hasOwnProperty.call(n,l)&&(i[l]=n[l]);i.originalType=e,i.mdxType="string"==typeof e?e:a,c[1]=i;for(var s=2;sDbConnectionInterceptor",id:"92421-dbconnectioninterceptor",children:[]},{value:"9.24.2.2 DbCommandInterceptor",id:"92422-dbcommandinterceptor",children:[]},{value:"9.24.2.3 SaveChangesInterceptor",id:"92423-savechangesinterceptor",children:[]},{value:"9.24.2.4 SavedChangesEvent \u62e6\u622a",id:"92424-savedchangesevent-\u62e6\u622a",children:[]}]},{value:"9.24.3 \u6ce8\u518c\u81ea\u5b9a\u4e49\u8fc7\u6ee4\u5668",id:"9243-\u6ce8\u518c\u81ea\u5b9a\u4e49\u8fc7\u6ee4\u5668",children:[]},{value:"9.24.4 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9244-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],s={rightToc:l};function d(e){var n=e.components,t=Object(o.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},s,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"9241-\u6570\u636e\u5e93\u62e6\u622a\u5668"},"9.24.1 \u6570\u636e\u5e93\u62e6\u622a\u5668"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u56db\u79cd\u6570\u636e\u5e93\u64cd\u4f5c\u62e6\u622a\u5668\uff0c\u53ef\u4ee5\u901a\u8fc7\u62e6\u622a\u5668\u52a8\u6001\u4fee\u8be5\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u52a8\u6001\u4fee\u6539sql\uff0c\u52a8\u6001\u66f4\u6539\u53c2\u6570\u7b49\u64cd\u4f5c\u3002"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u652f\u6301\u8fd9\u56db\u79cd\u62e6\u622a\u5668\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DbConnectionInterceptor"),"\uff1a\u6570\u636e\u5e93\u8fde\u63a5\u62e6\u622a\u5668"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DbCommandInterceptor"),"\uff1a\u6570\u636e\u5e93\u6267\u884c ",Object(r.b)("inlineCode",{parentName:"li"},"Sql")," \u62e6\u622a\u5668"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"SaveChangesInterceptor"),"\uff1a\u63d0\u4ea4\u5230\u6570\u636e\u5e93\u62e6\u622a\u5668"),Object(r.b)("li",{parentName:"ul"},"\u5728\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u4e2d\u91cd\u5199 ",Object(r.b)("inlineCode",{parentName:"li"},"SavedChangesEvent")," \u76f8\u5173\u4e8b\u4ef6")),Object(r.b)("h2",{id:"9242-\u652f\u6301\u62e6\u622a\u7c7b\u578b"},"9.24.2 \u652f\u6301\u62e6\u622a\u7c7b\u578b"),Object(r.b)("h3",{id:"92421-dbconnectioninterceptor"},"9.24.2.1 ",Object(r.b)("inlineCode",{parentName:"h3"},"DbConnectionInterceptor")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"using Microsoft.EntityFrameworkCore.Diagnostics;\nusing System.Data.Common;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace Fur.DatabaseAccessor.Interceptors\n{\n public class SqlConnectionInterceptor : DbConnectionInterceptor\n {\n // \u6570\u636e\u5e93\u8fde\u63a5\u4e4b\u524d\n public override InterceptionResult ConnectionOpening(DbConnection connection, ConnectionEventData eventData, InterceptionResult result)\n {\n return base.ConnectionOpening(connection, eventData, result);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u4e4b\u524d\uff08\u5f02\u6b65\uff09\n public override ValueTask ConnectionOpeningAsync(DbConnection connection, ConnectionEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default)\n {\n return base.ConnectionOpeningAsync(connection, eventData, result, cancellationToken);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u6210\u529f\n public override void ConnectionOpened(DbConnection connection, ConnectionEndEventData eventData)\n {\n base.ConnectionOpened(connection, eventData);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u6210\u529f\uff08\u5f02\u6b65\uff09\n public override Task ConnectionOpenedAsync(DbConnection connection, ConnectionEndEventData eventData, CancellationToken cancellationToken = default)\n {\n return base.ConnectionOpenedAsync(connection, eventData, cancellationToken);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u5173\u95ed\u4e4b\u524d\n public override InterceptionResult ConnectionClosing(DbConnection connection, ConnectionEventData eventData, InterceptionResult result)\n {\n return base.ConnectionClosing(connection, eventData, result);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u5173\u95ed\u4e4b\u524d\uff08\u5f02\u6b65\uff09\n public override ValueTask ConnectionClosingAsync(DbConnection connection, ConnectionEventData eventData, InterceptionResult result)\n {\n return base.ConnectionClosingAsync(connection, eventData, result);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u5173\u95ed\u6210\u529f\n public override void ConnectionClosed(DbConnection connection, ConnectionEndEventData eventData)\n {\n base.ConnectionClosed(connection, eventData);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u5173\u95ed\u6210\u529f\uff08\u5f02\u6b65\uff09\n public override Task ConnectionClosedAsync(DbConnection connection, ConnectionEndEventData eventData)\n {\n return base.ConnectionClosedAsync(connection, eventData);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u5931\u8d25\n public override void ConnectionFailed(DbConnection connection, ConnectionErrorEventData eventData)\n {\n base.ConnectionFailed(connection, eventData);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u5931\u8d25\uff08\u5f02\u6b65\uff09\n public override Task ConnectionFailedAsync(DbConnection connection, ConnectionErrorEventData eventData, CancellationToken cancellationToken = default)\n {\n return base.ConnectionFailedAsync(connection, eventData, cancellationToken);\n }\n }\n}\n")),Object(r.b)("h3",{id:"92422-dbcommandinterceptor"},"9.24.2.2 ",Object(r.b)("inlineCode",{parentName:"h3"},"DbCommandInterceptor")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"using Microsoft.EntityFrameworkCore.Diagnostics;\nusing System.Data.Common;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace Fur.DatabaseAccessor\n{\n internal sealed class SqlCommandProfilerInterceptor : DbCommandInterceptor\n {\n // \u521b\u5efa\u547d\u4ee4\u5bf9\u8c61\u4e4b\u524d\n public override InterceptionResult CommandCreating(CommandCorrelatedEventData eventData, InterceptionResult result)\n {\n return base.CommandCreating(eventData, result);\n }\n\n // \u521b\u5efa\u547d\u4ee4\u5bf9\u8c61\u4e4b\u540e\n public override DbCommand CommandCreated(CommandEndEventData eventData, DbCommand result)\n {\n return base.CommandCreated(eventData, result);\n }\n\n // \u521b\u5efa\u547d\u4ee4\u5bf9\u8c61\u5931\u8d25\n public override void CommandFailed(DbCommand command, CommandErrorEventData eventData)\n {\n base.CommandFailed(command, eventData);\n }\n\n // \u521b\u5efa\u547d\u4ee4\u5bf9\u8c61\u5931\u8d25\uff08\u5f02\u6b65\uff09\n public override Task CommandFailedAsync(DbCommand command, CommandErrorEventData eventData, CancellationToken cancellationToken = default)\n {\n return base.CommandFailedAsync(command, eventData, cancellationToken);\n }\n\n // \u8bfb\u53d6\u6570\u636e\u4e4b\u524d\n public override InterceptionResult ReaderExecuting(DbCommand command, CommandEventData eventData, InterceptionResult result)\n {\n return base.ReaderExecuting(command, eventData, result);\n }\n\n // \u8bfb\u53d6\u6570\u636e\u4e4b\u524d\uff08\u5f02\u6b65\uff09\n public override ValueTask> ReaderExecutingAsync(DbCommand command, CommandEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default)\n {\n return base.ReaderExecutingAsync(command, eventData, result, cancellationToken);\n }\n\n // \u8bfb\u53d6\u6570\u636e\u4e4b\u540e\n public override DbDataReader ReaderExecuted(DbCommand command, CommandExecutedEventData eventData, DbDataReader result)\n {\n return base.ReaderExecuted(command, eventData, result);\n }\n\n // \u8bfb\u53d6\u6570\u636e\u4e4b\u540e\uff08\u5f02\u6b65\uff09\n public override ValueTask ReaderExecutedAsync(DbCommand command, CommandExecutedEventData eventData, DbDataReader result, CancellationToken cancellationToken = default)\n {\n return base.ReaderExecutedAsync(command, eventData, result, cancellationToken);\n }\n\n // DataReader \u5bf9\u8c61\u91ca\u653e\u4e4b\u524d\n public override InterceptionResult DataReaderDisposing(DbCommand command, DataReaderDisposingEventData eventData, InterceptionResult result)\n {\n return base.DataReaderDisposing(command, eventData, result);\n }\n\n // \u65e0\u67e5\u8be2\u6267\u884c sql \u4e4b\u524d\n public override InterceptionResult NonQueryExecuting(DbCommand command, CommandEventData eventData, InterceptionResult result)\n {\n return base.NonQueryExecuting(command, eventData, result);\n }\n\n // \u65e0\u67e5\u8be2\u6267\u884c sql \u4e4b\u524d\uff08\u5f02\u6b65\uff09\n public override ValueTask> NonQueryExecutingAsync(DbCommand command, CommandEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default)\n {\n return base.NonQueryExecutingAsync(command, eventData, result, cancellationToken);\n }\n\n // \u65e0\u67e5\u8be2\u6267\u884c sql \u4e4b\u540e\n public override int NonQueryExecuted(DbCommand command, CommandExecutedEventData eventData, int result)\n {\n return base.NonQueryExecuted(command, eventData, result);\n }\n\n // \u65e0\u67e5\u8be2\u6267\u884c sql \u4e4b\u540e\uff08\u5f02\u6b65\uff09\n public override ValueTask NonQueryExecutedAsync(DbCommand command, CommandExecutedEventData eventData, int result, CancellationToken cancellationToken = default)\n {\n return base.NonQueryExecutedAsync(command, eventData, result, cancellationToken);\n }\n\n // \u6267\u884c sql \u8fd4\u56de\u5355\u884c\u5355\u5217\u4e4b\u524d\n public override InterceptionResult ScalarExecuting(DbCommand command, CommandEventData eventData, InterceptionResult result)\n {\n return base.ScalarExecuting(command, eventData, result);\n }\n\n // \u6267\u884c sql \u8fd4\u56de\u5355\u884c\u5355\u5217\u4e4b\u524d\uff08\u5f02\u6b65\uff09\n public override ValueTask> ScalarExecutingAsync(DbCommand command, CommandEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default)\n {\n return base.ScalarExecutingAsync(command, eventData, result, cancellationToken);\n }\n\n // \u6267\u884c sql \u8fd4\u56de\u5355\u884c\u5355\u5217\u4e4b\u540e\n public override object ScalarExecuted(DbCommand command, CommandExecutedEventData eventData, object result)\n {\n return base.ScalarExecuted(command, eventData, result);\n }\n\n // \u6267\u884c sql \u8fd4\u56de\u5355\u884c\u5355\u5217\u4e4b\u540e\uff08\u5f02\u6b65\uff09\n public override ValueTask ScalarExecutedAsync(DbCommand command, CommandExecutedEventData eventData, object result, CancellationToken cancellationToken = default)\n {\n return base.ScalarExecutedAsync(command, eventData, result, cancellationToken);\n }\n }\n}\n")),Object(r.b)("h3",{id:"92423-savechangesinterceptor"},"9.24.2.3 ",Object(r.b)("inlineCode",{parentName:"h3"},"SaveChangesInterceptor")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"using Microsoft.EntityFrameworkCore.Diagnostics;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace Fur.DatabaseAccessor\n{\n public class DbContextSaveChangesInterceptor : SaveChangesInterceptor\n {\n // \u63d0\u4ea4\u5230\u6570\u636e\u5e93\u4e4b\u524d\n public override InterceptionResult SavingChanges(DbContextEventData eventData, InterceptionResult result)\n {\n return base.SavingChanges(eventData, result);\n }\n\n // \u63d0\u4ea4\u5230\u6570\u636e\u5e93\u4e4b\u524d\uff08\u5f02\u6b65\uff09\n public override ValueTask> SavingChangesAsync(DbContextEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default)\n {\n return base.SavingChangesAsync(eventData, result, cancellationToken);\n }\n\n // \u63d0\u4ea4\u5230\u6570\u636e\u5e93\u4e4b\u540e\n public override int SavedChanges(SaveChangesCompletedEventData eventData, int result)\n {\n return base.SavedChanges(eventData, result);\n }\n\n // \u63d0\u4ea4\u5230\u6570\u636e\u5e93\u4e4b\u540e\uff08\u5f02\u6b65\uff09\n public override ValueTask SavedChangesAsync(SaveChangesCompletedEventData eventData, int result, CancellationToken cancellationToken = default)\n {\n return base.SavedChangesAsync(eventData, result, cancellationToken);\n }\n\n // \u63d0\u4ea4\u6570\u636e\u5e93\u5931\u8d25\n public override void SaveChangesFailed(DbContextErrorEventData eventData)\n {\n base.SaveChangesFailed(eventData);\n }\n\n // \u63d0\u4ea4\u6570\u636e\u5e93\u5931\u8d25\uff08\u5f02\u6b65\uff09\n public override Task SaveChangesFailedAsync(DbContextErrorEventData eventData, CancellationToken cancellationToken = default)\n {\n return base.SaveChangesFailedAsync(eventData, cancellationToken);\n }\n }\n}\n")),Object(r.b)("h3",{id:"92424-savedchangesevent-\u62e6\u622a"},"9.24.2.4 ",Object(r.b)("inlineCode",{parentName:"h3"},"SavedChangesEvent")," \u62e6\u622a"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u4e3a\u6240\u6709 ",Object(r.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u5b50\u7c7b\u90fd\u63d0\u4f9b\u4e86\u4e09\u4e2a\u53ef\u91cd\u5199\u7684\u65b9\u6cd5\uff0c\u8fd9\u4e09\u4e2a\u65b9\u6cd5\u5206\u522b\u7531\u4e09\u4e2a\u4e8b\u4ef6\u89e6\u53d1\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u63d0\u4ea4\u66f4\u6539\u4e4b\u524d SavingChanges \u4e8b\u4ef6"),"\uff1a\u89e6\u53d1 ",Object(r.b)("inlineCode",{parentName:"li"},"void SavingChangesEvent(object sender, SavingChangesEventArgs e)")," \u65b9\u6cd5"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u63d0\u4ea4\u66f4\u6539\u4e4b\u540e SavedChanges \u4e8b\u4ef6"),"\uff1a\u89e6\u53d1 ",Object(r.b)("inlineCode",{parentName:"li"},"void SavedChangesEvent(object sender, SavedChangesEventArgs e)")," \u65b9\u6cd5"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u63d0\u4ea4\u66f4\u6539\u5931\u8d25 SaveChangesFailed \u4e8b\u4ef6"),"\uff1a\u89e6\u53d1 ",Object(r.b)("inlineCode",{parentName:"li"},"void SaveChangesFailedEvent(object sender, SaveChangesFailedEventArgs e)")," \u65b9\u6cd5")),Object(r.b)("p",null,"\u901a\u8fc7\u8fd9\u4e09\u4e2a\u4e8b\u4ef6\u6211\u4eec\u53ef\u4ee5",Object(r.b)("strong",{parentName:"p"},"\u5728\u6570\u636e\u5e93\u505a\u589e\u3001\u5220\u3001\u6539\u65f6\u5019\u505a\u62e6\u622a\uff0c\u6bd4\u5982\u8bbe\u7f6e\u521b\u5efa\u65f6\u95f4\u3001\u66f4\u65b0\u65f6\u95f4\u6216\u5176\u4ed6\u9ed8\u8ba4\u64cd\u4f5c"),"\u3002"),Object(r.b)("p",null,"\u5982\u81ea\u52a8\u6dfb\u52a0\u79df\u6237Id\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"protected override void SavingChangesEvent(object sender, SavingChangesEventArgs e)\n{\n // \u83b7\u53d6\u5f53\u524d\u4e8b\u4ef6\u5bf9\u5e94\u4e0a\u4e0b\u6587\n var dbContext = sender as FurDbContext;\n // \u83b7\u53d6\u6240\u6709\u65b0\u589e\u548c\u66f4\u65b0\u7684\u5b9e\u4f53\n var entities = dbContext.ChangeTracker.Entries()\n .Where(u => u.State == EntityState.Added || u.State == EntityState.Modified);\n foreach (var entity in entities)\n {\n switch (entity.State)\n {\n // \u81ea\u52a8\u8bbe\u7f6e\u79df\u6237Id\n case EntityState.Added:\n entity.Property(nameof(Entity.TenantId)).CurrentValue = GetTenantId();\n break;\n // \u6392\u9664\u79df\u6237Id\n case EntityState.Modified:\n entity.Property(nameof(Entity.TenantId)).IsModified = false;\n break;\n }\n }\n}\n")),Object(r.b)("h2",{id:"9243-\u6ce8\u518c\u81ea\u5b9a\u4e49\u8fc7\u6ee4\u5668"},"9.24.3 \u6ce8\u518c\u81ea\u5b9a\u4e49\u8fc7\u6ee4\u5668"),Object(r.b)("p",null,"\u5b9a\u4e49\u597d\u8fc7\u6ee4\u5668\u4e4b\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u4e2d\u6ce8\u518c\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"services.AddSqlitePool(interceptors: new IInterceptor[] {\n new SqlConnectionProfilerInterceptor(),\n new DbContextSaveChangesInterceptor(),\n new SqlCommandProfilerInterceptor()\n});\n")),Object(r.b)("h2",{id:"9244-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.24.4 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/7b4b163f.dcdeae35.js b/handbook/build/7b4b163f.dcdeae35.js new file mode 100644 index 00000000000..9f58c6a5398 --- /dev/null +++ b/handbook/build/7b4b163f.dcdeae35.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[43],{142:function(e,n,t){"use strict";t.d(n,"a",(function(){return u})),t.d(n,"b",(function(){return p}));var a=t(0),o=t.n(a);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function i(e){for(var n=1;n=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var s=o.a.createContext({}),d=function(e){var n=o.a.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):i(i({},n),e)),t},u=function(e){var n=d(e.components);return o.a.createElement(s.Provider,{value:n},e.children)},b={inlineCode:"code",wrapper:function(e){var n=e.children;return o.a.createElement(o.a.Fragment,{},n)}},m=o.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,r=e.originalType,c=e.parentName,s=l(e,["components","mdxType","originalType","parentName"]),u=d(t),m=a,p=u["".concat(c,".").concat(m)]||u[m]||b[m]||r;return t?o.a.createElement(p,i(i({ref:n},s),{},{components:t})):o.a.createElement(p,i({ref:n},s))}));function p(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var r=t.length,c=new Array(r);c[0]=m;var i={};for(var l in n)hasOwnProperty.call(n,l)&&(i[l]=n[l]);i.originalType=e,i.mdxType="string"==typeof e?e:a,c[1]=i;for(var s=2;sDbConnectionInterceptor",id:"92421-dbconnectioninterceptor",children:[]},{value:"9.24.2.2 DbCommandInterceptor",id:"92422-dbcommandinterceptor",children:[]},{value:"9.24.2.3 SaveChangesInterceptor",id:"92423-savechangesinterceptor",children:[]},{value:"9.24.2.4 SavedChangesEvent \u62e6\u622a",id:"92424-savedchangesevent-\u62e6\u622a",children:[]}]},{value:"9.24.3 \u6ce8\u518c\u81ea\u5b9a\u4e49\u8fc7\u6ee4\u5668",id:"9243-\u6ce8\u518c\u81ea\u5b9a\u4e49\u8fc7\u6ee4\u5668",children:[]},{value:"9.24.4 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9244-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],s={rightToc:l};function d(e){var n=e.components,t=Object(o.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},s,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"9241-\u6570\u636e\u5e93\u62e6\u622a\u5668"},"9.24.1 \u6570\u636e\u5e93\u62e6\u622a\u5668"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u56db\u79cd\u6570\u636e\u5e93\u64cd\u4f5c\u62e6\u622a\u5668\uff0c\u53ef\u4ee5\u901a\u8fc7\u62e6\u622a\u5668\u52a8\u6001\u4fee\u8be5\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u52a8\u6001\u4fee\u6539sql\uff0c\u52a8\u6001\u66f4\u6539\u53c2\u6570\u7b49\u64cd\u4f5c\u3002"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u652f\u6301\u8fd9\u56db\u79cd\u62e6\u622a\u5668\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DbConnectionInterceptor"),"\uff1a\u6570\u636e\u5e93\u8fde\u63a5\u62e6\u622a\u5668"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DbCommandInterceptor"),"\uff1a\u6570\u636e\u5e93\u6267\u884c ",Object(r.b)("inlineCode",{parentName:"li"},"Sql")," \u62e6\u622a\u5668"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"SaveChangesInterceptor"),"\uff1a\u63d0\u4ea4\u5230\u6570\u636e\u5e93\u62e6\u622a\u5668"),Object(r.b)("li",{parentName:"ul"},"\u5728\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u4e2d\u91cd\u5199 ",Object(r.b)("inlineCode",{parentName:"li"},"SavedChangesEvent")," \u76f8\u5173\u4e8b\u4ef6")),Object(r.b)("h2",{id:"9242-\u652f\u6301\u62e6\u622a\u7c7b\u578b"},"9.24.2 \u652f\u6301\u62e6\u622a\u7c7b\u578b"),Object(r.b)("h3",{id:"92421-dbconnectioninterceptor"},"9.24.2.1 ",Object(r.b)("inlineCode",{parentName:"h3"},"DbConnectionInterceptor")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"using Microsoft.EntityFrameworkCore.Diagnostics;\nusing System.Data.Common;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace Fur.DatabaseAccessor.Interceptors\n{\n public class SqlConnectionInterceptor : DbConnectionInterceptor\n {\n // \u6570\u636e\u5e93\u8fde\u63a5\u4e4b\u524d\n public override InterceptionResult ConnectionOpening(DbConnection connection, ConnectionEventData eventData, InterceptionResult result)\n {\n return base.ConnectionOpening(connection, eventData, result);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u4e4b\u524d\uff08\u5f02\u6b65\uff09\n public override ValueTask ConnectionOpeningAsync(DbConnection connection, ConnectionEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default)\n {\n return base.ConnectionOpeningAsync(connection, eventData, result, cancellationToken);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u6210\u529f\n public override void ConnectionOpened(DbConnection connection, ConnectionEndEventData eventData)\n {\n base.ConnectionOpened(connection, eventData);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u6210\u529f\uff08\u5f02\u6b65\uff09\n public override Task ConnectionOpenedAsync(DbConnection connection, ConnectionEndEventData eventData, CancellationToken cancellationToken = default)\n {\n return base.ConnectionOpenedAsync(connection, eventData, cancellationToken);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u5173\u95ed\u4e4b\u524d\n public override InterceptionResult ConnectionClosing(DbConnection connection, ConnectionEventData eventData, InterceptionResult result)\n {\n return base.ConnectionClosing(connection, eventData, result);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u5173\u95ed\u4e4b\u524d\uff08\u5f02\u6b65\uff09\n public override ValueTask ConnectionClosingAsync(DbConnection connection, ConnectionEventData eventData, InterceptionResult result)\n {\n return base.ConnectionClosingAsync(connection, eventData, result);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u5173\u95ed\u6210\u529f\n public override void ConnectionClosed(DbConnection connection, ConnectionEndEventData eventData)\n {\n base.ConnectionClosed(connection, eventData);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u5173\u95ed\u6210\u529f\uff08\u5f02\u6b65\uff09\n public override Task ConnectionClosedAsync(DbConnection connection, ConnectionEndEventData eventData)\n {\n return base.ConnectionClosedAsync(connection, eventData);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u5931\u8d25\n public override void ConnectionFailed(DbConnection connection, ConnectionErrorEventData eventData)\n {\n base.ConnectionFailed(connection, eventData);\n }\n\n // \u6570\u636e\u5e93\u8fde\u63a5\u5931\u8d25\uff08\u5f02\u6b65\uff09\n public override Task ConnectionFailedAsync(DbConnection connection, ConnectionErrorEventData eventData, CancellationToken cancellationToken = default)\n {\n return base.ConnectionFailedAsync(connection, eventData, cancellationToken);\n }\n }\n}\n")),Object(r.b)("h3",{id:"92422-dbcommandinterceptor"},"9.24.2.2 ",Object(r.b)("inlineCode",{parentName:"h3"},"DbCommandInterceptor")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"using Microsoft.EntityFrameworkCore.Diagnostics;\nusing System.Data.Common;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace Fur.DatabaseAccessor\n{\n internal sealed class SqlCommandProfilerInterceptor : DbCommandInterceptor\n {\n // \u521b\u5efa\u547d\u4ee4\u5bf9\u8c61\u4e4b\u524d\n public override InterceptionResult CommandCreating(CommandCorrelatedEventData eventData, InterceptionResult result)\n {\n return base.CommandCreating(eventData, result);\n }\n\n // \u521b\u5efa\u547d\u4ee4\u5bf9\u8c61\u4e4b\u540e\n public override DbCommand CommandCreated(CommandEndEventData eventData, DbCommand result)\n {\n return base.CommandCreated(eventData, result);\n }\n\n // \u521b\u5efa\u547d\u4ee4\u5bf9\u8c61\u5931\u8d25\n public override void CommandFailed(DbCommand command, CommandErrorEventData eventData)\n {\n base.CommandFailed(command, eventData);\n }\n\n // \u521b\u5efa\u547d\u4ee4\u5bf9\u8c61\u5931\u8d25\uff08\u5f02\u6b65\uff09\n public override Task CommandFailedAsync(DbCommand command, CommandErrorEventData eventData, CancellationToken cancellationToken = default)\n {\n return base.CommandFailedAsync(command, eventData, cancellationToken);\n }\n\n // \u8bfb\u53d6\u6570\u636e\u4e4b\u524d\n public override InterceptionResult ReaderExecuting(DbCommand command, CommandEventData eventData, InterceptionResult result)\n {\n return base.ReaderExecuting(command, eventData, result);\n }\n\n // \u8bfb\u53d6\u6570\u636e\u4e4b\u524d\uff08\u5f02\u6b65\uff09\n public override ValueTask> ReaderExecutingAsync(DbCommand command, CommandEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default)\n {\n return base.ReaderExecutingAsync(command, eventData, result, cancellationToken);\n }\n\n // \u8bfb\u53d6\u6570\u636e\u4e4b\u540e\n public override DbDataReader ReaderExecuted(DbCommand command, CommandExecutedEventData eventData, DbDataReader result)\n {\n return base.ReaderExecuted(command, eventData, result);\n }\n\n // \u8bfb\u53d6\u6570\u636e\u4e4b\u540e\uff08\u5f02\u6b65\uff09\n public override ValueTask ReaderExecutedAsync(DbCommand command, CommandExecutedEventData eventData, DbDataReader result, CancellationToken cancellationToken = default)\n {\n return base.ReaderExecutedAsync(command, eventData, result, cancellationToken);\n }\n\n // DataReader \u5bf9\u8c61\u91ca\u653e\u4e4b\u524d\n public override InterceptionResult DataReaderDisposing(DbCommand command, DataReaderDisposingEventData eventData, InterceptionResult result)\n {\n return base.DataReaderDisposing(command, eventData, result);\n }\n\n // \u65e0\u67e5\u8be2\u6267\u884c sql \u4e4b\u524d\n public override InterceptionResult NonQueryExecuting(DbCommand command, CommandEventData eventData, InterceptionResult result)\n {\n return base.NonQueryExecuting(command, eventData, result);\n }\n\n // \u65e0\u67e5\u8be2\u6267\u884c sql \u4e4b\u524d\uff08\u5f02\u6b65\uff09\n public override ValueTask> NonQueryExecutingAsync(DbCommand command, CommandEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default)\n {\n return base.NonQueryExecutingAsync(command, eventData, result, cancellationToken);\n }\n\n // \u65e0\u67e5\u8be2\u6267\u884c sql \u4e4b\u540e\n public override int NonQueryExecuted(DbCommand command, CommandExecutedEventData eventData, int result)\n {\n return base.NonQueryExecuted(command, eventData, result);\n }\n\n // \u65e0\u67e5\u8be2\u6267\u884c sql \u4e4b\u540e\uff08\u5f02\u6b65\uff09\n public override ValueTask NonQueryExecutedAsync(DbCommand command, CommandExecutedEventData eventData, int result, CancellationToken cancellationToken = default)\n {\n return base.NonQueryExecutedAsync(command, eventData, result, cancellationToken);\n }\n\n // \u6267\u884c sql \u8fd4\u56de\u5355\u884c\u5355\u5217\u4e4b\u524d\n public override InterceptionResult ScalarExecuting(DbCommand command, CommandEventData eventData, InterceptionResult result)\n {\n return base.ScalarExecuting(command, eventData, result);\n }\n\n // \u6267\u884c sql \u8fd4\u56de\u5355\u884c\u5355\u5217\u4e4b\u524d\uff08\u5f02\u6b65\uff09\n public override ValueTask> ScalarExecutingAsync(DbCommand command, CommandEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default)\n {\n return base.ScalarExecutingAsync(command, eventData, result, cancellationToken);\n }\n\n // \u6267\u884c sql \u8fd4\u56de\u5355\u884c\u5355\u5217\u4e4b\u540e\n public override object ScalarExecuted(DbCommand command, CommandExecutedEventData eventData, object result)\n {\n return base.ScalarExecuted(command, eventData, result);\n }\n\n // \u6267\u884c sql \u8fd4\u56de\u5355\u884c\u5355\u5217\u4e4b\u540e\uff08\u5f02\u6b65\uff09\n public override ValueTask ScalarExecutedAsync(DbCommand command, CommandExecutedEventData eventData, object result, CancellationToken cancellationToken = default)\n {\n return base.ScalarExecutedAsync(command, eventData, result, cancellationToken);\n }\n }\n}\n")),Object(r.b)("h3",{id:"92423-savechangesinterceptor"},"9.24.2.3 ",Object(r.b)("inlineCode",{parentName:"h3"},"SaveChangesInterceptor")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"using Microsoft.EntityFrameworkCore.Diagnostics;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace Fur.DatabaseAccessor\n{\n public class DbContextSaveChangesInterceptor : SaveChangesInterceptor\n {\n // \u63d0\u4ea4\u5230\u6570\u636e\u5e93\u4e4b\u524d\n public override InterceptionResult SavingChanges(DbContextEventData eventData, InterceptionResult result)\n {\n return base.SavingChanges(eventData, result);\n }\n\n // \u63d0\u4ea4\u5230\u6570\u636e\u5e93\u4e4b\u524d\uff08\u5f02\u6b65\uff09\n public override ValueTask> SavingChangesAsync(DbContextEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default)\n {\n return base.SavingChangesAsync(eventData, result, cancellationToken);\n }\n\n // \u63d0\u4ea4\u5230\u6570\u636e\u5e93\u4e4b\u540e\n public override int SavedChanges(SaveChangesCompletedEventData eventData, int result)\n {\n return base.SavedChanges(eventData, result);\n }\n\n // \u63d0\u4ea4\u5230\u6570\u636e\u5e93\u4e4b\u540e\uff08\u5f02\u6b65\uff09\n public override ValueTask SavedChangesAsync(SaveChangesCompletedEventData eventData, int result, CancellationToken cancellationToken = default)\n {\n return base.SavedChangesAsync(eventData, result, cancellationToken);\n }\n\n // \u63d0\u4ea4\u6570\u636e\u5e93\u5931\u8d25\n public override void SaveChangesFailed(DbContextErrorEventData eventData)\n {\n base.SaveChangesFailed(eventData);\n }\n\n // \u63d0\u4ea4\u6570\u636e\u5e93\u5931\u8d25\uff08\u5f02\u6b65\uff09\n public override Task SaveChangesFailedAsync(DbContextErrorEventData eventData, CancellationToken cancellationToken = default)\n {\n return base.SaveChangesFailedAsync(eventData, cancellationToken);\n }\n }\n}\n")),Object(r.b)("h3",{id:"92424-savedchangesevent-\u62e6\u622a"},"9.24.2.4 ",Object(r.b)("inlineCode",{parentName:"h3"},"SavedChangesEvent")," \u62e6\u622a"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u4e3a\u6240\u6709 ",Object(r.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u5b50\u7c7b\u90fd\u63d0\u4f9b\u4e86\u4e09\u4e2a\u53ef\u91cd\u5199\u7684\u65b9\u6cd5\uff0c\u8fd9\u4e09\u4e2a\u65b9\u6cd5\u5206\u522b\u7531\u4e09\u4e2a\u4e8b\u4ef6\u89e6\u53d1\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u63d0\u4ea4\u66f4\u6539\u4e4b\u524d SavingChanges \u4e8b\u4ef6"),"\uff1a\u89e6\u53d1 ",Object(r.b)("inlineCode",{parentName:"li"},"void SavingChangesEvent(object sender, SavingChangesEventArgs e)")," \u65b9\u6cd5"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u63d0\u4ea4\u66f4\u6539\u4e4b\u540e SavedChanges \u4e8b\u4ef6"),"\uff1a\u89e6\u53d1 ",Object(r.b)("inlineCode",{parentName:"li"},"void SavedChangesEvent(object sender, SavedChangesEventArgs e)")," \u65b9\u6cd5"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u63d0\u4ea4\u66f4\u6539\u5931\u8d25 SaveChangesFailed \u4e8b\u4ef6"),"\uff1a\u89e6\u53d1 ",Object(r.b)("inlineCode",{parentName:"li"},"void SaveChangesFailedEvent(object sender, SaveChangesFailedEventArgs e)")," \u65b9\u6cd5")),Object(r.b)("p",null,"\u901a\u8fc7\u8fd9\u4e09\u4e2a\u4e8b\u4ef6\u6211\u4eec\u53ef\u4ee5",Object(r.b)("strong",{parentName:"p"},"\u5728\u6570\u636e\u5e93\u505a\u589e\u3001\u5220\u3001\u6539\u65f6\u5019\u505a\u62e6\u622a\uff0c\u6bd4\u5982\u8bbe\u7f6e\u521b\u5efa\u65f6\u95f4\u3001\u66f4\u65b0\u65f6\u95f4\u6216\u5176\u4ed6\u9ed8\u8ba4\u64cd\u4f5c"),"\u3002"),Object(r.b)("p",null,"\u5982\u81ea\u52a8\u6dfb\u52a0\u79df\u6237Id\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"protected override void SavingChangesEvent(object sender, SavingChangesEventArgs e)\n{\n // \u83b7\u53d6\u5f53\u524d\u4e8b\u4ef6\u5bf9\u5e94\u4e0a\u4e0b\u6587\n var dbContext = sender as FurDbContext;\n // \u83b7\u53d6\u6240\u6709\u65b0\u589e\u548c\u66f4\u65b0\u7684\u5b9e\u4f53\n var entities = dbContext.ChangeTracker.Entries()\n .Where(u => u.State == EntityState.Added || u.State == EntityState.Modified);\n foreach (var entity in entities)\n {\n switch (entity.State)\n {\n // \u81ea\u52a8\u8bbe\u7f6e\u79df\u6237Id\n case EntityState.Added:\n entity.Property(nameof(Entity.TenantId)).CurrentValue = GetTenantId();\n break;\n // \u6392\u9664\u79df\u6237Id\n case EntityState.Modified:\n entity.Property(nameof(Entity.TenantId)).IsModified = false;\n break;\n }\n }\n}\n")),Object(r.b)("h2",{id:"9243-\u6ce8\u518c\u81ea\u5b9a\u4e49\u8fc7\u6ee4\u5668"},"9.24.3 \u6ce8\u518c\u81ea\u5b9a\u4e49\u8fc7\u6ee4\u5668"),Object(r.b)("p",null,"\u5b9a\u4e49\u597d\u8fc7\u6ee4\u5668\u4e4b\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u4e2d\u6ce8\u518c\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"services.AddSqlitePool(interceptors: new IInterceptor[] {\n new SqlConnectionProfilerInterceptor(),\n new DbContextSaveChangesInterceptor(),\n new SqlCommandProfilerInterceptor()\n});\n")),Object(r.b)("h2",{id:"9244-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.24.4 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/7c7b3a8a.a8db9a6c.js b/handbook/build/7c7b3a8a.a8db9a6c.js new file mode 100644 index 00000000000..a39269bb701 --- /dev/null +++ b/handbook/build/7c7b3a8a.a8db9a6c.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[44],{100:function(e,n,r){"use strict";r.r(n),r.d(n,"frontMatter",(function(){return i})),r.d(n,"metadata",(function(){return o})),r.d(n,"rightToc",(function(){return u})),r.d(n,"default",(function(){return p}));var t=r(2),a=r(6),s=(r(0),r(142)),i={id:"dbcontext-query",title:"9.10 \u67e5\u8be2\u64cd\u4f5c",sidebar_label:"9.10 \u67e5\u8be2\u64cd\u4f5c"},o={unversionedId:"dbcontext-query",id:"dbcontext-query",isDocsHomePage:!1,title:"9.10 \u67e5\u8be2\u64cd\u4f5c",description:"9.10.1 \u6839\u636e\u4e3b\u952e\u67e5\u8be2\u4e00\u6761",source:"@site/docs\\dbcontext-query.mdx",slug:"/dbcontext-query",permalink:"/fur/docs/dbcontext-query",editUrl:"https://gitee.com/monksoul/Fur/tree/main/handbook/docs/dbcontext-query.mdx",version:"current",sidebar_label:"9.10 \u67e5\u8be2\u64cd\u4f5c",sidebar:"docs",previous:{title:"9.9 \u6279\u91cf\u64cd\u4f5c",permalink:"/fur/docs/dbcontext-batch"},next:{title:"9.11 \u9ad8\u7ea7\u67e5\u8be2\u64cd\u4f5c",permalink:"/fur/docs/dbcontext-hight-query"}},u=[{value:"9.10.1 \u6839\u636e\u4e3b\u952e\u67e5\u8be2\u4e00\u6761",id:"9101-\u6839\u636e\u4e3b\u952e\u67e5\u8be2\u4e00\u6761",children:[]},{value:"9.10.2 \u6839\u636e\u6761\u4ef6\u67e5\u8be2\u4e00\u6761",id:"9102-\u6839\u636e\u6761\u4ef6\u67e5\u8be2\u4e00\u6761",children:[]},{value:"9.10.3 \u67e5\u8be2\u6240\u6709\u6570\u636e",id:"9103-\u67e5\u8be2\u6240\u6709\u6570\u636e",children:[]},{value:"9.10.4 \u6839\u636e\u6761\u4ef6\u67e5\u8be2\u6240\u6709\u6570\u636e",id:"9104-\u6839\u636e\u6761\u4ef6\u67e5\u8be2\u6240\u6709\u6570\u636e",children:[]},{value:"9.10.5 \u5206\u9875\u67e5\u8be2",id:"9105-\u5206\u9875\u67e5\u8be2",children:[]},{value:"9.10.6 \u5176\u4ed6\u67e5\u8be2",id:"9106-\u5176\u4ed6\u67e5\u8be2",children:[{value:"9.10.6.1 \u67e5\u770b\u8bb0\u5f55\u662f\u5426\u5b58\u5728",id:"91061-\u67e5\u770b\u8bb0\u5f55\u662f\u5426\u5b58\u5728",children:[]},{value:"9.10.6.2 \u67e5\u8be2\u8bb0\u5f55\u6570",id:"91062-\u67e5\u8be2\u8bb0\u5f55\u6570",children:[]},{value:"9.10.6.3 \u67e5\u8be2\u6700\u5927\u503c",id:"91063-\u67e5\u8be2\u6700\u5927\u503c",children:[]},{value:"9.10.6.4 \u67e5\u8be2\u6700\u5c0f\u503c",id:"91064-\u67e5\u8be2\u6700\u5c0f\u503c",children:[]},{value:"9.10.6.5 \u6c42\u548c\u67e5\u8be2",id:"91065-\u6c42\u548c\u67e5\u8be2",children:[]},{value:"9.10.6.6 \u6c42\u5e73\u5747\u503c\u67e5\u8be2",id:"91066-\u6c42\u5e73\u5747\u503c\u67e5\u8be2",children:[]},{value:"9.10.6.7 \u65f6\u95f4\u67e5\u8be2",id:"91067-\u65f6\u95f4\u67e5\u8be2",children:[]},{value:"9.10.6.8 \u6a21\u7cca\u67e5\u8be2",id:"91068-\u6a21\u7cca\u67e5\u8be2",children:[]},{value:"9.10.6.9 Case When",id:"91069-case-when",children:[]}]},{value:"9.10.7 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9107-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],c={rightToc:u};function p(e){var n=e.components,r=Object(a.a)(e,["components"]);return Object(s.b)("wrapper",Object(t.a)({},c,r,{components:n,mdxType:"MDXLayout"}),Object(s.b)("h2",{id:"9101-\u6839\u636e\u4e3b\u952e\u67e5\u8be2\u4e00\u6761"},"9.10.1 \u6839\u636e\u4e3b\u952e\u67e5\u8be2\u4e00\u6761"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar person = repository.Find(1);\n\n// \u793a\u4f8b\u4e8c\nvar person = repository.FindOrDefault(1);\n\n// \u793a\u4f8b\u4e09\nvar person = repository.Entities.Find(1);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar person = await repository.FindAsync(1);\n\n// \u793a\u4f8b\u4e8c\nvar person = await repository.FindOrDefaultAsync(1);\n\n// \u793a\u4f8b\u4e09\nvar person = await repository.Entities.FindAsync(1);\n\n")),Object(s.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(s.b)("h5",{parentName:"div"},Object(s.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(s.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(s.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u63d0\u793a")),Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(s.b)("p",{parentName:"div"},"\u53ef\u4ee5\u652f\u6301\u591a\u4e2a\u952e\u67e5\u8be2\uff0c\u5982\u4e3b\u952e\u3001\u8054\u5408\u952e\u3002",Object(s.b)("inlineCode",{parentName:"p"},'repository.Find(1, "\u767e\u5c0f\u50e7")'),";"))),Object(s.b)("h2",{id:"9102-\u6839\u636e\u6761\u4ef6\u67e5\u8be2\u4e00\u6761"},"9.10.2 \u6839\u636e\u6761\u4ef6\u67e5\u8be2\u4e00\u6761"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar person = repository.Single(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e8c\nvar person = repository.SingleOrDefault(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e09\nvar person = repository.First(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u56db\nvar person = repository.FirstOrDefault(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e94\nvar person = repository.Last(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u516d\nvar person = repository.LastOrDefault(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e03\nvar person = repository.Entities.Single(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u516b\nvar person = repository.Entities.First(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e5d\nvar person = repository.Entities.FirstOrDefault(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u5341\nvar person = repository.Entities.Last(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u5341\u4e00\nvar person = repository.Entities.LastOrDefault(u => u.Name == "Fur");\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar person = await repository.SingleAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e8c\nvar person = await repository.SingleOrDefaultAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e09\nvar person = await repository.FirstAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u56db\nvar person = await repository.FirstOrDefaultAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e94\nvar person = await repository.LastAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u516d\nvar person = await repository.LastOrDefaultAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e03\nvar person = await repository.Entities.SingleAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u516b\nvar person = await repository.Entities.FirstAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e5d\nvar person = await repository.Entities.FirstOrDefaultAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u5341\nvar person = await repository.Entities.LastAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u5341\u4e00\nvar person = await repository.Entities.LastOrDefaultAsync(u => u.Name == "Fur");\n')),Object(s.b)("h2",{id:"9103-\u67e5\u8be2\u6240\u6709\u6570\u636e"},"9.10.3 \u67e5\u8be2\u6240\u6709\u6570\u636e"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = repository.Entities;\n\n// \u793a\u4f8b\u4e8c\nvar persons = repository.DetachedEntities;\n\n// \u793a\u4f8b\u4e09\nvar persons = repository.AsQueryable();\n\n// \u793a\u4f8b\u56db\nvar persons = repository.AsEnumerable();\n\n// \u793a\u4f8b\u4e94\nvar persons = await AsAsyncEnumerable();\n")),Object(s.b)("h2",{id:"9104-\u6839\u636e\u6761\u4ef6\u67e5\u8be2\u6240\u6709\u6570\u636e"},"9.10.4 \u6839\u636e\u6761\u4ef6\u67e5\u8be2\u6240\u6709\u6570\u636e"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// \u793a\u4f8b\u4e00\nvar persons = repository.Where(u => u.Id > 10);\n\n// \u793a\u4f8b\u4e8c\nvar persons = repository.Where(u => u.Id > 10 && u.Name.Equals("Fur"));\n\n// \u793a\u4f8b\u4e09\nvar persons = repository.Where(u => u.Id > 10).Where(u => u.Name.Equals("Fur"));\n\n// \u793a\u4f8b\u56db\nvar persons = repository.Where(!string.IsNullOrEmpty(name), u => u.Id > 10 && u.Name.Equals("Fur"));\n\n// \u793a\u4f8b\u4e94\nvar persons = repository.Where(!string.IsNullOrEmpty(name), u => u.Id > 10)\n .Where(age > 18, u => u.Name.Containes("\u767e\u5c0f\u50e7"))\n .Where(u => u.Age > 18);\n\n// \u793a\u4f8b\u516d\nvar persons = repository.Where(u => u.Name == "Fur",\n u => u.Name == "\u767e\u5c0f\u50e7",\n u => u.Name == "MonkSoul");\n\n// \u793a\u4f8b\u4e03\nvar persons = repository.Where(u => u.Id > 10).Where(u => u.Name.Equals("Fur"))\n .Where(age > 18, u => u.Name.Containes("\u767e\u5c0f\u50e7"))\n .Where(u => u.Name == "Fur",\n u => u.Name == "\u767e\u5c0f\u50e7",\n u => u.Name == "MonkSoul");\n\n// \u793a\u4f8b\u516b\nvar persons = repository.Where((age > 18, u => u.Name == "Fur"),\n (!string.IsNullOrEmpty(name), u => u.Id > 10));\n\n// \u793a\u4f8b\u4e5d\nvar persons = repository.Where(u => u.Id > 10).Where(u => u.Name.Equals("Fur"))\n .Where(age > 18, u => u.Name.Containes("\u767e\u5c0f\u50e7"))\n .Where(u => u.Name == "Fur",\n u => u.Name == "\u767e\u5c0f\u50e7",\n u => u.Name == "MonkSoul")\n .Where((age > 18, u => u.Name == "Fur"),\n (!string.IsNullOrEmpty(name), u => u.Id > 10));\n\n// \u793a\u4f8b\u5341\nvar persons = repository.Entities.Where(u => u.Id > 10)\n .Where(age > 18, u => u.Name.Containes("\u767e\u5c0f\u50e7"));\n\n// \u793a\u4f8b\u5341\u4e00\nvar persons = repository.DetachedEntities.Where(u => u.Id > 20);\n\n// \u793a\u4f8b\u5341\u4e8c\nvar persons = repository.AsQueryable(u => u.Id > 20).Where(u => u.Name == "Fur");\n')),Object(s.b)("h2",{id:"9105-\u5206\u9875\u67e5\u8be2"},"9.10.5 \u5206\u9875\u67e5\u8be2"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = repository.Where(u => u.Id > 10).ToPagedList();\n\n// \u793a\u4f8b\u4e8c\nvar persons = repository.Where(u => u.Id > 10).ToPagedList(1, 10);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = await repository.Where(u => u.Id > 10).ToPagedListAsync();\n\n// \u793a\u4f8b\u4e8c\nvar persons = await repository.Where(u => u.Id > 10).ToPagedListAsync(1, 10);\n")),Object(s.b)("h2",{id:"9106-\u5176\u4ed6\u67e5\u8be2"},"9.10.6 \u5176\u4ed6\u67e5\u8be2"),Object(s.b)("h3",{id:"91061-\u67e5\u770b\u8bb0\u5f55\u662f\u5426\u5b58\u5728"},"9.10.6.1 \u67e5\u770b\u8bb0\u5f55\u662f\u5426\u5b58\u5728"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar isExists = repository.Any();\n\n// \u793a\u4f8b\u4e8c\nvar isExists = repository.Any(u => u.Id > 10);\n\n// \u793a\u4f8b\u4e09\nvar isExists = repository.Entities.Any();\n\n// \u793a\u4f8b\u56db\nvar isExists = repository.DetachedEntities.Any(u => u.Id > 10);\n\n// \u793a\u4f8b\u4e94\nvar isExists = repository.Where(u => u.Id > 10).Any();\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar isExists = await repository.AnyAsync();\n\n// \u793a\u4f8b\u4e8c\nvar isExists = await repository.AnyAsync(u => u.Id > 10);\n\n// \u793a\u4f8b\u4e09\nvar isExists = await repository.Entities.AnyAsync();\n\n// \u793a\u4f8b\u56db\nvar isExists = await repository.DetachedEntities.AnyAsync(u => u.Id > 10);\n\n// \u793a\u4f8b\u4e94\nvar isExists = await repository.Where(u => u.Id > 10).AnyAsync();\n")),Object(s.b)("h3",{id:"91062-\u67e5\u8be2\u8bb0\u5f55\u6570"},"9.10.6.2 \u67e5\u8be2\u8bb0\u5f55\u6570"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar count = repository.Count();\n\n// \u793a\u4f8b\u4e8c\nvar count = repository.Count(u => u.Id > 10);\n\n// \u793a\u4f8b\u4e09\nvar count = repository.Entities.Count(u => u.Id > 10);\n\n// \u793a\u4f8b\u56db\nvar count = repository.Entities.DetachedEntities.Count();\n\n// \u793a\u4f8b\u4e94\nvar count = repository.Where(u => u.Id > 10).Count();\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar count = await repository.CountAsync();\n\n// \u793a\u4f8b\u4e8c\nvar count = await repository.CountAsync(u => u.Id > 10);\n\n// \u793a\u4f8b\u4e09\nvar count = await repository.Entities.CountAsync(u => u.Id > 10);\n\n// \u793a\u4f8b\u56db\nvar count = await repository.Entities.DetachedEntities.CountAsync();\n\n// \u793a\u4f8b\u4e94\nvar count = await repository.Where(u => u.Id > 10).CountAsync();\n")),Object(s.b)("h3",{id:"91063-\u67e5\u8be2\u6700\u5927\u503c"},"9.10.6.3 \u67e5\u8be2\u6700\u5927\u503c"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar entity = repository.Max();\n\n// \u793a\u4f8b\u4e8c\nvar value = repository.Max(u => u.Id);\n\n// \u793a\u4f8b\u4e09\nvar entity = repository.Entities.Max();\n\n// \u793a\u4f8b\u56db\nvar value = repository.Entities.DetachedEntities.Max(u => u.Age);\n\n// \u793a\u4f8b\u4e94\nvar value = repository.Where(u => u.Id > 10).Max(u => u.Age);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar entity = await repository.MaxAsync();\n\n// \u793a\u4f8b\u4e8c\nvar value = await repository.MaxAsync(u => u.Id);\n\n// \u793a\u4f8b\u4e09\nvar entity = await repository.Entities.MaxAsync();\n\n// \u793a\u4f8b\u56db\nvar value = await repository.Entities.DetachedEntities.MaxAsync(u => u.Age);\n\n// \u793a\u4f8b\u4e94\nvar value = await repository.Where(u => u.Id > 10).MaxAsync(u => u.Age);\n")),Object(s.b)("h3",{id:"91064-\u67e5\u8be2\u6700\u5c0f\u503c"},"9.10.6.4 \u67e5\u8be2\u6700\u5c0f\u503c"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar entity = repository.Min();\n\n// \u793a\u4f8b\u4e8c\nvar value = repository.Min(u => u.Id);\n\n// \u793a\u4f8b\u4e09\nvar entity = repository.Entities.Min();\n\n// \u793a\u4f8b\u56db\nvar value = repository.Entities.DetachedEntities.Min(u => u.Age);\n\n// \u793a\u4f8b\u4e94\nvar value = repository.Where(u => u.Id > 10).Min(u => u.Age);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar entity = await repository.MinAsync();\n\n// \u793a\u4f8b\u4e8c\nvar value = await repository.MinAsync(u => u.Id);\n\n// \u793a\u4f8b\u4e09\nvar entity = await repository.Entities.MinAsync();\n\n// \u793a\u4f8b\u56db\nvar value = await repository.Entities.DetachedEntities.MinAsync(u => u.Age);\n\n// \u793a\u4f8b\u4e94\nvar value = await repository.Where(u => u.Id > 10).MinAsync(u => u.Age);\n")),Object(s.b)("h3",{id:"91065-\u6c42\u548c\u67e5\u8be2"},"9.10.6.5 \u6c42\u548c\u67e5\u8be2"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar sum = repository.Entities.Sum(u => u.Cost);\n\n// \u793a\u4f8b\u4e8c\nvar sum = repository.AsQueryable().Sum(u => u.Cost);\n\n// \u793a\u4f8b\u4e09\nvar sum = repository.DetachedEntities.Sum(u => u.Cost);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar sum = await repository.Entities.SumAsync(u => u.Cost);\n\n// \u793a\u4f8b\u4e8c\nvar sum = await repository.AsQueryable().SumAsync(u => u.Cost);\n\n// \u793a\u4f8b\u4e09\nvar sum = await repository.DetachedEntities.SumAsync(u => u.Cost);\n")),Object(s.b)("h3",{id:"91066-\u6c42\u5e73\u5747\u503c\u67e5\u8be2"},"9.10.6.6 \u6c42\u5e73\u5747\u503c\u67e5\u8be2"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar sum = repository.Entities.Average(u => u.Cost);\n\n// \u793a\u4f8b\u4e8c\nvar sum = repository.AsQueryable().Average(u => u.Cost);\n\n// \u793a\u4f8b\u4e09\nvar sum = repository.DetachedEntities.Average(u => u.Cost);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar sum = await repository.Entities.AverageAsync(u => u.Cost);\n\n// \u793a\u4f8b\u4e8c\nvar sum = await repository.AsQueryable().AverageAsync(u => u.Cost);\n\n// \u793a\u4f8b\u4e09\nvar sum = await repository.DetachedEntities.AverageAsync(u => u.Cost);\n")),Object(s.b)("h3",{id:"91067-\u65f6\u95f4\u67e5\u8be2"},"9.10.6.7 \u65f6\u95f4\u67e5\u8be2"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'var starDate = DateTime.Parse("2020-09-10");\nvar endDate = DateTime.Parse("2020-09-10");\nvar query = repository.Where(u => u.CreatedDt >= starDate && u.CreatedDt <= endDate);\n')),Object(s.b)("h3",{id:"91068-\u6a21\u7cca\u67e5\u8be2"},"9.10.6.8 \u6a21\u7cca\u67e5\u8be2"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// \u793a\u4f8b\u4e00\nrepository.Where(u => u.Name.StartWith("Fur"));\n\n// \u793a\u4f8b\u4e8c\n_testRepository.Where(u => u.Name.EndWith("Fur"));\n\n// \u793a\u4f8b\u4e09\n_testRepository.Where(u => u.Name.Contains("Fur"));\n')),Object(s.b)("h3",{id:"91069-case-when"},"9.10.6.9 ",Object(s.b)("inlineCode",{parentName:"h3"},"Case When")),Object(s.b)("p",null,"\u6570\u636e\u5e93\u4e2d\u7684 ",Object(s.b)("inlineCode",{parentName:"p"},"Case When")," \u5b9e\u9645\u4e0a\u5bf9\u5e94\u7684\u662f\u6211\u4eec\u7a0b\u5e8f\u4e2d\u7684 ",Object(s.b)("inlineCode",{parentName:"p"},"\u4e09\u5143\u8868\u8fbe\u5f0f")," \uff0c\u4e5f\u5c31\u662f\u4f7f\u7528 ",Object(s.b)("inlineCode",{parentName:"p"},"\u4e09\u5143\u8868\u8fbe\u5f0f")," \u5373\u53ef\u81ea\u52a8\u751f\u6210 ",Object(s.b)("inlineCode",{parentName:"p"},"Case When")," \u8bed\u53e5\u3002"),Object(s.b)("h2",{id:"9107-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.10.7 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(s.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(s.b)("h5",{parentName:"div"},Object(s.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(s.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(s.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(s.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(s.b)("a",Object(t.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0},142:function(e,n,r){"use strict";r.d(n,"a",(function(){return l})),r.d(n,"b",(function(){return b}));var t=r(0),a=r.n(t);function s(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function i(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,t)}return r}function o(e){for(var n=1;n=0||(a[r]=e[r]);return a}(e,n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var c=a.a.createContext({}),p=function(e){var n=a.a.useContext(c),r=n;return e&&(r="function"==typeof e?e(n):o(o({},n),e)),r},l=function(e){var n=p(e.components);return a.a.createElement(c.Provider,{value:n},e.children)},d={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},y=a.a.forwardRef((function(e,n){var r=e.components,t=e.mdxType,s=e.originalType,i=e.parentName,c=u(e,["components","mdxType","originalType","parentName"]),l=p(r),y=t,b=l["".concat(i,".").concat(y)]||l[y]||d[y]||s;return r?a.a.createElement(b,o(o({ref:n},c),{},{components:r})):a.a.createElement(b,o({ref:n},c))}));function b(e,n){var r=arguments,t=n&&n.mdxType;if("string"==typeof e||t){var s=r.length,i=new Array(s);i[0]=y;var o={};for(var u in n)hasOwnProperty.call(n,u)&&(o[u]=n[u]);o.originalType=e,o.mdxType="string"==typeof e?e:t,i[1]=o;for(var c=2;c=0||(a[r]=e[r]);return a}(e,n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var c=a.a.createContext({}),p=function(e){var n=a.a.useContext(c),r=n;return e&&(r="function"==typeof e?e(n):o(o({},n),e)),r},l=function(e){var n=p(e.components);return a.a.createElement(c.Provider,{value:n},e.children)},d={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},y=a.a.forwardRef((function(e,n){var r=e.components,t=e.mdxType,s=e.originalType,i=e.parentName,c=u(e,["components","mdxType","originalType","parentName"]),l=p(r),y=t,b=l["".concat(i,".").concat(y)]||l[y]||d[y]||s;return r?a.a.createElement(b,o(o({ref:n},c),{},{components:r})):a.a.createElement(b,o({ref:n},c))}));function b(e,n){var r=arguments,t=n&&n.mdxType;if("string"==typeof e||t){var s=r.length,i=new Array(s);i[0]=y;var o={};for(var u in n)hasOwnProperty.call(n,u)&&(o[u]=n[u]);o.originalType=e,o.mdxType="string"==typeof e?e:t,i[1]=o;for(var c=2;cCase When",id:"91069-case-when",children:[]}]},{value:"9.10.7 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9107-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],c={rightToc:u};function p(e){var n=e.components,r=Object(a.a)(e,["components"]);return Object(s.b)("wrapper",Object(t.a)({},c,r,{components:n,mdxType:"MDXLayout"}),Object(s.b)("h2",{id:"9101-\u6839\u636e\u4e3b\u952e\u67e5\u8be2\u4e00\u6761"},"9.10.1 \u6839\u636e\u4e3b\u952e\u67e5\u8be2\u4e00\u6761"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar person = repository.Find(1);\n\n// \u793a\u4f8b\u4e8c\nvar person = repository.FindOrDefault(1);\n\n// \u793a\u4f8b\u4e09\nvar person = repository.Entities.Find(1);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar person = await repository.FindAsync(1);\n\n// \u793a\u4f8b\u4e8c\nvar person = await repository.FindOrDefaultAsync(1);\n\n// \u793a\u4f8b\u4e09\nvar person = await repository.Entities.FindAsync(1);\n\n")),Object(s.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(s.b)("h5",{parentName:"div"},Object(s.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(s.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(s.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u63d0\u793a")),Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(s.b)("p",{parentName:"div"},"\u53ef\u4ee5\u652f\u6301\u591a\u4e2a\u952e\u67e5\u8be2\uff0c\u5982\u4e3b\u952e\u3001\u8054\u5408\u952e\u3002",Object(s.b)("inlineCode",{parentName:"p"},'repository.Find(1, "\u767e\u5c0f\u50e7")'),";"))),Object(s.b)("h2",{id:"9102-\u6839\u636e\u6761\u4ef6\u67e5\u8be2\u4e00\u6761"},"9.10.2 \u6839\u636e\u6761\u4ef6\u67e5\u8be2\u4e00\u6761"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar person = repository.Single(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e8c\nvar person = repository.SingleOrDefault(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e09\nvar person = repository.First(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u56db\nvar person = repository.FirstOrDefault(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e94\nvar person = repository.Last(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u516d\nvar person = repository.LastOrDefault(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e03\nvar person = repository.Entities.Single(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u516b\nvar person = repository.Entities.First(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e5d\nvar person = repository.Entities.FirstOrDefault(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u5341\nvar person = repository.Entities.Last(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u5341\u4e00\nvar person = repository.Entities.LastOrDefault(u => u.Name == "Fur");\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar person = await repository.SingleAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e8c\nvar person = await repository.SingleOrDefaultAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e09\nvar person = await repository.FirstAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u56db\nvar person = await repository.FirstOrDefaultAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e94\nvar person = await repository.LastAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u516d\nvar person = await repository.LastOrDefaultAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e03\nvar person = await repository.Entities.SingleAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u516b\nvar person = await repository.Entities.FirstAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u4e5d\nvar person = await repository.Entities.FirstOrDefaultAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u5341\nvar person = await repository.Entities.LastAsync(u => u.Name == "Fur");\n\n// \u793a\u4f8b\u5341\u4e00\nvar person = await repository.Entities.LastOrDefaultAsync(u => u.Name == "Fur");\n')),Object(s.b)("h2",{id:"9103-\u67e5\u8be2\u6240\u6709\u6570\u636e"},"9.10.3 \u67e5\u8be2\u6240\u6709\u6570\u636e"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = repository.Entities;\n\n// \u793a\u4f8b\u4e8c\nvar persons = repository.DetachedEntities;\n\n// \u793a\u4f8b\u4e09\nvar persons = repository.AsQueryable();\n\n// \u793a\u4f8b\u56db\nvar persons = repository.AsEnumerable();\n\n// \u793a\u4f8b\u4e94\nvar persons = await AsAsyncEnumerable();\n")),Object(s.b)("h2",{id:"9104-\u6839\u636e\u6761\u4ef6\u67e5\u8be2\u6240\u6709\u6570\u636e"},"9.10.4 \u6839\u636e\u6761\u4ef6\u67e5\u8be2\u6240\u6709\u6570\u636e"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// \u793a\u4f8b\u4e00\nvar persons = repository.Where(u => u.Id > 10);\n\n// \u793a\u4f8b\u4e8c\nvar persons = repository.Where(u => u.Id > 10 && u.Name.Equals("Fur"));\n\n// \u793a\u4f8b\u4e09\nvar persons = repository.Where(u => u.Id > 10).Where(u => u.Name.Equals("Fur"));\n\n// \u793a\u4f8b\u56db\nvar persons = repository.Where(!string.IsNullOrEmpty(name), u => u.Id > 10 && u.Name.Equals("Fur"));\n\n// \u793a\u4f8b\u4e94\nvar persons = repository.Where(!string.IsNullOrEmpty(name), u => u.Id > 10)\n .Where(age > 18, u => u.Name.Containes("\u767e\u5c0f\u50e7"))\n .Where(u => u.Age > 18);\n\n// \u793a\u4f8b\u516d\nvar persons = repository.Where(u => u.Name == "Fur",\n u => u.Name == "\u767e\u5c0f\u50e7",\n u => u.Name == "MonkSoul");\n\n// \u793a\u4f8b\u4e03\nvar persons = repository.Where(u => u.Id > 10).Where(u => u.Name.Equals("Fur"))\n .Where(age > 18, u => u.Name.Containes("\u767e\u5c0f\u50e7"))\n .Where(u => u.Name == "Fur",\n u => u.Name == "\u767e\u5c0f\u50e7",\n u => u.Name == "MonkSoul");\n\n// \u793a\u4f8b\u516b\nvar persons = repository.Where((age > 18, u => u.Name == "Fur"),\n (!string.IsNullOrEmpty(name), u => u.Id > 10));\n\n// \u793a\u4f8b\u4e5d\nvar persons = repository.Where(u => u.Id > 10).Where(u => u.Name.Equals("Fur"))\n .Where(age > 18, u => u.Name.Containes("\u767e\u5c0f\u50e7"))\n .Where(u => u.Name == "Fur",\n u => u.Name == "\u767e\u5c0f\u50e7",\n u => u.Name == "MonkSoul")\n .Where((age > 18, u => u.Name == "Fur"),\n (!string.IsNullOrEmpty(name), u => u.Id > 10));\n\n// \u793a\u4f8b\u5341\nvar persons = repository.Entities.Where(u => u.Id > 10)\n .Where(age > 18, u => u.Name.Containes("\u767e\u5c0f\u50e7"));\n\n// \u793a\u4f8b\u5341\u4e00\nvar persons = repository.DetachedEntities.Where(u => u.Id > 20);\n\n// \u793a\u4f8b\u5341\u4e8c\nvar persons = repository.AsQueryable(u => u.Id > 20).Where(u => u.Name == "Fur");\n')),Object(s.b)("h2",{id:"9105-\u5206\u9875\u67e5\u8be2"},"9.10.5 \u5206\u9875\u67e5\u8be2"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = repository.Where(u => u.Id > 10).ToPagedList();\n\n// \u793a\u4f8b\u4e8c\nvar persons = repository.Where(u => u.Id > 10).ToPagedList(1, 10);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = await repository.Where(u => u.Id > 10).ToPagedListAsync();\n\n// \u793a\u4f8b\u4e8c\nvar persons = await repository.Where(u => u.Id > 10).ToPagedListAsync(1, 10);\n")),Object(s.b)("h2",{id:"9106-\u5176\u4ed6\u67e5\u8be2"},"9.10.6 \u5176\u4ed6\u67e5\u8be2"),Object(s.b)("h3",{id:"91061-\u67e5\u770b\u8bb0\u5f55\u662f\u5426\u5b58\u5728"},"9.10.6.1 \u67e5\u770b\u8bb0\u5f55\u662f\u5426\u5b58\u5728"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar isExists = repository.Any();\n\n// \u793a\u4f8b\u4e8c\nvar isExists = repository.Any(u => u.Id > 10);\n\n// \u793a\u4f8b\u4e09\nvar isExists = repository.Entities.Any();\n\n// \u793a\u4f8b\u56db\nvar isExists = repository.DetachedEntities.Any(u => u.Id > 10);\n\n// \u793a\u4f8b\u4e94\nvar isExists = repository.Where(u => u.Id > 10).Any();\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar isExists = await repository.AnyAsync();\n\n// \u793a\u4f8b\u4e8c\nvar isExists = await repository.AnyAsync(u => u.Id > 10);\n\n// \u793a\u4f8b\u4e09\nvar isExists = await repository.Entities.AnyAsync();\n\n// \u793a\u4f8b\u56db\nvar isExists = await repository.DetachedEntities.AnyAsync(u => u.Id > 10);\n\n// \u793a\u4f8b\u4e94\nvar isExists = await repository.Where(u => u.Id > 10).AnyAsync();\n")),Object(s.b)("h3",{id:"91062-\u67e5\u8be2\u8bb0\u5f55\u6570"},"9.10.6.2 \u67e5\u8be2\u8bb0\u5f55\u6570"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar count = repository.Count();\n\n// \u793a\u4f8b\u4e8c\nvar count = repository.Count(u => u.Id > 10);\n\n// \u793a\u4f8b\u4e09\nvar count = repository.Entities.Count(u => u.Id > 10);\n\n// \u793a\u4f8b\u56db\nvar count = repository.Entities.DetachedEntities.Count();\n\n// \u793a\u4f8b\u4e94\nvar count = repository.Where(u => u.Id > 10).Count();\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar count = await repository.CountAsync();\n\n// \u793a\u4f8b\u4e8c\nvar count = await repository.CountAsync(u => u.Id > 10);\n\n// \u793a\u4f8b\u4e09\nvar count = await repository.Entities.CountAsync(u => u.Id > 10);\n\n// \u793a\u4f8b\u56db\nvar count = await repository.Entities.DetachedEntities.CountAsync();\n\n// \u793a\u4f8b\u4e94\nvar count = await repository.Where(u => u.Id > 10).CountAsync();\n")),Object(s.b)("h3",{id:"91063-\u67e5\u8be2\u6700\u5927\u503c"},"9.10.6.3 \u67e5\u8be2\u6700\u5927\u503c"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar entity = repository.Max();\n\n// \u793a\u4f8b\u4e8c\nvar value = repository.Max(u => u.Id);\n\n// \u793a\u4f8b\u4e09\nvar entity = repository.Entities.Max();\n\n// \u793a\u4f8b\u56db\nvar value = repository.Entities.DetachedEntities.Max(u => u.Age);\n\n// \u793a\u4f8b\u4e94\nvar value = repository.Where(u => u.Id > 10).Max(u => u.Age);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar entity = await repository.MaxAsync();\n\n// \u793a\u4f8b\u4e8c\nvar value = await repository.MaxAsync(u => u.Id);\n\n// \u793a\u4f8b\u4e09\nvar entity = await repository.Entities.MaxAsync();\n\n// \u793a\u4f8b\u56db\nvar value = await repository.Entities.DetachedEntities.MaxAsync(u => u.Age);\n\n// \u793a\u4f8b\u4e94\nvar value = await repository.Where(u => u.Id > 10).MaxAsync(u => u.Age);\n")),Object(s.b)("h3",{id:"91064-\u67e5\u8be2\u6700\u5c0f\u503c"},"9.10.6.4 \u67e5\u8be2\u6700\u5c0f\u503c"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar entity = repository.Min();\n\n// \u793a\u4f8b\u4e8c\nvar value = repository.Min(u => u.Id);\n\n// \u793a\u4f8b\u4e09\nvar entity = repository.Entities.Min();\n\n// \u793a\u4f8b\u56db\nvar value = repository.Entities.DetachedEntities.Min(u => u.Age);\n\n// \u793a\u4f8b\u4e94\nvar value = repository.Where(u => u.Id > 10).Min(u => u.Age);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar entity = await repository.MinAsync();\n\n// \u793a\u4f8b\u4e8c\nvar value = await repository.MinAsync(u => u.Id);\n\n// \u793a\u4f8b\u4e09\nvar entity = await repository.Entities.MinAsync();\n\n// \u793a\u4f8b\u56db\nvar value = await repository.Entities.DetachedEntities.MinAsync(u => u.Age);\n\n// \u793a\u4f8b\u4e94\nvar value = await repository.Where(u => u.Id > 10).MinAsync(u => u.Age);\n")),Object(s.b)("h3",{id:"91065-\u6c42\u548c\u67e5\u8be2"},"9.10.6.5 \u6c42\u548c\u67e5\u8be2"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar sum = repository.Entities.Sum(u => u.Cost);\n\n// \u793a\u4f8b\u4e8c\nvar sum = repository.AsQueryable().Sum(u => u.Cost);\n\n// \u793a\u4f8b\u4e09\nvar sum = repository.DetachedEntities.Sum(u => u.Cost);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar sum = await repository.Entities.SumAsync(u => u.Cost);\n\n// \u793a\u4f8b\u4e8c\nvar sum = await repository.AsQueryable().SumAsync(u => u.Cost);\n\n// \u793a\u4f8b\u4e09\nvar sum = await repository.DetachedEntities.SumAsync(u => u.Cost);\n")),Object(s.b)("h3",{id:"91066-\u6c42\u5e73\u5747\u503c\u67e5\u8be2"},"9.10.6.6 \u6c42\u5e73\u5747\u503c\u67e5\u8be2"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar sum = repository.Entities.Average(u => u.Cost);\n\n// \u793a\u4f8b\u4e8c\nvar sum = repository.AsQueryable().Average(u => u.Cost);\n\n// \u793a\u4f8b\u4e09\nvar sum = repository.DetachedEntities.Average(u => u.Cost);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar sum = await repository.Entities.AverageAsync(u => u.Cost);\n\n// \u793a\u4f8b\u4e8c\nvar sum = await repository.AsQueryable().AverageAsync(u => u.Cost);\n\n// \u793a\u4f8b\u4e09\nvar sum = await repository.DetachedEntities.AverageAsync(u => u.Cost);\n")),Object(s.b)("h3",{id:"91067-\u65f6\u95f4\u67e5\u8be2"},"9.10.6.7 \u65f6\u95f4\u67e5\u8be2"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'var starDate = DateTime.Parse("2020-09-10");\nvar endDate = DateTime.Parse("2020-09-10");\nvar query = repository.Where(u => u.CreatedDt >= starDate && u.CreatedDt <= endDate);\n')),Object(s.b)("h3",{id:"91068-\u6a21\u7cca\u67e5\u8be2"},"9.10.6.8 \u6a21\u7cca\u67e5\u8be2"),Object(s.b)("pre",null,Object(s.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// \u793a\u4f8b\u4e00\nrepository.Where(u => u.Name.StartWith("Fur"));\n\n// \u793a\u4f8b\u4e8c\n_testRepository.Where(u => u.Name.EndWith("Fur"));\n\n// \u793a\u4f8b\u4e09\n_testRepository.Where(u => u.Name.Contains("Fur"));\n')),Object(s.b)("h3",{id:"91069-case-when"},"9.10.6.9 ",Object(s.b)("inlineCode",{parentName:"h3"},"Case When")),Object(s.b)("p",null,"\u6570\u636e\u5e93\u4e2d\u7684 ",Object(s.b)("inlineCode",{parentName:"p"},"Case When")," \u5b9e\u9645\u4e0a\u5bf9\u5e94\u7684\u662f\u6211\u4eec\u7a0b\u5e8f\u4e2d\u7684 ",Object(s.b)("inlineCode",{parentName:"p"},"\u4e09\u5143\u8868\u8fbe\u5f0f")," \uff0c\u4e5f\u5c31\u662f\u4f7f\u7528 ",Object(s.b)("inlineCode",{parentName:"p"},"\u4e09\u5143\u8868\u8fbe\u5f0f")," \u5373\u53ef\u81ea\u52a8\u751f\u6210 ",Object(s.b)("inlineCode",{parentName:"p"},"Case When")," \u8bed\u53e5\u3002"),Object(s.b)("h2",{id:"9107-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.10.7 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(s.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(s.b)("h5",{parentName:"div"},Object(s.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(s.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(s.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(s.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(s.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(s.b)("a",Object(t.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/7d3779e7.20c05f2d.js b/handbook/build/7d3779e7.20c05f2d.js deleted file mode 100644 index 03c374f4609..00000000000 --- a/handbook/build/7d3779e7.20c05f2d.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[42],{142:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return m}));var r=n(0),a=n.n(r);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var l=a.a.createContext({}),b=function(e){var t=a.a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},u=function(e){var t=b(e.components);return a.a.createElement(l.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},s=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,o=e.originalType,c=e.parentName,l=p(e,["components","mdxType","originalType","parentName"]),u=b(n),s=r,m=u["".concat(c,".").concat(s)]||u[s]||d[s]||o;return n?a.a.createElement(m,i(i({ref:t},l),{},{components:n})):a.a.createElement(m,i({ref:t},l))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var o=n.length,c=new Array(o);c[0]=s;var i={};for(var p in t)hasOwnProperty.call(t,p)&&(i[p]=t[p]);i.originalType=e,i.mdxType="string"==typeof e?e:r,c[1]=i;for(var l=2;l=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var l=a.a.createContext({}),u=function(e){var t=a.a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},b=function(e){var t=u(e.components);return a.a.createElement(l.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},s=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,o=e.originalType,c=e.parentName,l=p(e,["components","mdxType","originalType","parentName"]),b=u(n),s=r,m=b["".concat(c,".").concat(s)]||b[s]||d[s]||o;return n?a.a.createElement(m,i(i({ref:t},l),{},{components:n})):a.a.createElement(m,i({ref:t},l))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var o=n.length,c=new Array(o);c[0]=s;var i={};for(var p in t)hasOwnProperty.call(t,p)&&(i[p]=t[p]);i.originalType=e,i.mdxType="string"==typeof e?e:r,c[1]=i;for(var l=2;lIEntity \u793a\u8303\uff1a",id:"9322-ientity-\u793a\u8303\uff1a",children:[]},{value:"9.3.2.2 EntityBase \u793a\u8303\uff1a",id:"9322-entitybase-\u793a\u8303\uff1a",children:[]},{value:"9.3.2.3 Entity \u793a\u8303\uff1a",id:"9323-entity-\u793a\u8303\uff1a",children:[]},{value:"9.3.2.4 EntityNotKey \u793a\u8303\uff1a",id:"9324-entitynotkey-\u793a\u8303\uff1a",children:[]}]},{value:"9.3.3 \u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e",id:"933-\u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e",children:[{value:"9.3.3.1 \u5728\u6570\u636e\u5e93\u5b9e\u4f53\u4e2d\u914d\u7f6e",id:"9331-\u5728\u6570\u636e\u5e93\u5b9e\u4f53\u4e2d\u914d\u7f6e",children:[]},{value:"9.3.3.2 \u5728\u4efb\u4f55\u5b9e\u4f8b\u7c7b\u4e2d\u914d\u7f6e",id:"9332-\u5728\u4efb\u4f55\u5b9e\u4f8b\u7c7b\u4e2d\u914d\u7f6e",children:[]}]},{value:"9.3.4 \u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e\u8bf4\u660e",id:"934-\u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e\u8bf4\u660e",children:[]},{value:"9.3.5 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"935-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],o={rightToc:l};function p(e){var n=e.components,t=Object(i.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},o,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"931-\u6570\u636e\u5e93\u5b9e\u4f53"},"9.3.1 \u6570\u636e\u5e93\u5b9e\u4f53"),Object(r.b)("p",null,"\u5728\u9762\u5411\u5bf9\u8c61\u5f00\u53d1\u601d\u60f3\u4e2d\uff0c\u6700\u91cd\u8981\u5c24\u4e3a",Object(r.b)("strong",{parentName:"p"},"\u5bf9\u8c61"),"\u4e8c\u5b57\uff0c\u5728 .NET \u5f00\u53d1\u8fc7\u53bb\uff0c\u64cd\u4f5c\u6570\u636e\u5e93\u5f80\u5f80\u91c7\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"DataTable")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"DataSet")," \u6765\u63a5\u6536\u6570\u636e\u5e93\u8fd4\u56de\u7ed3\u679c\u96c6\uff0c\u800c\u64cd\u4f5c\u6570\u636e\u5e93\u4e5f\u79bb\u4e0d\u5f00\u624b\u5199 ",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u8bed\u53e5\u3002"),Object(r.b)("p",null,"\u5728\u8fc7\u53bb\u9762\u5411\u8fc7\u7a0b\u548c\u5e94\u7528\u4e0d\u53d1\u8fbe\u7684\u65f6\u4ee3\uff0c\u8fd9\u4e9b\u64cd\u4f5c\u786e\u5b9e\u597d\u4f7f\u3002\u7136\u540e\u968f\u7740\u4e2d\u56fd\u4e92\u8054\u7f51\u7f51\u6c11\u7684\u6fc0\u589e\uff0c\u7535\u5b50\u5316\u65f6\u4ee3\u7684\u5230\u6765\uff0c\u5404\u884c\u5404\u4e1a\u5bf9\u5e94\u7528\u9700\u6c42\u4e5f\u8fbe\u5230\u4e86\u524d\u6240\u672a\u6709\u7684\u91cf\u7ea7\u3002"),Object(r.b)("p",null,"\u6240\u4ee5\uff0c\u5728\u8fc7\u53bb\u624b\u5199 ",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u7684\u65f6\u4ee3\u5404\u79cd\u95ee\u9898\u663e\u9732\u65e0\u7591\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u7a0b\u5e8f\u5458\u80fd\u529b\u53c2\u5dee\u4e0d\u9f50\uff0c\u5199\u51fa\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"sql")," \u6027\u80fd\u81ea\u7136\u4e5f\u5929\u5dee\u5730\u522b"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"sql")," \u5c5e\u4e8e\u5b57\u7b26\u4e32\u786c\u7f16\u7a0b\uff0c\u540e\u671f\u7ef4\u62a4\u96be\u4e0a\u52a0\u96be"),Object(r.b)("li",{parentName:"ul"},"\u8bb8\u591a\u5355\u8868\u751a\u81f3\u591a\u8868\u7ed3\u6784\u4e00\u81f4\uff0c\u51fa\u73b0\u5927\u91cf\u91cd\u590d ",Object(r.b)("inlineCode",{parentName:"li"},"sql")," \u4ee3\u7801"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"sql")," \u672c\u8eab\u5728\u4e0d\u540c\u7684\u6570\u636e\u5e93\u63d0\u4f9b\u5668\u4e2d\u5199\u6cd5\u6709\u5dee\uff0c\u540e\u7eed\u8fc1\u79fb\u5934\u75db\u4e0d\u5df2")),Object(r.b)("p",null,"\u5f53\u7136\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u662f\u65f6\u4ee3\u7684\u4ea7\u7269\uff0c\u6211\u4eec\u4e5f\u79bb\u4e0d\u5f00 ",Object(r.b)("inlineCode",{parentName:"p"},"sql"),"\uff0c\u4f46\u5bf9\u4e8e\u5927\u591a\u6570\u7a0b\u5e8f\u5458\u548c\u9879\u76ee\u6765\u8bf4\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u672a\u5fc5\u80fd\u591f\u5e26\u7ed9\u4ed6\u4eec\u591a\u5927\u7684\u6548\u76ca\u3002"),Object(r.b)("p",null,"\u6240\u4ee5\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"ORM")," \u5c31\u8bde\u751f\u4e86\uff0c\u6240\u8c13\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"ORM")," \u5c31\u662f\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\uff0c\u82f1\u6587\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"Object Relational Mapping"),"\uff0c\u7b80\u5355\u70b9\u8bf4\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"ORM")," \u6839\u636e\u7279\u6709\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"POCO \u8d2b\u8840\u6a21\u578b")," \u89c4\u5219\u751f\u6210 ",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u8bed\u53e5\u3002\u5927\u5927\u907f\u514d\u4e86\u91cd\u590d ",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u80fd\u529b\u53c2\u5dee\u4e0d\u9f50\u7b49\u95ee\u9898\u3002\uff08\u5f53\u7136 ",Object(r.b)("inlineCode",{parentName:"p"},"ORM")," \u4f5c\u8005 ",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u80fd\u529b\u4e5f\u4f1a\u5f71\u54cd\u6700\u7ec8\u6027\u80fd\uff09"),Object(r.b)("p",null,"\u4e0a\u9762\u6240\u8bf4\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"POCO")," \u8d2b\u8840\u6a21\u578b\u6b63\u662f\u6211\u4eec\u672c\u7ae0\u8282\u7684 ",Object(r.b)("strong",{parentName:"p"},"\u6570\u636e\u5e93\u5b9e\u4f53"),"\u3002"),Object(r.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u6570\u636e\u5e93\u5b9e\u4f53\u5c31\u662f\u6570\u636e\u5e93\u8868\u7684\u7c7b\u8868\u73b0\uff0c\u901a\u8fc7\u4e00\u5b9a\u7684\u89c4\u5219\u4f7f\u8fd9\u4e2a\u7c7b\u80fd\u591f\u4e00\u4e00\u5bf9\u5e94\u8868\u7ed3\u6784\u3002\u901a\u5e38\u8fd9\u6837\u7684\u7c7b\u4e5f\u79f0\u4e3a\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"POCO")," \u8d2b\u8840\u6a21\u578b\uff0c\u4e5f\u5c31\u662f\u53ea\u6709\u5b9a\u4e49\uff0c\u6ca1\u6709\u884c\u4e3a\u3002"),Object(r.b)("h2",{id:"932-\u5982\u4f55\u5b9a\u4e49\u5b9e\u4f53"},"9.3.2 \u5982\u4f55\u5b9a\u4e49\u5b9e\u4f53"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u591a\u79cd\u5b9a\u4e49\u5b9e\u4f53\u7684\u63a5\u53e3\u4f9d\u8d56\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"IEntity"),"\uff1a\u5b9e\u4f53\u57fa\u63a5\u53e3\uff0c\u662f\u6240\u6709\u5b9e\u4f53\u7684\u57fa\u63a5\u53e3"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"IEntityNotKey"),"\uff1a\u65e0\u952e\u5b9e\u4f53\u63a5\u53e3\uff0c\u4e5f\u5c31\u662f\u89c6\u56fe\u3001\u5b58\u50a8\u8fc7\u7a0b\u3001\u51fd\u6570\u4f9d\u8d56\u63a5\u53e3"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"EntityBase"),"\uff1a\u5b9e\u4f53\u57fa\u62bd\u8c61\u7c7b\uff0c\u5185\u7f6e\u4e86 ",Object(r.b)("inlineCode",{parentName:"li"},"Id"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"TenantId")," \u5b57\u6bb5"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Entity"),"\uff1a\u5b9e\u4f53\u901a\u7528\u62bd\u8c61\u7c7b\uff0c\u7ee7\u627f\u81ea ",Object(r.b)("inlineCode",{parentName:"li"},"EntityBase"),"\uff0c\u540c\u65f6\u5185\u7f6e ",Object(r.b)("inlineCode",{parentName:"li"},"CreatedTime"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"UpdatedTime"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"IsDeleted")," \u5b57\u6bb5"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"EntityNotKey"),"\uff1a\u65e0\u952e\u5b9e\u4f53\u62bd\u8c61\u7c7b\uff0c\u89c6\u56fe\u3001\u5b58\u50a8\u8fc7\u7a0b\u3001\u51fd\u6570\u4f9d\u8d56\u62bd\u8c61\u7c7b")),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u5b9e\u4f53\u5b9a\u4e49\u4f4d\u7f6e")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u6709\u7ea6\u5b9a\uff0c\u5b9e\u4f53\u7edf\u4e00\u5b9a\u4e49\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur.Core")," \u5c42\u3002"))),Object(r.b)("h3",{id:"9321-\u5b9e\u4f53\u7ee7\u627f\u9009\u7528\u539f\u5219"},"9.3.2.1 \u5b9e\u4f53\u7ee7\u627f\u9009\u7528\u539f\u5219"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u5982\u679c\u4f60\u4e0d\u9700\u8981 ",Object(r.b)("inlineCode",{parentName:"li"},"Fur")," \u4e3a\u5b9e\u4f53\u6dfb\u52a0\u4efb\u4f55\u5185\u7f6e\u7279\u6027\uff0c\u9009\u7528 ",Object(r.b)("inlineCode",{parentName:"li"},"IEntity"),"\uff0c\u65e0\u952e\u5b9e\u4f53\u9009\u7528 ",Object(r.b)("inlineCode",{parentName:"li"},"IEntityNotKey")),Object(r.b)("li",{parentName:"ul"},"\u5982\u679c\u4f60\u53ea\u9700\u8981 ",Object(r.b)("inlineCode",{parentName:"li"},"Id")," \u5c5e\u6027\uff0c\u9009\u7528 ",Object(r.b)("inlineCode",{parentName:"li"},"EntityBase")),Object(r.b)("li",{parentName:"ul"},"\u5982\u679c\u4f60\u9700\u8981 ",Object(r.b)("inlineCode",{parentName:"li"},"Fur")," \u4e3a\u4f60\u81ea\u52a8\u6dfb\u52a0\u5e38\u7528\u5b57\u6bb5\uff0c\u5219\u9009\u7528 ",Object(r.b)("inlineCode",{parentName:"li"},"Entity")),Object(r.b)("li",{parentName:"ul"},"\u5982\u679c\u4f60\u9700\u8981\u89c6\u56fe\u3001\u5b58\u50a8\u8fc7\u7a0b\u3001\u51fd\u6570\u53ef\u4ee5\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"li"},"DbSet")," \u64cd\u4f5c\uff0c\u5219\u7ee7\u627f ",Object(r.b)("inlineCode",{parentName:"li"},"EntityNotKey"))),Object(r.b)("h3",{id:"9322-ientity-\u793a\u8303\uff1a"},"9.3.2.2 ",Object(r.b)("inlineCode",{parentName:"h3"},"IEntity")," \u793a\u8303\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5}","{1,5}":!0}),"using Fur.DatabaseAccessor;\n\nnamespace Fur.Core\n{\n public class User : IEntity\n {\n /// \n /// \u624b\u5de5\u5b9a\u4e49 Id\n /// \n public int Id { get; set; }\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n }\n}\n")),Object(r.b)("h3",{id:"9322-entitybase-\u793a\u8303\uff1a"},"9.3.2.2 ",Object(r.b)("inlineCode",{parentName:"h3"},"EntityBase")," \u793a\u8303\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5}","{1,5}":!0}),"using Fur.DatabaseAccessor;\n\nnamespace Fur.Core\n{\n public class User : EntityBase\n {\n // \u65e0\u9700\u5b9a\u4e49 Id \u5c5e\u6027\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n }\n}\n")),Object(r.b)("h3",{id:"9323-entity-\u793a\u8303\uff1a"},"9.3.2.3 ",Object(r.b)("inlineCode",{parentName:"h3"},"Entity")," \u793a\u8303\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5}","{1,5}":!0}),"using Fur.DatabaseAccessor;\n\nnamespace Fur.Core\n{\n public class User : Entity\n {\n // \u65e0\u9700\u5b9a\u4e49 Id \u5c5e\u6027\n // \u5e76\u81ea\u52a8\u6dfb\u52a0 CreatedTime\uff0cUpdateTime\uff0cIsDeleted \u5c5e\u6027\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n }\n}\n")),Object(r.b)("h3",{id:"9324-entitynotkey-\u793a\u8303\uff1a"},"9.3.2.4 ",Object(r.b)("inlineCode",{parentName:"h3"},"EntityNotKey")," \u793a\u8303\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,7-9}","{1,5,7-9}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Core\n{\n public class UserView : EntityNotKey\n {\n public UserView() : base("\u89c6\u56fe\u540d\u79f0")\n {\n }\n\n /// \n /// Id\n /// \n public int Id { get; set; }\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n }\n}\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u6570\u636e\u5e93\u5b9e\u4f53\u5fc5\u987b\u76f4\u63a5\u6216\u95f4\u63a5\u7ee7\u627f ",Object(r.b)("inlineCode",{parentName:"p"},"IEntity")," \u624d\u80fd\u8fdb\u884c\u4ed3\u50a8\u7b49\u64cd\u4f5c\u3002"))),Object(r.b)("h2",{id:"933-\u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e"},"9.3.3 \u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e"),Object(r.b)("p",null,"\u5728\u8fc7\u53bb\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"EF Core")," \u9879\u76ee\u5f00\u53d1\u4e2d\uff0c\u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e\u9700\u8981\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"DbContext")," \u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"OnModelCreating")," \u4e2d\u914d\u7f6e\u3002",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u4e3a\u4e86\u7b80\u5316\u914d\u7f6e\u548c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\uff0c\u62bd\u8c61\u51fa\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"IEntityTypeBuilder")," \u63a5\u53e3\u3002"),Object(r.b)("p",null,"\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"IEntityTypeBuilder")," \u63a5\u53e3\uff0c\u6211\u4eec\u65e0\u9700\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"DbContext")," \u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"OnModelCreating")," \u4e2d\u914d\u7f6e\uff0c\u53ef\u5728\u4efb\u610f\u5730\u65b9\u914d\u7f6e\u3002"),Object(r.b)("h3",{id:"9331-\u5728\u6570\u636e\u5e93\u5b9e\u4f53\u4e2d\u914d\u7f6e"},"9.3.3.1 \u5728\u6570\u636e\u5e93\u5b9e\u4f53\u4e2d\u914d\u7f6e"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,20-25}","{1,5,20-25}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\n\nnamespace Fur.Core\n{\n public class User : Entity, IEntityTypeBuilder\n {\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n\n // \u914d\u7f6e\u6570\u636e\u5e93\u5b9e\u4f53\n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasKey(u => u.Id);\n entityBuilder.HasIndex(u => u.Name);\n }\n }\n}\n")),Object(r.b)("h3",{id:"9332-\u5728\u4efb\u4f55\u5b9e\u4f8b\u7c7b\u4e2d\u914d\u7f6e"},"9.3.3.2 \u5728\u4efb\u4f55\u5b9e\u4f8b\u7c7b\u4e2d\u914d\u7f6e"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,8,10-14}","{1,8,10-14}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\n\nnamespace Fur.Core\n{\n public class SomeClass : IEntityTypeBuilder\n {\n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasKey(u => u.Id);\n entityBuilder.HasIndex(u => u.Name);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\uff0c\u4e0a\u9762\u4f8b\u5b50\uff0c\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"SomeClass")," \u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"User")," \u6570\u636e\u5e93\u5b9e\u4f53\u3002"),Object(r.b)("h2",{id:"934-\u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e\u8bf4\u660e"},"9.3.4 \u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e\u8bf4\u660e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4f1a\u81ea\u52a8\u626b\u63cf\u6240\u6709\u7ee7\u627f ",Object(r.b)("inlineCode",{parentName:"p"},"IEntity")," \u63a5\u53e3\u7684\u7c7b\u8fdb\u884c ",Object(r.b)("inlineCode",{parentName:"p"},"DbSet")," \u6ce8\u518c\uff0c\u4e5f\u5c31\u662f\u5b9e\u73b0\u81ea\u52a8\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"DbContext")," \u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"OnModelCreating"),"\u3002"),Object(r.b)("p",null,"\u5982\u679c\u9700\u8981\u8df3\u8fc7\u81ea\u52a8\u6ce8\u518c\uff0c\u53ea\u9700\u8981\u8d34 ",Object(r.b)("inlineCode",{parentName:"p"},"[NonAutomatic]")," \u6216 ",Object(r.b)("inlineCode",{parentName:"p"},"[SkipScan]")," \u7279\u6027\u5373\u53ef\u3002\u4e00\u65e6\u8d34\u4e86\u6b21\u7279\u6027\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u624b\u52a8\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"DbContext")," \u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"OnModelCreating")),Object(r.b)("h2",{id:"935-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.3.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return s})),t.d(n,"b",(function(){return u}));var a=t(0),i=t.n(a);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function b(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function c(e){for(var n=1;n=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var o=i.a.createContext({}),p=function(e){var n=i.a.useContext(o),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},s=function(e){var n=p(e.components);return i.a.createElement(o.Provider,{value:n},e.children)},d={inlineCode:"code",wrapper:function(e){var n=e.children;return i.a.createElement(i.a.Fragment,{},n)}},m=i.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,r=e.originalType,b=e.parentName,o=l(e,["components","mdxType","originalType","parentName"]),s=p(t),m=a,u=s["".concat(b,".").concat(m)]||s[m]||d[m]||r;return t?i.a.createElement(u,c(c({ref:n},o),{},{components:t})):i.a.createElement(u,c({ref:n},o))}));function u(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var r=t.length,b=new Array(r);b[0]=m;var c={};for(var l in n)hasOwnProperty.call(n,l)&&(c[l]=n[l]);c.originalType=e,c.mdxType="string"==typeof e?e:a,b[1]=c;for(var o=2;o=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var o=i.a.createContext({}),p=function(e){var n=i.a.useContext(o),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},s=function(e){var n=p(e.components);return i.a.createElement(o.Provider,{value:n},e.children)},d={inlineCode:"code",wrapper:function(e){var n=e.children;return i.a.createElement(i.a.Fragment,{},n)}},m=i.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,r=e.originalType,b=e.parentName,o=l(e,["components","mdxType","originalType","parentName"]),s=p(t),m=a,u=s["".concat(b,".").concat(m)]||s[m]||d[m]||r;return t?i.a.createElement(u,c(c({ref:n},o),{},{components:t})):i.a.createElement(u,c({ref:n},o))}));function u(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var r=t.length,b=new Array(r);b[0]=m;var c={};for(var l in n)hasOwnProperty.call(n,l)&&(c[l]=n[l]);c.originalType=e,c.mdxType="string"==typeof e?e:a,b[1]=c;for(var o=2;oIEntity \u793a\u8303\uff1a",id:"9322-ientity-\u793a\u8303\uff1a",children:[]},{value:"9.3.2.2 EntityBase \u793a\u8303\uff1a",id:"9322-entitybase-\u793a\u8303\uff1a",children:[]},{value:"9.3.2.3 Entity \u793a\u8303\uff1a",id:"9323-entity-\u793a\u8303\uff1a",children:[]},{value:"9.3.2.4 EntityNotKey \u793a\u8303\uff1a",id:"9324-entitynotkey-\u793a\u8303\uff1a",children:[]}]},{value:"9.3.3 \u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e",id:"933-\u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e",children:[{value:"9.3.3.1 \u5728\u6570\u636e\u5e93\u5b9e\u4f53\u4e2d\u914d\u7f6e",id:"9331-\u5728\u6570\u636e\u5e93\u5b9e\u4f53\u4e2d\u914d\u7f6e",children:[]},{value:"9.3.3.2 \u5728\u4efb\u4f55\u5b9e\u4f8b\u7c7b\u4e2d\u914d\u7f6e",id:"9332-\u5728\u4efb\u4f55\u5b9e\u4f8b\u7c7b\u4e2d\u914d\u7f6e",children:[]}]},{value:"9.3.4 \u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e\u8bf4\u660e",id:"934-\u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e\u8bf4\u660e",children:[]},{value:"9.3.5 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"935-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],o={rightToc:l};function p(e){var n=e.components,t=Object(i.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},o,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"931-\u6570\u636e\u5e93\u5b9e\u4f53"},"9.3.1 \u6570\u636e\u5e93\u5b9e\u4f53"),Object(r.b)("p",null,"\u5728\u9762\u5411\u5bf9\u8c61\u5f00\u53d1\u601d\u60f3\u4e2d\uff0c\u6700\u91cd\u8981\u5c24\u4e3a",Object(r.b)("strong",{parentName:"p"},"\u5bf9\u8c61"),"\u4e8c\u5b57\uff0c\u5728 .NET \u5f00\u53d1\u8fc7\u53bb\uff0c\u64cd\u4f5c\u6570\u636e\u5e93\u5f80\u5f80\u91c7\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"DataTable")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"DataSet")," \u6765\u63a5\u6536\u6570\u636e\u5e93\u8fd4\u56de\u7ed3\u679c\u96c6\uff0c\u800c\u64cd\u4f5c\u6570\u636e\u5e93\u4e5f\u79bb\u4e0d\u5f00\u624b\u5199 ",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u8bed\u53e5\u3002"),Object(r.b)("p",null,"\u5728\u8fc7\u53bb\u9762\u5411\u8fc7\u7a0b\u548c\u5e94\u7528\u4e0d\u53d1\u8fbe\u7684\u65f6\u4ee3\uff0c\u8fd9\u4e9b\u64cd\u4f5c\u786e\u5b9e\u597d\u4f7f\u3002\u7136\u540e\u968f\u7740\u4e2d\u56fd\u4e92\u8054\u7f51\u7f51\u6c11\u7684\u6fc0\u589e\uff0c\u7535\u5b50\u5316\u65f6\u4ee3\u7684\u5230\u6765\uff0c\u5404\u884c\u5404\u4e1a\u5bf9\u5e94\u7528\u9700\u6c42\u4e5f\u8fbe\u5230\u4e86\u524d\u6240\u672a\u6709\u7684\u91cf\u7ea7\u3002"),Object(r.b)("p",null,"\u6240\u4ee5\uff0c\u5728\u8fc7\u53bb\u624b\u5199 ",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u7684\u65f6\u4ee3\u5404\u79cd\u95ee\u9898\u663e\u9732\u65e0\u7591\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u7a0b\u5e8f\u5458\u80fd\u529b\u53c2\u5dee\u4e0d\u9f50\uff0c\u5199\u51fa\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"sql")," \u6027\u80fd\u81ea\u7136\u4e5f\u5929\u5dee\u5730\u522b"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"sql")," \u5c5e\u4e8e\u5b57\u7b26\u4e32\u786c\u7f16\u7a0b\uff0c\u540e\u671f\u7ef4\u62a4\u96be\u4e0a\u52a0\u96be"),Object(r.b)("li",{parentName:"ul"},"\u8bb8\u591a\u5355\u8868\u751a\u81f3\u591a\u8868\u7ed3\u6784\u4e00\u81f4\uff0c\u51fa\u73b0\u5927\u91cf\u91cd\u590d ",Object(r.b)("inlineCode",{parentName:"li"},"sql")," \u4ee3\u7801"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"sql")," \u672c\u8eab\u5728\u4e0d\u540c\u7684\u6570\u636e\u5e93\u63d0\u4f9b\u5668\u4e2d\u5199\u6cd5\u6709\u5dee\uff0c\u540e\u7eed\u8fc1\u79fb\u5934\u75db\u4e0d\u5df2")),Object(r.b)("p",null,"\u5f53\u7136\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u662f\u65f6\u4ee3\u7684\u4ea7\u7269\uff0c\u6211\u4eec\u4e5f\u79bb\u4e0d\u5f00 ",Object(r.b)("inlineCode",{parentName:"p"},"sql"),"\uff0c\u4f46\u5bf9\u4e8e\u5927\u591a\u6570\u7a0b\u5e8f\u5458\u548c\u9879\u76ee\u6765\u8bf4\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u672a\u5fc5\u80fd\u591f\u5e26\u7ed9\u4ed6\u4eec\u591a\u5927\u7684\u6548\u76ca\u3002"),Object(r.b)("p",null,"\u6240\u4ee5\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"ORM")," \u5c31\u8bde\u751f\u4e86\uff0c\u6240\u8c13\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"ORM")," \u5c31\u662f\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\uff0c\u82f1\u6587\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"Object Relational Mapping"),"\uff0c\u7b80\u5355\u70b9\u8bf4\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"ORM")," \u6839\u636e\u7279\u6709\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"POCO \u8d2b\u8840\u6a21\u578b")," \u89c4\u5219\u751f\u6210 ",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u8bed\u53e5\u3002\u5927\u5927\u907f\u514d\u4e86\u91cd\u590d ",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u80fd\u529b\u53c2\u5dee\u4e0d\u9f50\u7b49\u95ee\u9898\u3002\uff08\u5f53\u7136 ",Object(r.b)("inlineCode",{parentName:"p"},"ORM")," \u4f5c\u8005 ",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u80fd\u529b\u4e5f\u4f1a\u5f71\u54cd\u6700\u7ec8\u6027\u80fd\uff09"),Object(r.b)("p",null,"\u4e0a\u9762\u6240\u8bf4\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"POCO")," \u8d2b\u8840\u6a21\u578b\u6b63\u662f\u6211\u4eec\u672c\u7ae0\u8282\u7684 ",Object(r.b)("strong",{parentName:"p"},"\u6570\u636e\u5e93\u5b9e\u4f53"),"\u3002"),Object(r.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u6570\u636e\u5e93\u5b9e\u4f53\u5c31\u662f\u6570\u636e\u5e93\u8868\u7684\u7c7b\u8868\u73b0\uff0c\u901a\u8fc7\u4e00\u5b9a\u7684\u89c4\u5219\u4f7f\u8fd9\u4e2a\u7c7b\u80fd\u591f\u4e00\u4e00\u5bf9\u5e94\u8868\u7ed3\u6784\u3002\u901a\u5e38\u8fd9\u6837\u7684\u7c7b\u4e5f\u79f0\u4e3a\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"POCO")," \u8d2b\u8840\u6a21\u578b\uff0c\u4e5f\u5c31\u662f\u53ea\u6709\u5b9a\u4e49\uff0c\u6ca1\u6709\u884c\u4e3a\u3002"),Object(r.b)("h2",{id:"932-\u5982\u4f55\u5b9a\u4e49\u5b9e\u4f53"},"9.3.2 \u5982\u4f55\u5b9a\u4e49\u5b9e\u4f53"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u591a\u79cd\u5b9a\u4e49\u5b9e\u4f53\u7684\u63a5\u53e3\u4f9d\u8d56\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"IEntity"),"\uff1a\u5b9e\u4f53\u57fa\u63a5\u53e3\uff0c\u662f\u6240\u6709\u5b9e\u4f53\u7684\u57fa\u63a5\u53e3"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"IEntityNotKey"),"\uff1a\u65e0\u952e\u5b9e\u4f53\u63a5\u53e3\uff0c\u4e5f\u5c31\u662f\u89c6\u56fe\u3001\u5b58\u50a8\u8fc7\u7a0b\u3001\u51fd\u6570\u4f9d\u8d56\u63a5\u53e3"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"EntityBase"),"\uff1a\u5b9e\u4f53\u57fa\u62bd\u8c61\u7c7b\uff0c\u5185\u7f6e\u4e86 ",Object(r.b)("inlineCode",{parentName:"li"},"Id"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"TenantId")," \u5b57\u6bb5"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Entity"),"\uff1a\u5b9e\u4f53\u901a\u7528\u62bd\u8c61\u7c7b\uff0c\u7ee7\u627f\u81ea ",Object(r.b)("inlineCode",{parentName:"li"},"EntityBase"),"\uff0c\u540c\u65f6\u5185\u7f6e ",Object(r.b)("inlineCode",{parentName:"li"},"CreatedTime"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"UpdatedTime"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"IsDeleted")," \u5b57\u6bb5"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"EntityNotKey"),"\uff1a\u65e0\u952e\u5b9e\u4f53\u62bd\u8c61\u7c7b\uff0c\u89c6\u56fe\u3001\u5b58\u50a8\u8fc7\u7a0b\u3001\u51fd\u6570\u4f9d\u8d56\u62bd\u8c61\u7c7b")),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u5b9e\u4f53\u5b9a\u4e49\u4f4d\u7f6e")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u6709\u7ea6\u5b9a\uff0c\u5b9e\u4f53\u7edf\u4e00\u5b9a\u4e49\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur.Core")," \u5c42\u3002"))),Object(r.b)("h3",{id:"9321-\u5b9e\u4f53\u7ee7\u627f\u9009\u7528\u539f\u5219"},"9.3.2.1 \u5b9e\u4f53\u7ee7\u627f\u9009\u7528\u539f\u5219"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u5982\u679c\u4f60\u4e0d\u9700\u8981 ",Object(r.b)("inlineCode",{parentName:"li"},"Fur")," \u4e3a\u5b9e\u4f53\u6dfb\u52a0\u4efb\u4f55\u5185\u7f6e\u7279\u6027\uff0c\u9009\u7528 ",Object(r.b)("inlineCode",{parentName:"li"},"IEntity"),"\uff0c\u65e0\u952e\u5b9e\u4f53\u9009\u7528 ",Object(r.b)("inlineCode",{parentName:"li"},"IEntityNotKey")),Object(r.b)("li",{parentName:"ul"},"\u5982\u679c\u4f60\u53ea\u9700\u8981 ",Object(r.b)("inlineCode",{parentName:"li"},"Id")," \u5c5e\u6027\uff0c\u9009\u7528 ",Object(r.b)("inlineCode",{parentName:"li"},"EntityBase")),Object(r.b)("li",{parentName:"ul"},"\u5982\u679c\u4f60\u9700\u8981 ",Object(r.b)("inlineCode",{parentName:"li"},"Fur")," \u4e3a\u4f60\u81ea\u52a8\u6dfb\u52a0\u5e38\u7528\u5b57\u6bb5\uff0c\u5219\u9009\u7528 ",Object(r.b)("inlineCode",{parentName:"li"},"Entity")),Object(r.b)("li",{parentName:"ul"},"\u5982\u679c\u4f60\u9700\u8981\u89c6\u56fe\u3001\u5b58\u50a8\u8fc7\u7a0b\u3001\u51fd\u6570\u53ef\u4ee5\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"li"},"DbSet")," \u64cd\u4f5c\uff0c\u5219\u7ee7\u627f ",Object(r.b)("inlineCode",{parentName:"li"},"EntityNotKey"))),Object(r.b)("h3",{id:"9322-ientity-\u793a\u8303\uff1a"},"9.3.2.2 ",Object(r.b)("inlineCode",{parentName:"h3"},"IEntity")," \u793a\u8303\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5}","{1,5}":!0}),"using Fur.DatabaseAccessor;\n\nnamespace Fur.Core\n{\n public class User : IEntity\n {\n /// \n /// \u624b\u5de5\u5b9a\u4e49 Id\n /// \n public int Id { get; set; }\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n }\n}\n")),Object(r.b)("h3",{id:"9322-entitybase-\u793a\u8303\uff1a"},"9.3.2.2 ",Object(r.b)("inlineCode",{parentName:"h3"},"EntityBase")," \u793a\u8303\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5}","{1,5}":!0}),"using Fur.DatabaseAccessor;\n\nnamespace Fur.Core\n{\n public class User : EntityBase\n {\n // \u65e0\u9700\u5b9a\u4e49 Id \u5c5e\u6027\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n }\n}\n")),Object(r.b)("h3",{id:"9323-entity-\u793a\u8303\uff1a"},"9.3.2.3 ",Object(r.b)("inlineCode",{parentName:"h3"},"Entity")," \u793a\u8303\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5}","{1,5}":!0}),"using Fur.DatabaseAccessor;\n\nnamespace Fur.Core\n{\n public class User : Entity\n {\n // \u65e0\u9700\u5b9a\u4e49 Id \u5c5e\u6027\n // \u5e76\u81ea\u52a8\u6dfb\u52a0 CreatedTime\uff0cUpdateTime\uff0cIsDeleted \u5c5e\u6027\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n }\n}\n")),Object(r.b)("h3",{id:"9324-entitynotkey-\u793a\u8303\uff1a"},"9.3.2.4 ",Object(r.b)("inlineCode",{parentName:"h3"},"EntityNotKey")," \u793a\u8303\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,7-9}","{1,5,7-9}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Core\n{\n public class UserView : EntityNotKey\n {\n public UserView() : base("\u89c6\u56fe\u540d\u79f0")\n {\n }\n\n /// \n /// Id\n /// \n public int Id { get; set; }\n\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n }\n}\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u6ce8\u610f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u6570\u636e\u5e93\u5b9e\u4f53\u5fc5\u987b\u76f4\u63a5\u6216\u95f4\u63a5\u7ee7\u627f ",Object(r.b)("inlineCode",{parentName:"p"},"IEntity")," \u624d\u80fd\u8fdb\u884c\u4ed3\u50a8\u7b49\u64cd\u4f5c\u3002"))),Object(r.b)("h2",{id:"933-\u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e"},"9.3.3 \u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e"),Object(r.b)("p",null,"\u5728\u8fc7\u53bb\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"EF Core")," \u9879\u76ee\u5f00\u53d1\u4e2d\uff0c\u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e\u9700\u8981\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"DbContext")," \u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"OnModelCreating")," \u4e2d\u914d\u7f6e\u3002",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u4e3a\u4e86\u7b80\u5316\u914d\u7f6e\u548c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\uff0c\u62bd\u8c61\u51fa\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"IEntityTypeBuilder")," \u63a5\u53e3\u3002"),Object(r.b)("p",null,"\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"IEntityTypeBuilder")," \u63a5\u53e3\uff0c\u6211\u4eec\u65e0\u9700\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"DbContext")," \u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"OnModelCreating")," \u4e2d\u914d\u7f6e\uff0c\u53ef\u5728\u4efb\u610f\u5730\u65b9\u914d\u7f6e\u3002"),Object(r.b)("h3",{id:"9331-\u5728\u6570\u636e\u5e93\u5b9e\u4f53\u4e2d\u914d\u7f6e"},"9.3.3.1 \u5728\u6570\u636e\u5e93\u5b9e\u4f53\u4e2d\u914d\u7f6e"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,20-25}","{1,5,20-25}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\n\nnamespace Fur.Core\n{\n public class User : Entity, IEntityTypeBuilder\n {\n /// \n /// \u540d\u79f0\n /// \n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n\n // \u914d\u7f6e\u6570\u636e\u5e93\u5b9e\u4f53\n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasKey(u => u.Id);\n entityBuilder.HasIndex(u => u.Name);\n }\n }\n}\n")),Object(r.b)("h3",{id:"9332-\u5728\u4efb\u4f55\u5b9e\u4f8b\u7c7b\u4e2d\u914d\u7f6e"},"9.3.3.2 \u5728\u4efb\u4f55\u5b9e\u4f8b\u7c7b\u4e2d\u914d\u7f6e"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,8,10-14}","{1,8,10-14}":!0}),"using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\n\nnamespace Fur.Core\n{\n public class SomeClass : IEntityTypeBuilder\n {\n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasKey(u => u.Id);\n entityBuilder.HasIndex(u => u.Name);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\uff0c\u4e0a\u9762\u4f8b\u5b50\uff0c\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"SomeClass")," \u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"User")," \u6570\u636e\u5e93\u5b9e\u4f53\u3002"),Object(r.b)("h2",{id:"934-\u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e\u8bf4\u660e"},"9.3.4 \u6570\u636e\u5e93\u5b9e\u4f53\u914d\u7f6e\u8bf4\u660e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4f1a\u81ea\u52a8\u626b\u63cf\u6240\u6709\u7ee7\u627f ",Object(r.b)("inlineCode",{parentName:"p"},"IEntity")," \u63a5\u53e3\u7684\u7c7b\u8fdb\u884c ",Object(r.b)("inlineCode",{parentName:"p"},"DbSet")," \u6ce8\u518c\uff0c\u4e5f\u5c31\u662f\u5b9e\u73b0\u81ea\u52a8\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"DbContext")," \u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"OnModelCreating"),"\u3002"),Object(r.b)("p",null,"\u5982\u679c\u9700\u8981\u8df3\u8fc7\u81ea\u52a8\u6ce8\u518c\uff0c\u53ea\u9700\u8981\u8d34 ",Object(r.b)("inlineCode",{parentName:"p"},"[NonAutomatic]")," \u6216 ",Object(r.b)("inlineCode",{parentName:"p"},"[SkipScan]")," \u7279\u6027\u5373\u53ef\u3002\u4e00\u65e6\u8d34\u4e86\u6b21\u7279\u6027\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u624b\u52a8\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"DbContext")," \u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"OnModelCreating")),Object(r.b)("h2",{id:"935-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.3.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/handbook/build/8bbf9761.bb6f6ac0.js b/handbook/build/8bbf9761.bb6f6ac0.js new file mode 100644 index 00000000000..219ac651d97 --- /dev/null +++ b/handbook/build/8bbf9761.bb6f6ac0.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[48],{104:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return i})),n.d(t,"metadata",(function(){return c})),n.d(t,"rightToc",(function(){return l})),n.d(t,"default",(function(){return p}));var r=n(2),a=n(6),o=(n(0),n(142)),i={id:"reference",title:"1.4 \u9879\u76ee\u5f15\u7528",sidebar_label:"1.4 \u9879\u76ee\u5f15\u7528"},c={unversionedId:"reference",id:"reference",isDocsHomePage:!1,title:"1.4 \u9879\u76ee\u5f15\u7528",description:"1.4.1 \u5173\u4e8e\u9879\u76ee\u5f15\u7528",source:"@site/docs\\reference.mdx",slug:"/reference",permalink:"/fur/docs/reference",editUrl:"https://gitee.com/monksoul/Fur/tree/main/handbook/docs/reference.mdx",version:"current",sidebar_label:"1.4 \u9879\u76ee\u5f15\u7528",sidebar:"docs",previous:{title:"1.3 \u6e90\u7801\u7ed3\u6784",permalink:"/fur/docs/source"},next:{title:"2. \u4e00\u5206\u949f\u5165\u95e8",permalink:"/fur/docs/get-start"}},l=[{value:"1.4.1 \u5173\u4e8e\u9879\u76ee\u5f15\u7528",id:"141-\u5173\u4e8e\u9879\u76ee\u5f15\u7528",children:[]},{value:"1.4.2 \u521b\u5efa\u9879\u76ee\u6ce8\u610f\u4e8b\u9879",id:"142-\u521b\u5efa\u9879\u76ee\u6ce8\u610f\u4e8b\u9879",children:[]},{value:"1.4.3 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"143-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],b={rightToc:l};function p(e){var t=e.components,n=Object(a.a)(e,["components"]);return Object(o.b)("wrapper",Object(r.a)({},b,n,{components:t,mdxType:"MDXLayout"}),Object(o.b)("h2",{id:"141-\u5173\u4e8e\u9879\u76ee\u5f15\u7528"},"1.4.1 \u5173\u4e8e\u9879\u76ee\u5f15\u7528"),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u9ed8\u8ba4\u91c7\u7528\u591a\u5c42\u9879\u76ee\u8bbe\u8ba1\u67b6\u6784\uff0c\u6bcf\u4e00\u4e2a\u9879\u76ee\u5c42\u7684\u4f9d\u8d56\u5206\u522b\u662f\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Fur"),"\uff1a\u6838\u5fc3\u5c42\uff0c\u65e0\u9879\u76ee\u4f9d\u8d56"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Fur.Application"),"\uff1a\u6dfb\u52a0 ",Object(o.b)("inlineCode",{parentName:"li"},"Fur.Core")," \u5f15\u7528"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Fur.Core"),"\uff1a\u6dfb\u52a0 ",Object(o.b)("inlineCode",{parentName:"li"},"Fur")," \u5f15\u7528"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Fur.Database.Migrations"),"\uff1a\u6dfb\u52a0 ",Object(o.b)("inlineCode",{parentName:"li"},"Fur.EntityFramework.Core")," \u5f15\u7528"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Fur.EntityFramework.Core"),"\uff1a\u6dfb\u52a0 ",Object(o.b)("inlineCode",{parentName:"li"},"Fur.Core")," \u5f15\u7528"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Fur.Web.Core"),"\uff1a\u6dfb\u52a0 ",Object(o.b)("inlineCode",{parentName:"li"},"Fur.Application"),"\uff0c",Object(o.b)("inlineCode",{parentName:"li"},"Fur.Database.Migrations")," \u5f15\u7528"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Fur.Web.Entry"),"\uff1a\u6dfb\u52a0 ",Object(o.b)("inlineCode",{parentName:"li"},"Fur.Web.Core")," \u5f15\u7528 \u548c ",Object(o.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.Tools")," \u5305")),Object(o.b)("h2",{id:"142-\u521b\u5efa\u9879\u76ee\u6ce8\u610f\u4e8b\u9879"},"1.4.2 \u521b\u5efa\u9879\u76ee\u6ce8\u610f\u4e8b\u9879"),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u91c7\u7528\u6700\u65b0\u7684 ",Object(o.b)("inlineCode",{parentName:"p"},".NET 5")," \u5171\u4eab\u5305\u8bbe\u8ba1\u65b9\u5f0f\uff0c\u6240\u4ee5\uff0c\u6240\u6709\u65b0\u5efa\u7684 ",Object(o.b)("inlineCode",{parentName:"p"},"\u9879\u76ee")," \u90fd\u9700\u8981\u4fee\u6539 ",Object(o.b)("inlineCode",{parentName:"p"},".csproj")," \u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-xml",metastring:'title="Fur.Core\\Fur.Core.csproj"',title:'"Fur.Core\\Fur.Core.csproj"'}),'\n \n\n')),Object(o.b)("p",null,"\u5b8c\u6574\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-xml",metastring:"{17-19}","{17-19}":!0}),'\n\n \n net5.0\n 1701;1702;1591\n Fur.Core.xml\n \n\n \n \n \n\n \n \n \n\n \n \n \n\n\n\n')),Object(o.b)("p",null,"\u6240\u6709\u65b0\u5efa\u9879\u76ee\u90fd\u9700\u6dfb\u52a0 ",Object(o.b)("inlineCode",{parentName:"p"},"\u4e0a\u8ff0\u9ad8\u4eae\u4ee3\u7801"),"\uff0c\u65b9\u53ef\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u5168\u90e8\u529f\u80fd\u3002"),Object(o.b)("h2",{id:"143-\u53cd\u9988\u4e0e\u5efa\u8bae"},"1.4.3 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(o.b)("a",Object(r.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return d}));var r=n(0),a=n.n(r);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var b=a.a.createContext({}),p=function(e){var t=a.a.useContext(b),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},u=function(e){var t=p(e.components);return a.a.createElement(b.Provider,{value:t},e.children)},m={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},s=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,o=e.originalType,i=e.parentName,b=l(e,["components","mdxType","originalType","parentName"]),u=p(n),s=r,d=u["".concat(i,".").concat(s)]||u[s]||m[s]||o;return n?a.a.createElement(d,c(c({ref:t},b),{},{components:n})):a.a.createElement(d,c({ref:t},b))}));function d(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var o=n.length,i=new Array(o);i[0]=s;var c={};for(var l in t)hasOwnProperty.call(t,l)&&(c[l]=t[l]);c.originalType=e,c.mdxType="string"==typeof e?e:r,i[1]=c;for(var b=2;b\n \n\n')),Object(o.b)("p",null,"\u5b8c\u6574\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-xml",metastring:"{17-19}","{17-19}":!0}),'\n\n \n net5.0\n 1701;1702;1591\n Fur.Core.xml\n \n\n \n \n \n\n \n \n \n\n \n \n \n\n\n\n')),Object(o.b)("p",null,"\u6240\u6709\u65b0\u5efa\u9879\u76ee\u90fd\u9700\u6dfb\u52a0 ",Object(o.b)("inlineCode",{parentName:"p"},"\u4e0a\u8ff0\u9ad8\u4eae\u4ee3\u7801"),"\uff0c\u65b9\u53ef\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u5168\u90e8\u529f\u80fd\u3002"),Object(o.b)("h2",{id:"143-\u53cd\u9988\u4e0e\u5efa\u8bae"},"1.4.3 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(o.b)("a",Object(r.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return d}));var r=n(0),a=n.n(r);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var b=a.a.createContext({}),p=function(e){var t=a.a.useContext(b),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},u=function(e){var t=p(e.components);return a.a.createElement(b.Provider,{value:t},e.children)},m={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},s=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,o=e.originalType,i=e.parentName,b=l(e,["components","mdxType","originalType","parentName"]),u=p(n),s=r,d=u["".concat(i,".").concat(s)]||u[s]||m[s]||o;return n?a.a.createElement(d,c(c({ref:t},b),{},{components:n})):a.a.createElement(d,c({ref:t},b))}));function d(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var o=n.length,i=new Array(o);i[0]=s;var c={};for(var l in t)hasOwnProperty.call(t,l)&&(c[l]=t[l]);c.originalType=e,c.mdxType="string"==typeof e?e:r,i[1]=c;for(var b=2;b=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var u=o.a.createContext({}),p=function(e){var r=o.a.useContext(u),t=r;return e&&(t="function"==typeof e?e(r):c(c({},r),e)),t},s=function(e){var r=p(e.components);return o.a.createElement(u.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,i=e.parentName,u=l(e,["components","mdxType","originalType","parentName"]),s=p(t),d=n,m=s["".concat(i,".").concat(d)]||s[d]||f[d]||a;return t?o.a.createElement(m,c(c({ref:r},u),{},{components:t})):o.a.createElement(m,c({ref:r},u))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,i=new Array(a);i[0]=d;var c={};for(var l in r)hasOwnProperty.call(r,l)&&(c[l]=r[l]);c.originalType=e,c.mdxType="string"==typeof e?e:n,i[1]=c;for(var u=2;u=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var l=o.a.createContext({}),p=function(e){var r=o.a.useContext(l),t=r;return e&&(t="function"==typeof e?e(r):c(c({},r),e)),t},s=function(e){var r=p(e.components);return o.a.createElement(l.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,i=e.parentName,l=u(e,["components","mdxType","originalType","parentName"]),s=p(t),d=n,m=s["".concat(i,".").concat(d)]||s[d]||f[d]||a;return t?o.a.createElement(m,c(c({ref:r},l),{},{components:t})):o.a.createElement(m,c({ref:r},l))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,i=new Array(a);i[0]=d;var c={};for(var u in r)hasOwnProperty.call(r,u)&&(c[u]=r[u]);c.originalType=e,c.mdxType="string"==typeof e?e:n,i[1]=c;for(var l=2;l\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0",id:"91921-\u6253\u5f00-\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0",children:[]},{value:"9.19.2.2 \u5207\u6362\u9ed8\u8ba4\u9879\u76ee",id:"91922-\u5207\u6362\u9ed8\u8ba4\u9879\u76ee",children:[]},{value:"9.19.2.3 \u8f93\u5165 cli.ps1 \u547d\u4ee4",id:"91923-\u8f93\u5165-clips1-\u547d\u4ee4",children:[]}]},{value:"9.19.3 \u754c\u9762\u64cd\u4f5c\u6a21\u5f0f",id:"9193-\u754c\u9762\u64cd\u4f5c\u6a21\u5f0f",children:[{value:"9.19.3.1 \u542f\u52a8\u754c\u9762\u64cd\u4f5c",id:"91931-\u542f\u52a8\u754c\u9762\u64cd\u4f5c",children:[]},{value:"9.13.3.2 \u52a0\u8f7d\u6570\u636e\u5e93\u8868",id:"91332-\u52a0\u8f7d\u6570\u636e\u5e93\u8868",children:[]},{value:"9.13.3.3 \u9009\u62e9\u8868\u6216\u89c6\u56fe\u751f\u6210",id:"91333-\u9009\u62e9\u8868\u6216\u89c6\u56fe\u751f\u6210",children:[]},{value:"9.13.3.4 \u9009\u62e9\u4fdd\u5b58\u76ee\u5f55",id:"91334-\u9009\u62e9\u4fdd\u5b58\u76ee\u5f55",children:[]},{value:"9.13.3.5 \u751f\u6210\u6700\u7ec8\u5b9e\u4f53\u4ee3\u7801",id:"91335-\u751f\u6210\u6700\u7ec8\u5b9e\u4f53\u4ee3\u7801",children:[]}]},{value:"9.13.4 \u547d\u4ee4\u53c2\u6570\u914d\u7f6e",id:"9134-\u547d\u4ee4\u53c2\u6570\u914d\u7f6e",children:[]},{value:"9.13.5 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9135-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],s={rightToc:l};function p(e){var t=e.components,n=Object(i.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},s,n,{components:t,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"9191-\u6570\u636e\u5e93\u5f00\u53d1\u65b9\u5f0f"},"9.19.1 \u6570\u636e\u5e93\u5f00\u53d1\u65b9\u5f0f"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\u6765 ",Object(r.b)("strong",{parentName:"p"},"\u4fdd\u6301\u5b9e\u4f53\u6a21\u578b\u548c\u6570\u636e\u5e93\u67b6\u6784\u540c\u6b65"),"\u3002"),Object(r.b)("p",null,"\u81f3\u4e8e\u6211\u4eec\u5e94\u8be5\u9009\u7528\u54ea\u4e2a\u65b9\u6cd5\uff0c\u8bf7\u786e\u5b9a\u4f60\u662f\u5e0c\u671b\u4ee5\u5b9e\u4f53\u6a21\u578b\u4e3a\u51c6\u8fd8\u662f\u4ee5\u6570\u636e\u5e93\u4e3a\u51c6\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u5982\u679c\u5e0c\u671b ",Object(r.b)("strong",{parentName:"p"},"\u4ee5\u5b9e\u4f53\u6a21\u578b\u4e3a\u51c6"),"\uff0c\u8bf7\u4f7f\u7528\u6b63\u5411\u5de5\u7a0b\uff08Code First\uff09\u3002 \u5bf9\u5b9e\u4f53\u6a21\u578b\u8fdb\u884c\u66f4\u6539\u65f6\uff0c\u6b64\u65b9\u6cd5\u4f1a\u4ee5\u589e\u91cf\u65b9\u5f0f\u5c06\u76f8\u5e94\u67b6\u6784\u66f4\u6539\u5e94\u7528\u5230\u6570\u636e\u5e93\uff0c\u4ee5\u4f7f\u6570\u636e\u5e93\u4fdd\u6301\u4e0e\u5b9e\u4f53\u6a21\u578b\u517c\u5bb9\u3002")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u5982\u679c\u5e0c\u671b ",Object(r.b)("strong",{parentName:"p"},"\u4ee5\u6570\u636e\u5e93\u67b6\u6784\u4e3a\u51c6"),"\uff0c\u8bf7\u4f7f\u7528\u53cd\u5411\u5de5\u7a0b\uff08Database First\uff09\u3002 \u4f7f\u7528\u6b64\u65b9\u6cd5\uff0c\u53ef\u901a\u8fc7\u5c06\u6570\u636e\u5e93\u67b6\u6784\u53cd\u5411\u5de5\u7a0b\u5230\u5b9e\u4f53\u6a21\u578b\u6765\u751f\u6210\u76f8\u5e94\u7684\u5b9e\u4f53\u7c7b\u578b\u3002"))),Object(r.b)("p",null,"\u672c\u7ae0\u8282\u662f ",Object(r.b)("strong",{parentName:"p"},"\u53cd\u5411\u5de5\u7a0b\uff08Database First\uff09")," \u7684\u76f8\u5173\u5185\u5bb9\u3002"),Object(r.b)("h2",{id:"9192-\u64cd\u4f5c\u6307\u5357"},"9.19.2 \u64cd\u4f5c\u6307\u5357"),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u64cd\u4f5c\u4e4b\u524d\u6ce8\u610f\u4e8b\u9879")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u76ee\u524d ",Object(r.b)("inlineCode",{parentName:"p"},"Fur Tools")," \u751f\u6210\u5de5\u5177",Object(r.b)("strong",{parentName:"p"},"\u9ed8\u8ba4\u4e0d\u652f\u6301\u4efb\u4f55\u6570\u636e\u5e93"),"\u751f\u6210\uff0c\u6240\u4ee5\u5982\u9700\u751f\u6210\u7279\u5b9a\u6570\u636e\u5e93\u7684\u4ee3\u7801\uff0c\u53ea\u9700\u8981\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur.EntityFrameworkCore.Core")," \u5b89\u88c5\u5bf9\u5e94\u7684\u6570\u636e\u5e93\u5305\u5373\u53ef\uff1a"),Object(r.b)("p",{parentName:"div"},"\u5404\u4e2a\u6570\u636e\u5e93\u7684\u5305\u53ef\u67e5\u9605\uff1a",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"dbcontext-multi-database#91811-%E6%95%B0%E6%8D%AE%E5%BA%93%E6%8F%90%E4%BE%9B%E5%99%A8%E5%AF%B9%E5%BA%94%E5%8C%85"}),"\u591a\u6570\u636e\u5e93\u64cd\u4f5c-\u6570\u636e\u5e93\u63d0\u4f9b\u5668\u5bf9\u5e94\u5305")),Object(r.b)("p",{parentName:"div"},"\u53e6\u5916\uff0c\u53ea\u6709 ",Object(r.b)("inlineCode",{parentName:"p"},"SqlServer")," \u6570\u636e\u5e93\u652f\u6301\u53ef\u89c6\u5316 ",Object(r.b)("inlineCode",{parentName:"p"},"GUI")," \u64cd\u4f5c\uff0c\u5176\u4ed6\u7684\u53ea\u80fd\u547d\u4ee4\u884c\u64cd\u4f5c\u3002"))),Object(r.b)("h3",{id:"91921-\u6253\u5f00-\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0"},"9.19.2.1 \u6253\u5f00 ",Object(r.b)("inlineCode",{parentName:"h3"},"\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0")),Object(r.b)("p",null,"\u6ce8\u610f\uff1a\u5f00\u59cb\u4e4b\u524d\u5148\u628a ",Object(r.b)("inlineCode",{parentName:"p"},"Fur.Web.Entry")," \u8bbe\u4e3a\u542f\u52a8\u9879\u76ee\u3002"),Object(r.b)("img",{src:Object(o.a)("img/dbfirst1.png")}),Object(r.b)("h3",{id:"91922-\u5207\u6362\u9ed8\u8ba4\u9879\u76ee"},"9.19.2.2 \u5207\u6362\u9ed8\u8ba4\u9879\u76ee"),Object(r.b)("p",null,"\u5c06 ",Object(r.b)("inlineCode",{parentName:"p"},"\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0")," \u9ed8\u8ba4\u9879\u76ee\u8bbe\u7f6e\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"Fur.Core"),"\uff0c\u5982\u679c\u60a8\u662f\u5176\u4ed6\u540d\u5b57\uff0c\u5219\u5207\u6362\u5bf9\u5e94\u5373\u53ef\u3002"),Object(r.b)("img",{src:Object(o.a)("img/dbfirst2.png")}),Object(r.b)("h3",{id:"91923-\u8f93\u5165-clips1-\u547d\u4ee4"},"9.19.2.3 \u8f93\u5165 ",Object(r.b)("inlineCode",{parentName:"h3"},"cli.ps1")," \u547d\u4ee4"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),' &"../tools/cli.ps1"\n')),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u5173\u4e8e\u6570\u636e\u5e93\u547d\u540d")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5982\u679c\u9700\u8981\u4fdd\u6301\u548c\u6570\u636e\u5e93\u4e00\u6a21\u4e00\u6837\u7684\u547d\u540d\uff0c\u5219\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"-UseDatabaseNames")," \u53c2\u6570\u6307\u5b9a\uff0c\u5982\uff1a"),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),' &"../tools/cli.ps1" -UseDatabaseNames\n')))),Object(r.b)("img",{src:Object(o.a)("img/dbfirst3.png")}),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7b49\u5f85\u8f93\u5165")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u6267\u884c\u4e0a\u9762\u547d\u4ee4\u540e\uff0c\u6b64\u65f6\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Cli")," \u6709\u4e00\u4e2a\u7b49\u5f85\u8f93\u5165\u63d0\u793a\uff1a"),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Fur Tools v1.0.0 \u8bf7\u952e\u5165\u64cd\u4f5c\u7c7b\u578b\uff1a[G] \u754c\u9762\u64cd\u4f5c\uff0c[\u4efb\u610f\u5b57\u7b26] \u547d\u4ee4\u884c\u64cd\u4f5c\nFur Tools v1.0.0 \u60a8\u7684\u8f93\u5165\u662f:\n")),Object(r.b)("p",{parentName:"div"},Object(r.b)("strong",{parentName:"p"},"\u8f93\u5165\u5927\u5199 ",Object(r.b)("inlineCode",{parentName:"strong"},"G")," \u8fdb\u5165\u754c\u9762\u64cd\u4f5c\u6a21\u5f0f\uff0c\u5176\u4ed6\u4efb\u610f\u5b57\u7b26\u8fdb\u5165\u547d\u4ee4\u884c\u64cd\u4f5c\u6a21\u5f0f\u3002")))),Object(r.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u6ce8\u610f\u4e8b\u9879")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u76ee\u524d\u53ea\u6709 ",Object(r.b)("inlineCode",{parentName:"p"},"Sql Server")," \u6570\u636e\u5e93\u624d\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"p"},"GUI \u754c\u9762\u64cd\u4f5c\u6a21\u5f0f"),"\uff0c\u5176\u4ed6\u6570\u636e\u5e93\u8bf7\u4f7f\u7528\u547d\u4ee4\u884c\u6a21\u5f0f\u3002"))),Object(r.b)("h2",{id:"9193-\u754c\u9762\u64cd\u4f5c\u6a21\u5f0f"},"9.19.3 \u754c\u9762\u64cd\u4f5c\u6a21\u5f0f"),Object(r.b)("h3",{id:"91931-\u542f\u52a8\u754c\u9762\u64cd\u4f5c"},"9.19.3.1 \u542f\u52a8\u754c\u9762\u64cd\u4f5c"),Object(r.b)("p",null,"\u5f53\u6211\u4eec\u8f93\u5165 ",Object(r.b)("inlineCode",{parentName:"p"},"G")," \u65f6\uff0c\u5c06\u6253\u5f00 ",Object(r.b)("inlineCode",{parentName:"p"},"GUI")," \u754c\u9762\u64cd\u4f5c\u6a21\u5f0f\uff0c\u5982\uff1a"),Object(r.b)("img",{src:Object(o.a)("img/dbfirst4.png")}),Object(r.b)("p",null,"\u8fd9\u65f6\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur Tools")," \u4f1a\u81ea\u52a8\u67e5\u627e\u6240\u6709\u6570\u636e\u5e93\u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},".json")," \u6587\u4ef6\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:"{12-13}","{12-13}":!0}),'{\n "Logging": {\n "LogLevel": {\n "Default": "Information",\n "Microsoft": "Warning",\n "Microsoft.Hosting.Lifetime": "Information",\n "Microsoft.EntityFrameworkCore": "Information"\n }\n },\n "AllowedHosts": "*",\n "ConnectionStrings": {\n "DbConnectionString": "Server=localhost;Database=Fur;User=sa;Password=000000;MultipleActiveResultSets=True;",\n "Sqlite3ConnectionString": "Data Source=./Fur.db"\n }\n}\n')),Object(r.b)("h3",{id:"91332-\u52a0\u8f7d\u6570\u636e\u5e93\u8868"},"9.13.3.2 \u52a0\u8f7d\u6570\u636e\u5e93\u8868"),Object(r.b)("p",null,"\u9009\u62e9\u8fde\u63a5\u5b57\u7b26\u4e32\u4e4b\u540e\uff0c\u70b9\u51fb ",Object(r.b)("inlineCode",{parentName:"p"},"\u52a0\u8f7d\u6570\u636e\u5e93\u8868\u548c\u89c6\u56fe")," \u6309\u94ae\u52a0\u8f7d\u3002"),Object(r.b)("img",{src:Object(o.a)("img/dbfirst5.png")}),Object(r.b)("h3",{id:"91333-\u9009\u62e9\u8868\u6216\u89c6\u56fe\u751f\u6210"},"9.13.3.3 \u9009\u62e9\u8868\u6216\u89c6\u56fe\u751f\u6210"),Object(r.b)("p",null,"\u52a0\u8f7d\u8868\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u9009\u62e9\u60a8\u8981\u751f\u6210\u7684\u8868\u6216\u89c6\u56fe\uff0c",Object(r.b)("strong",{parentName:"p"},"\u652f\u6301\u591a\u9009")),Object(r.b)("img",{src:Object(o.a)("img/dbfirst6.png")}),Object(r.b)("p",null,"\u70b9\u51fb\u5e95\u90e8\u6309\u94ae ",Object(r.b)("inlineCode",{parentName:"p"},"\u7acb\u5373\u751f\u6210")),Object(r.b)("h3",{id:"91334-\u9009\u62e9\u4fdd\u5b58\u76ee\u5f55"},"9.13.3.4 \u9009\u62e9\u4fdd\u5b58\u76ee\u5f55"),Object(r.b)("p",null,"\u70b9\u51fb ",Object(r.b)("inlineCode",{parentName:"p"},"\u7acb\u5373\u751f\u6210")," \u6309\u94ae\u540e\uff0c\u4f1a\u5f39\u51fa\u5b9e\u4f53\u4fdd\u5b58\u9009\u62e9\u76ee\u5f55\u8d44\u6e90\u7ba1\u7406\u5668\uff0c\u9ed8\u8ba4\u5b9e\u4f53\u53ea\u80fd\u4fdd\u5b58\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur.Core")," \u5c42\uff1a"),Object(r.b)("img",{src:Object(o.a)("img/dbfirst7.png")}),Object(r.b)("p",null,"\u70b9\u51fb\u786e\u5b9a\u540e\u5c31\u53ef\u5b8c\u6210\u6240\u6709\u751f\u6210\u64cd\u4f5c\u3002"),Object(r.b)("h3",{id:"91335-\u751f\u6210\u6700\u7ec8\u5b9e\u4f53\u4ee3\u7801"},"9.13.3.5 \u751f\u6210\u6700\u7ec8\u5b9e\u4f53\u4ee3\u7801"),Object(r.b)("img",{src:Object(o.a)("img/dbfirst8.png")}),Object(r.b)("p",null,"\u6700\u7ec8\u811a\u672c\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),'PM> &"../tools/cli.ps1"\n// -----------------------------------------------------------------------------\n// ______ _______ _\n// | ____| |__ __| | |\n// | |__ _ _ _ __ | | ___ ___ | |___\n// | __| | | | \'__| | |/ _ \\ / _ \\| / __|\n// | | | |_| | | | | (_) | (_) | \\__ \\\n// |_| \\__,_|_| |_|\\___/ \\___/|_|___/\n//\n// -----------------------------------------------------------------------------\n// Fur \u662f .NET 5 \u5e73\u53f0\u4e0b\u6781\u6613\u5165\u95e8\u3001\u6781\u901f\u5f00\u53d1\u7684 Web \u5e94\u7528\u6846\u67b6\u3002\n// Copyright \xa9 2020 Fur, Baiqian Co.,Ltd.\n//\n// \u6846\u67b6\u540d\u79f0\uff1aFur\n// \u6846\u67b6\u4f5c\u8005\uff1a\u767e\u5c0f\u50e7\n// \u6846\u67b6\u7248\u672c\uff1a1.0.0\n// \u6e90\u7801\u5730\u5740\uff1ahttps://gitee.com/monksoul/Fur\n// \u5f00\u6e90\u534f\u8bae\uff1aApache-2.0\uff08http://www.apache.org/licenses/LICENSE-2.0\uff09\n// -----------------------------------------------------------------------------\nFur Tools v1.0.0 \u542f\u52a8\u4e2d......\nFur Tools v1.0.0 \u542f\u52a8\u6210\u529f\uff01\nFur Tools v1.0.0 \u8bf7\u952e\u5165\u64cd\u4f5c\u7c7b\u578b\uff1a[G] \u754c\u9762\u64cd\u4f5c\uff0c[\u4efb\u610f\u5b57\u7b26] \u547d\u4ee4\u884c\u64cd\u4f5c\nFur Tools v1.0.0 \u60a8\u7684\u8f93\u5165\u662f: G\nFur Tools v1.0.0 \u6b63\u5728\u52a0\u8f7d\u6570\u636e\u5e93\u8868\u548c\u89c6\u56fe......\nFur Tools v1.0.0 \u52a0\u8f7d\u6210\u529f\uff01\nFur Tools v1.0.0 \u6b63\u5728\u7f16\u8bd1\u89e3\u51b3\u65b9\u6848\u4ee3\u7801......\nBuild started...\nBuild succeeded.\nFor foreign key FK_PersonDetail_Person_PersonId on table dbo.PersonDetail, unable to model the end of the foreign key on principal table dbo.Person. This is usually because the principal table was not included in the selection set.\nFur Tools v1.0.0 \u7f16\u8bd1\u6210\u529f\uff01\nFur Tools v1.0.0 \u5f00\u59cb\u751f\u6210\u5b9e\u4f53\u6587\u4ef6......\nFur Tools v1.0.0 \u6b63\u5728\u751f\u6210 City.cs \u5b9e\u4f53\u4ee3\u7801......\nFur Tools v1.0.0 \u6210\u529f\u751f\u6210 City.cs \u5b9e\u4f53\u4ee3\u7801\n// -----------------------------------------------------------------------------\n// \u4ee5\u4e0b\u4ee3\u7801\u7531 Fur Tools v1.0.0 \u751f\u6210\n// -----------------------------------------------------------------------------\n\nusing Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Collections.Generic;\n\n#nullable disable\n\nnamespace Fur.Core\n{\n public partial class City : IEntity, IEntityTypeBuilder\n {\n\n public City()\n {\n InverseParent = new HashSet();\n }\n\n public int Id { get; set; }\n public string Name { get; set; }\n public int? ParentId { get; set; }\n public DateTime CreatedTime { get; set; }\n public DateTime? UpdatedTime { get; set; }\n public bool IsDeleted { get; set; }\n\n public virtual City Parent { get; set; }\n public virtual ICollection InverseParent { get; set; }\n\n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasIndex(e => e.ParentId, "IX_City_ParentId");\n\n entityBuilder.HasOne(d => d.Parent)\n .WithMany(p => p.InverseParent)\n .HasForeignKey(d => d.ParentId);\n\n }\n\n }\n}\n\nFur Tools v1.0.0 \u6b63\u5728\u751f\u6210 PersonDetail.cs \u5b9e\u4f53\u4ee3\u7801......\nFur Tools v1.0.0 \u6210\u529f\u751f\u6210 PersonDetail.cs \u5b9e\u4f53\u4ee3\u7801\n// -----------------------------------------------------------------------------\n// \u4ee5\u4e0b\u4ee3\u7801\u7531 Fur Tools v1.0.0 \u751f\u6210\n// -----------------------------------------------------------------------------\n\nusing Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Collections.Generic;\n\n#nullable disable\n\nnamespace Fur.Core\n{\n public partial class PersonDetail : IEntity, IEntityTypeBuilder\n {\n\n public int Id { get; set; }\n public string PhoneNumber { get; set; }\n public string Qq { get; set; }\n public int PersonId { get; set; }\n\n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasIndex(e => e.PersonId, "IX_PersonDetail_PersonId")\n .IsUnique();\n\n entityBuilder.Property(e => e.Qq).HasColumnName("QQ");\n\n }\n\n }\n}\n\nFur Tools v1.0.0 \u6b63\u5728\u751f\u6210 Post.cs \u5b9e\u4f53\u4ee3\u7801......\nFur Tools v1.0.0 \u6210\u529f\u751f\u6210 Post.cs \u5b9e\u4f53\u4ee3\u7801\n// -----------------------------------------------------------------------------\n// \u4ee5\u4e0b\u4ee3\u7801\u7531 Fur Tools v1.0.0 \u751f\u6210\n// -----------------------------------------------------------------------------\n\nusing Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Collections.Generic;\n\n#nullable disable\n\nnamespace Fur.Core\n{\n public partial class Post : IEntity\n {\n\n public int Id { get; set; }\n public string Name { get; set; }\n public DateTime CreatedTime { get; set; }\n public DateTime? UpdatedTime { get; set; }\n public bool IsDeleted { get; set; }\n\n }\n}\n\nFur Tools v1.0.0 \u6b63\u5728\u751f\u6210 VPerson.cs \u5b9e\u4f53\u4ee3\u7801......\nFur Tools v1.0.0 \u6210\u529f\u751f\u6210 VPerson.cs \u5b9e\u4f53\u4ee3\u7801\n// -----------------------------------------------------------------------------\n// \u4ee5\u4e0b\u4ee3\u7801\u7531 Fur Tools v1.0.0 \u751f\u6210\n// -----------------------------------------------------------------------------\n\nusing Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Collections.Generic;\n\n#nullable disable\n\nnamespace Fur.Core\n{\n public partial class VPerson : IEntity, IEntityTypeBuilder\n {\n\n public int Id { get; set; }\n public string Name { get; set; }\n public int Age { get; set; }\n public string Address { get; set; }\n\n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasNoKey();\n\n entityBuilder.ToView("V_Person");\n\n entityBuilder.Property(e => e.Id).ValueGeneratedOnAdd();\n\n entityBuilder.Property(e => e.Name).HasMaxLength(32);\n\n }\n\n }\n}\n\nFur Tools v1.0.0 \u5168\u90e8\u5b9e\u4f53\u751f\u6210\u6210\u529f\uff01\nPM>\n')),Object(r.b)("h2",{id:"9134-\u547d\u4ee4\u53c2\u6570\u914d\u7f6e"},"9.13.4 \u547d\u4ee4\u53c2\u6570\u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur Tools Cli")," \u652f\u6301\u591a\u4e2a\u53c2\u6570\u914d\u7f6e\uff0c\u4f7f\u7528\u65b9\u6cd5\u53ea\u9700\u8981\u5728\u547d\u4ee4\u540e\u9762\u6dfb\u52a0\u5373\u53ef\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),' &"../tools/cli.ps1" -Context \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u540d -ConnectionName \u8fde\u63a5\u5b57\u7b26\u4e32Key\n')),Object(r.b)("p",null,"\u652f\u6301\u53c2\u6570\u5982\u4e0b\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-Tables"),"\uff1a\u914d\u7f6e\u8981\u751f\u6210\u7684\u6570\u636e\u5e93\u8868\uff0c\u6570\u7ec4\u7c7b\u578b\uff0c\u5982\u679c\u4e3a\u7a7a\uff0c\u5219\u751f\u6210\u6570\u636e\u5e93\u6240\u6709\u8868\u548c\u89c6\u56fe\u3002\u5982\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"-Tables Person,PersonDetails")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-Context"),"\uff1a\u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"FurDbContext"),"\uff0c\u5982\u679c\u6709\u591a\u4e2a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u5219\u6b64\u53c2\u6570\u5fc5\u987b\u914d\u7f6e"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-ConnectionName"),"\uff1a\u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u5bf9\u4e8e ",Object(r.b)("inlineCode",{parentName:"li"},"appsetting.json")," \u4e2d\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"Key")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-OutputDir"),"\uff1a\u751f\u6210\u5b9e\u4f53\u4ee3\u7801\u8f93\u51fa\u76ee\u5f55\uff0c\u9ed8\u8ba4\u4e3a\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"./Fur.Core/Entities/")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-DbProvider"),"\uff1a\u6570\u636e\u5e93\u63d0\u4f9b\u5668\uff0c\u9ed8\u8ba4\u662f ",Object(r.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.SqlServer"),"\uff0c\u5176\u4ed6\u6570\u636e\u5e93\u8bf7\u6307\u5b9a\u5bf9\u5e94\u7a0b\u5e8f\u96c6",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"SqlServer"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.SqlServer")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Sqlite"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.Sqlite")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Cosmos"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.Cosmos")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"InMemoryDatabase"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.InMemory")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"MySql"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Pomelo.EntityFrameworkCore.MySql")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"PostgreSQL"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Npgsql.EntityFrameworkCore.PostgreSQL")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Oracle"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Citms.EntityFrameworkCore.Oracle")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Dm"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.Dm")))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-EntryProject"),"\uff1aWeb \u542f\u7528\u9879\u76ee\u5c42\u540d\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"Fur.Web.Entry")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-CoreProject"),"\uff1a\u5b9e\u4f53\u9879\u76ee\u5c42\u540d\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"Fur.Core")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-DbContextLocators"),"\uff1a\u591a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"MasterDbContextLocator"),"\uff0c\u652f\u6301\u591a\u4e2a\uff0c\u5982\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"MasterDbContextLocator,MySqlDbContextLocator")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-Product"),"\uff1a\u89e3\u51b3\u65b9\u6848\u9ed8\u8ba4\u524d\u7f00\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"li"},"Fur")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-UseDatabaseNames"),"\uff1a\u662f\u5426\u4fdd\u6301\u751f\u6210\u548c\u6570\u636e\u5e93\u3001\u8868\u4e00\u81f4\u7684\u540d\u79f0")),Object(r.b)("h2",{id:"9135-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.13.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return p})),n.d(t,"b",(function(){return m}));var a=n(0),i=n.n(a);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e){for(var t=1;t=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var l=i.a.createContext({}),s=function(e){var t=i.a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):b(b({},t),e)),n},p=function(e){var t=s(e.components);return i.a.createElement(l.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return i.a.createElement(i.a.Fragment,{},t)}},u=i.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,r=e.originalType,o=e.parentName,l=c(e,["components","mdxType","originalType","parentName"]),p=s(n),u=a,m=p["".concat(o,".").concat(u)]||p[u]||d[u]||r;return n?i.a.createElement(m,b(b({ref:t},l),{},{components:n})):i.a.createElement(m,b({ref:t},l))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var r=n.length,o=new Array(r);o[0]=u;var b={};for(var c in t)hasOwnProperty.call(t,c)&&(b[c]=t[c]);b.originalType=e,b.mdxType="string"==typeof e?e:a,o[1]=b;for(var l=2;l\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0",id:"91921-\u6253\u5f00-\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0",children:[]},{value:"9.19.2.2 \u5207\u6362\u9ed8\u8ba4\u9879\u76ee",id:"91922-\u5207\u6362\u9ed8\u8ba4\u9879\u76ee",children:[]},{value:"9.19.2.3 \u8f93\u5165 cli.ps1 \u547d\u4ee4",id:"91923-\u8f93\u5165-clips1-\u547d\u4ee4",children:[]}]},{value:"9.19.3 \u754c\u9762\u64cd\u4f5c\u6a21\u5f0f",id:"9193-\u754c\u9762\u64cd\u4f5c\u6a21\u5f0f",children:[{value:"9.19.3.1 \u542f\u52a8\u754c\u9762\u64cd\u4f5c",id:"91931-\u542f\u52a8\u754c\u9762\u64cd\u4f5c",children:[]},{value:"9.13.3.2 \u52a0\u8f7d\u6570\u636e\u5e93\u8868",id:"91332-\u52a0\u8f7d\u6570\u636e\u5e93\u8868",children:[]},{value:"9.13.3.3 \u9009\u62e9\u8868\u6216\u89c6\u56fe\u751f\u6210",id:"91333-\u9009\u62e9\u8868\u6216\u89c6\u56fe\u751f\u6210",children:[]},{value:"9.13.3.4 \u9009\u62e9\u4fdd\u5b58\u76ee\u5f55",id:"91334-\u9009\u62e9\u4fdd\u5b58\u76ee\u5f55",children:[]},{value:"9.13.3.5 \u751f\u6210\u6700\u7ec8\u5b9e\u4f53\u4ee3\u7801",id:"91335-\u751f\u6210\u6700\u7ec8\u5b9e\u4f53\u4ee3\u7801",children:[]}]},{value:"9.13.4 \u547d\u4ee4\u53c2\u6570\u914d\u7f6e",id:"9134-\u547d\u4ee4\u53c2\u6570\u914d\u7f6e",children:[]},{value:"9.13.5 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9135-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],s={rightToc:l};function p(e){var t=e.components,n=Object(i.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},s,n,{components:t,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"9191-\u6570\u636e\u5e93\u5f00\u53d1\u65b9\u5f0f"},"9.19.1 \u6570\u636e\u5e93\u5f00\u53d1\u65b9\u5f0f"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\u6765 ",Object(r.b)("strong",{parentName:"p"},"\u4fdd\u6301\u5b9e\u4f53\u6a21\u578b\u548c\u6570\u636e\u5e93\u67b6\u6784\u540c\u6b65"),"\u3002"),Object(r.b)("p",null,"\u81f3\u4e8e\u6211\u4eec\u5e94\u8be5\u9009\u7528\u54ea\u4e2a\u65b9\u6cd5\uff0c\u8bf7\u786e\u5b9a\u4f60\u662f\u5e0c\u671b\u4ee5\u5b9e\u4f53\u6a21\u578b\u4e3a\u51c6\u8fd8\u662f\u4ee5\u6570\u636e\u5e93\u4e3a\u51c6\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u5982\u679c\u5e0c\u671b ",Object(r.b)("strong",{parentName:"p"},"\u4ee5\u5b9e\u4f53\u6a21\u578b\u4e3a\u51c6"),"\uff0c\u8bf7\u4f7f\u7528\u6b63\u5411\u5de5\u7a0b\uff08Code First\uff09\u3002 \u5bf9\u5b9e\u4f53\u6a21\u578b\u8fdb\u884c\u66f4\u6539\u65f6\uff0c\u6b64\u65b9\u6cd5\u4f1a\u4ee5\u589e\u91cf\u65b9\u5f0f\u5c06\u76f8\u5e94\u67b6\u6784\u66f4\u6539\u5e94\u7528\u5230\u6570\u636e\u5e93\uff0c\u4ee5\u4f7f\u6570\u636e\u5e93\u4fdd\u6301\u4e0e\u5b9e\u4f53\u6a21\u578b\u517c\u5bb9\u3002")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u5982\u679c\u5e0c\u671b ",Object(r.b)("strong",{parentName:"p"},"\u4ee5\u6570\u636e\u5e93\u67b6\u6784\u4e3a\u51c6"),"\uff0c\u8bf7\u4f7f\u7528\u53cd\u5411\u5de5\u7a0b\uff08Database First\uff09\u3002 \u4f7f\u7528\u6b64\u65b9\u6cd5\uff0c\u53ef\u901a\u8fc7\u5c06\u6570\u636e\u5e93\u67b6\u6784\u53cd\u5411\u5de5\u7a0b\u5230\u5b9e\u4f53\u6a21\u578b\u6765\u751f\u6210\u76f8\u5e94\u7684\u5b9e\u4f53\u7c7b\u578b\u3002"))),Object(r.b)("p",null,"\u672c\u7ae0\u8282\u662f ",Object(r.b)("strong",{parentName:"p"},"\u53cd\u5411\u5de5\u7a0b\uff08Database First\uff09")," \u7684\u76f8\u5173\u5185\u5bb9\u3002"),Object(r.b)("h2",{id:"9192-\u64cd\u4f5c\u6307\u5357"},"9.19.2 \u64cd\u4f5c\u6307\u5357"),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u64cd\u4f5c\u4e4b\u524d\u6ce8\u610f\u4e8b\u9879")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u76ee\u524d ",Object(r.b)("inlineCode",{parentName:"p"},"Fur Tools")," \u751f\u6210\u5de5\u5177",Object(r.b)("strong",{parentName:"p"},"\u9ed8\u8ba4\u4e0d\u652f\u6301\u4efb\u4f55\u6570\u636e\u5e93"),"\u751f\u6210\uff0c\u6240\u4ee5\u5982\u9700\u751f\u6210\u7279\u5b9a\u6570\u636e\u5e93\u7684\u4ee3\u7801\uff0c\u53ea\u9700\u8981\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur.EntityFrameworkCore.Core")," \u5b89\u88c5\u5bf9\u5e94\u7684\u6570\u636e\u5e93\u5305\u5373\u53ef\uff1a"),Object(r.b)("p",{parentName:"div"},"\u5404\u4e2a\u6570\u636e\u5e93\u7684\u5305\u53ef\u67e5\u9605\uff1a",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"dbcontext-multi-database#91811-%E6%95%B0%E6%8D%AE%E5%BA%93%E6%8F%90%E4%BE%9B%E5%99%A8%E5%AF%B9%E5%BA%94%E5%8C%85"}),"\u591a\u6570\u636e\u5e93\u64cd\u4f5c-\u6570\u636e\u5e93\u63d0\u4f9b\u5668\u5bf9\u5e94\u5305")),Object(r.b)("p",{parentName:"div"},"\u53e6\u5916\uff0c\u53ea\u6709 ",Object(r.b)("inlineCode",{parentName:"p"},"SqlServer")," \u6570\u636e\u5e93\u652f\u6301\u53ef\u89c6\u5316 ",Object(r.b)("inlineCode",{parentName:"p"},"GUI")," \u64cd\u4f5c\uff0c\u5176\u4ed6\u7684\u53ea\u80fd\u547d\u4ee4\u884c\u64cd\u4f5c\u3002"))),Object(r.b)("h3",{id:"91921-\u6253\u5f00-\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0"},"9.19.2.1 \u6253\u5f00 ",Object(r.b)("inlineCode",{parentName:"h3"},"\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0")),Object(r.b)("p",null,"\u6ce8\u610f\uff1a\u5f00\u59cb\u4e4b\u524d\u5148\u628a ",Object(r.b)("inlineCode",{parentName:"p"},"Fur.Web.Entry")," \u8bbe\u4e3a\u542f\u52a8\u9879\u76ee\u3002"),Object(r.b)("img",{src:Object(o.a)("img/dbfirst1.png")}),Object(r.b)("h3",{id:"91922-\u5207\u6362\u9ed8\u8ba4\u9879\u76ee"},"9.19.2.2 \u5207\u6362\u9ed8\u8ba4\u9879\u76ee"),Object(r.b)("p",null,"\u5c06 ",Object(r.b)("inlineCode",{parentName:"p"},"\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0")," \u9ed8\u8ba4\u9879\u76ee\u8bbe\u7f6e\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"Fur.Core"),"\uff0c\u5982\u679c\u60a8\u662f\u5176\u4ed6\u540d\u5b57\uff0c\u5219\u5207\u6362\u5bf9\u5e94\u5373\u53ef\u3002"),Object(r.b)("img",{src:Object(o.a)("img/dbfirst2.png")}),Object(r.b)("h3",{id:"91923-\u8f93\u5165-clips1-\u547d\u4ee4"},"9.19.2.3 \u8f93\u5165 ",Object(r.b)("inlineCode",{parentName:"h3"},"cli.ps1")," \u547d\u4ee4"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),' &"../tools/cli.ps1"\n')),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u5173\u4e8e\u6570\u636e\u5e93\u547d\u540d")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5982\u679c\u9700\u8981\u4fdd\u6301\u548c\u6570\u636e\u5e93\u4e00\u6a21\u4e00\u6837\u7684\u547d\u540d\uff0c\u5219\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"-UseDatabaseNames")," \u53c2\u6570\u6307\u5b9a\uff0c\u5982\uff1a"),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),' &"../tools/cli.ps1" -UseDatabaseNames\n')))),Object(r.b)("img",{src:Object(o.a)("img/dbfirst3.png")}),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7b49\u5f85\u8f93\u5165")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u6267\u884c\u4e0a\u9762\u547d\u4ee4\u540e\uff0c\u6b64\u65f6\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Cli")," \u6709\u4e00\u4e2a\u7b49\u5f85\u8f93\u5165\u63d0\u793a\uff1a"),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Fur Tools v1.0.0 \u8bf7\u952e\u5165\u64cd\u4f5c\u7c7b\u578b\uff1a[G] \u754c\u9762\u64cd\u4f5c\uff0c[\u4efb\u610f\u5b57\u7b26] \u547d\u4ee4\u884c\u64cd\u4f5c\nFur Tools v1.0.0 \u60a8\u7684\u8f93\u5165\u662f:\n")),Object(r.b)("p",{parentName:"div"},Object(r.b)("strong",{parentName:"p"},"\u8f93\u5165\u5927\u5199 ",Object(r.b)("inlineCode",{parentName:"strong"},"G")," \u8fdb\u5165\u754c\u9762\u64cd\u4f5c\u6a21\u5f0f\uff0c\u5176\u4ed6\u4efb\u610f\u5b57\u7b26\u8fdb\u5165\u547d\u4ee4\u884c\u64cd\u4f5c\u6a21\u5f0f\u3002")))),Object(r.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u6ce8\u610f\u4e8b\u9879")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u76ee\u524d\u53ea\u6709 ",Object(r.b)("inlineCode",{parentName:"p"},"Sql Server")," \u6570\u636e\u5e93\u624d\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"p"},"GUI \u754c\u9762\u64cd\u4f5c\u6a21\u5f0f"),"\uff0c\u5176\u4ed6\u6570\u636e\u5e93\u8bf7\u4f7f\u7528\u547d\u4ee4\u884c\u6a21\u5f0f\u3002"))),Object(r.b)("h2",{id:"9193-\u754c\u9762\u64cd\u4f5c\u6a21\u5f0f"},"9.19.3 \u754c\u9762\u64cd\u4f5c\u6a21\u5f0f"),Object(r.b)("h3",{id:"91931-\u542f\u52a8\u754c\u9762\u64cd\u4f5c"},"9.19.3.1 \u542f\u52a8\u754c\u9762\u64cd\u4f5c"),Object(r.b)("p",null,"\u5f53\u6211\u4eec\u8f93\u5165 ",Object(r.b)("inlineCode",{parentName:"p"},"G")," \u65f6\uff0c\u5c06\u6253\u5f00 ",Object(r.b)("inlineCode",{parentName:"p"},"GUI")," \u754c\u9762\u64cd\u4f5c\u6a21\u5f0f\uff0c\u5982\uff1a"),Object(r.b)("img",{src:Object(o.a)("img/dbfirst4.png")}),Object(r.b)("p",null,"\u8fd9\u65f6\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur Tools")," \u4f1a\u81ea\u52a8\u67e5\u627e\u6240\u6709\u6570\u636e\u5e93\u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},".json")," \u6587\u4ef6\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:"{12-13}","{12-13}":!0}),'{\n "Logging": {\n "LogLevel": {\n "Default": "Information",\n "Microsoft": "Warning",\n "Microsoft.Hosting.Lifetime": "Information",\n "Microsoft.EntityFrameworkCore": "Information"\n }\n },\n "AllowedHosts": "*",\n "ConnectionStrings": {\n "DbConnectionString": "Server=localhost;Database=Fur;User=sa;Password=000000;MultipleActiveResultSets=True;",\n "Sqlite3ConnectionString": "Data Source=./Fur.db"\n }\n}\n')),Object(r.b)("h3",{id:"91332-\u52a0\u8f7d\u6570\u636e\u5e93\u8868"},"9.13.3.2 \u52a0\u8f7d\u6570\u636e\u5e93\u8868"),Object(r.b)("p",null,"\u9009\u62e9\u8fde\u63a5\u5b57\u7b26\u4e32\u4e4b\u540e\uff0c\u70b9\u51fb ",Object(r.b)("inlineCode",{parentName:"p"},"\u52a0\u8f7d\u6570\u636e\u5e93\u8868\u548c\u89c6\u56fe")," \u6309\u94ae\u52a0\u8f7d\u3002"),Object(r.b)("img",{src:Object(o.a)("img/dbfirst5.png")}),Object(r.b)("h3",{id:"91333-\u9009\u62e9\u8868\u6216\u89c6\u56fe\u751f\u6210"},"9.13.3.3 \u9009\u62e9\u8868\u6216\u89c6\u56fe\u751f\u6210"),Object(r.b)("p",null,"\u52a0\u8f7d\u8868\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u9009\u62e9\u60a8\u8981\u751f\u6210\u7684\u8868\u6216\u89c6\u56fe\uff0c",Object(r.b)("strong",{parentName:"p"},"\u652f\u6301\u591a\u9009")),Object(r.b)("img",{src:Object(o.a)("img/dbfirst6.png")}),Object(r.b)("p",null,"\u70b9\u51fb\u5e95\u90e8\u6309\u94ae ",Object(r.b)("inlineCode",{parentName:"p"},"\u7acb\u5373\u751f\u6210")),Object(r.b)("h3",{id:"91334-\u9009\u62e9\u4fdd\u5b58\u76ee\u5f55"},"9.13.3.4 \u9009\u62e9\u4fdd\u5b58\u76ee\u5f55"),Object(r.b)("p",null,"\u70b9\u51fb ",Object(r.b)("inlineCode",{parentName:"p"},"\u7acb\u5373\u751f\u6210")," \u6309\u94ae\u540e\uff0c\u4f1a\u5f39\u51fa\u5b9e\u4f53\u4fdd\u5b58\u9009\u62e9\u76ee\u5f55\u8d44\u6e90\u7ba1\u7406\u5668\uff0c\u9ed8\u8ba4\u5b9e\u4f53\u53ea\u80fd\u4fdd\u5b58\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur.Core")," \u5c42\uff1a"),Object(r.b)("img",{src:Object(o.a)("img/dbfirst7.png")}),Object(r.b)("p",null,"\u70b9\u51fb\u786e\u5b9a\u540e\u5c31\u53ef\u5b8c\u6210\u6240\u6709\u751f\u6210\u64cd\u4f5c\u3002"),Object(r.b)("h3",{id:"91335-\u751f\u6210\u6700\u7ec8\u5b9e\u4f53\u4ee3\u7801"},"9.13.3.5 \u751f\u6210\u6700\u7ec8\u5b9e\u4f53\u4ee3\u7801"),Object(r.b)("img",{src:Object(o.a)("img/dbfirst8.png")}),Object(r.b)("p",null,"\u6700\u7ec8\u811a\u672c\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),'PM> &"../tools/cli.ps1"\n// -----------------------------------------------------------------------------\n// ______ _______ _\n// | ____| |__ __| | |\n// | |__ _ _ _ __ | | ___ ___ | |___\n// | __| | | | \'__| | |/ _ \\ / _ \\| / __|\n// | | | |_| | | | | (_) | (_) | \\__ \\\n// |_| \\__,_|_| |_|\\___/ \\___/|_|___/\n//\n// -----------------------------------------------------------------------------\n// Fur \u662f .NET 5 \u5e73\u53f0\u4e0b\u6781\u6613\u5165\u95e8\u3001\u6781\u901f\u5f00\u53d1\u7684 Web \u5e94\u7528\u6846\u67b6\u3002\n// Copyright \xa9 2020 Fur, Baiqian Co.,Ltd.\n//\n// \u6846\u67b6\u540d\u79f0\uff1aFur\n// \u6846\u67b6\u4f5c\u8005\uff1a\u767e\u5c0f\u50e7\n// \u6846\u67b6\u7248\u672c\uff1a1.0.0\n// \u6e90\u7801\u5730\u5740\uff1ahttps://gitee.com/monksoul/Fur\n// \u5f00\u6e90\u534f\u8bae\uff1aApache-2.0\uff08http://www.apache.org/licenses/LICENSE-2.0\uff09\n// -----------------------------------------------------------------------------\nFur Tools v1.0.0 \u542f\u52a8\u4e2d......\nFur Tools v1.0.0 \u542f\u52a8\u6210\u529f\uff01\nFur Tools v1.0.0 \u8bf7\u952e\u5165\u64cd\u4f5c\u7c7b\u578b\uff1a[G] \u754c\u9762\u64cd\u4f5c\uff0c[\u4efb\u610f\u5b57\u7b26] \u547d\u4ee4\u884c\u64cd\u4f5c\nFur Tools v1.0.0 \u60a8\u7684\u8f93\u5165\u662f: G\nFur Tools v1.0.0 \u6b63\u5728\u52a0\u8f7d\u6570\u636e\u5e93\u8868\u548c\u89c6\u56fe......\nFur Tools v1.0.0 \u52a0\u8f7d\u6210\u529f\uff01\nFur Tools v1.0.0 \u6b63\u5728\u7f16\u8bd1\u89e3\u51b3\u65b9\u6848\u4ee3\u7801......\nBuild started...\nBuild succeeded.\nFor foreign key FK_PersonDetail_Person_PersonId on table dbo.PersonDetail, unable to model the end of the foreign key on principal table dbo.Person. This is usually because the principal table was not included in the selection set.\nFur Tools v1.0.0 \u7f16\u8bd1\u6210\u529f\uff01\nFur Tools v1.0.0 \u5f00\u59cb\u751f\u6210\u5b9e\u4f53\u6587\u4ef6......\nFur Tools v1.0.0 \u6b63\u5728\u751f\u6210 City.cs \u5b9e\u4f53\u4ee3\u7801......\nFur Tools v1.0.0 \u6210\u529f\u751f\u6210 City.cs \u5b9e\u4f53\u4ee3\u7801\n// -----------------------------------------------------------------------------\n// \u4ee5\u4e0b\u4ee3\u7801\u7531 Fur Tools v1.0.0 \u751f\u6210\n// -----------------------------------------------------------------------------\n\nusing Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Collections.Generic;\n\n#nullable disable\n\nnamespace Fur.Core\n{\n public partial class City : IEntity, IEntityTypeBuilder\n {\n\n public City()\n {\n InverseParent = new HashSet();\n }\n\n public int Id { get; set; }\n public string Name { get; set; }\n public int? ParentId { get; set; }\n public DateTime CreatedTime { get; set; }\n public DateTime? UpdatedTime { get; set; }\n public bool IsDeleted { get; set; }\n\n public virtual City Parent { get; set; }\n public virtual ICollection InverseParent { get; set; }\n\n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasIndex(e => e.ParentId, "IX_City_ParentId");\n\n entityBuilder.HasOne(d => d.Parent)\n .WithMany(p => p.InverseParent)\n .HasForeignKey(d => d.ParentId);\n\n }\n\n }\n}\n\nFur Tools v1.0.0 \u6b63\u5728\u751f\u6210 PersonDetail.cs \u5b9e\u4f53\u4ee3\u7801......\nFur Tools v1.0.0 \u6210\u529f\u751f\u6210 PersonDetail.cs \u5b9e\u4f53\u4ee3\u7801\n// -----------------------------------------------------------------------------\n// \u4ee5\u4e0b\u4ee3\u7801\u7531 Fur Tools v1.0.0 \u751f\u6210\n// -----------------------------------------------------------------------------\n\nusing Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Collections.Generic;\n\n#nullable disable\n\nnamespace Fur.Core\n{\n public partial class PersonDetail : IEntity, IEntityTypeBuilder\n {\n\n public int Id { get; set; }\n public string PhoneNumber { get; set; }\n public string Qq { get; set; }\n public int PersonId { get; set; }\n\n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasIndex(e => e.PersonId, "IX_PersonDetail_PersonId")\n .IsUnique();\n\n entityBuilder.Property(e => e.Qq).HasColumnName("QQ");\n\n }\n\n }\n}\n\nFur Tools v1.0.0 \u6b63\u5728\u751f\u6210 Post.cs \u5b9e\u4f53\u4ee3\u7801......\nFur Tools v1.0.0 \u6210\u529f\u751f\u6210 Post.cs \u5b9e\u4f53\u4ee3\u7801\n// -----------------------------------------------------------------------------\n// \u4ee5\u4e0b\u4ee3\u7801\u7531 Fur Tools v1.0.0 \u751f\u6210\n// -----------------------------------------------------------------------------\n\nusing Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Collections.Generic;\n\n#nullable disable\n\nnamespace Fur.Core\n{\n public partial class Post : IEntity\n {\n\n public int Id { get; set; }\n public string Name { get; set; }\n public DateTime CreatedTime { get; set; }\n public DateTime? UpdatedTime { get; set; }\n public bool IsDeleted { get; set; }\n\n }\n}\n\nFur Tools v1.0.0 \u6b63\u5728\u751f\u6210 VPerson.cs \u5b9e\u4f53\u4ee3\u7801......\nFur Tools v1.0.0 \u6210\u529f\u751f\u6210 VPerson.cs \u5b9e\u4f53\u4ee3\u7801\n// -----------------------------------------------------------------------------\n// \u4ee5\u4e0b\u4ee3\u7801\u7531 Fur Tools v1.0.0 \u751f\u6210\n// -----------------------------------------------------------------------------\n\nusing Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing System;\nusing System.Collections.Generic;\n\n#nullable disable\n\nnamespace Fur.Core\n{\n public partial class VPerson : IEntity, IEntityTypeBuilder\n {\n\n public int Id { get; set; }\n public string Name { get; set; }\n public int Age { get; set; }\n public string Address { get; set; }\n\n public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)\n {\n entityBuilder.HasNoKey();\n\n entityBuilder.ToView("V_Person");\n\n entityBuilder.Property(e => e.Id).ValueGeneratedOnAdd();\n\n entityBuilder.Property(e => e.Name).HasMaxLength(32);\n\n }\n\n }\n}\n\nFur Tools v1.0.0 \u5168\u90e8\u5b9e\u4f53\u751f\u6210\u6210\u529f\uff01\nPM>\n')),Object(r.b)("h2",{id:"9134-\u547d\u4ee4\u53c2\u6570\u914d\u7f6e"},"9.13.4 \u547d\u4ee4\u53c2\u6570\u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur Tools Cli")," \u652f\u6301\u591a\u4e2a\u53c2\u6570\u914d\u7f6e\uff0c\u4f7f\u7528\u65b9\u6cd5\u53ea\u9700\u8981\u5728\u547d\u4ee4\u540e\u9762\u6dfb\u52a0\u5373\u53ef\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),' &"../tools/cli.ps1" -Context \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u540d -ConnectionName \u8fde\u63a5\u5b57\u7b26\u4e32Key\n')),Object(r.b)("p",null,"\u652f\u6301\u53c2\u6570\u5982\u4e0b\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-Tables"),"\uff1a\u914d\u7f6e\u8981\u751f\u6210\u7684\u6570\u636e\u5e93\u8868\uff0c\u6570\u7ec4\u7c7b\u578b\uff0c\u5982\u679c\u4e3a\u7a7a\uff0c\u5219\u751f\u6210\u6570\u636e\u5e93\u6240\u6709\u8868\u548c\u89c6\u56fe\u3002\u5982\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"-Tables Person,PersonDetails")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-Context"),"\uff1a\u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"FurDbContext"),"\uff0c\u5982\u679c\u6709\u591a\u4e2a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u5219\u6b64\u53c2\u6570\u5fc5\u987b\u914d\u7f6e"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-ConnectionName"),"\uff1a\u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u5bf9\u4e8e ",Object(r.b)("inlineCode",{parentName:"li"},"appsetting.json")," \u4e2d\u7684 ",Object(r.b)("inlineCode",{parentName:"li"},"Key")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-OutputDir"),"\uff1a\u751f\u6210\u5b9e\u4f53\u4ee3\u7801\u8f93\u51fa\u76ee\u5f55\uff0c\u9ed8\u8ba4\u4e3a\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"./Fur.Core/Entities/")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-DbProvider"),"\uff1a\u6570\u636e\u5e93\u63d0\u4f9b\u5668\uff0c\u9ed8\u8ba4\u662f ",Object(r.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.SqlServer"),"\uff0c\u5176\u4ed6\u6570\u636e\u5e93\u8bf7\u6307\u5b9a\u5bf9\u5e94\u7a0b\u5e8f\u96c6",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"SqlServer"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.SqlServer")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Sqlite"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.Sqlite")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Cosmos"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.Cosmos")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"InMemoryDatabase"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.InMemory")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"MySql"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Pomelo.EntityFrameworkCore.MySql")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"PostgreSQL"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Npgsql.EntityFrameworkCore.PostgreSQL")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Oracle"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Citms.EntityFrameworkCore.Oracle")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Dm"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Microsoft.EntityFrameworkCore.Dm")))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-EntryProject"),"\uff1aWeb \u542f\u7528\u9879\u76ee\u5c42\u540d\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"Fur.Web.Entry")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-CoreProject"),"\uff1a\u5b9e\u4f53\u9879\u76ee\u5c42\u540d\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"Fur.Core")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-DbContextLocators"),"\uff1a\u591a\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"MasterDbContextLocator"),"\uff0c\u652f\u6301\u591a\u4e2a\uff0c\u5982\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"MasterDbContextLocator,MySqlDbContextLocator")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-Product"),"\uff1a\u89e3\u51b3\u65b9\u6848\u9ed8\u8ba4\u524d\u7f00\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"li"},"Fur")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"-UseDatabaseNames"),"\uff1a\u662f\u5426\u4fdd\u6301\u751f\u6210\u548c\u6570\u636e\u5e93\u3001\u8868\u4e00\u81f4\u7684\u540d\u79f0")),Object(r.b)("h2",{id:"9135-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.13.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return p})),n.d(t,"b",(function(){return m}));var a=n(0),i=n.n(a);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e){for(var t=1;t=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var l=i.a.createContext({}),s=function(e){var t=i.a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):b(b({},t),e)),n},p=function(e){var t=s(e.components);return i.a.createElement(l.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return i.a.createElement(i.a.Fragment,{},t)}},u=i.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,r=e.originalType,o=e.parentName,l=c(e,["components","mdxType","originalType","parentName"]),p=s(n),u=a,m=p["".concat(o,".").concat(u)]||p[u]||d[u]||r;return n?i.a.createElement(m,b(b({ref:t},l),{},{components:n})):i.a.createElement(m,b({ref:t},l))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var r=n.length,o=new Array(r);o[0]=u;var b={};for(var c in t)hasOwnProperty.call(t,c)&&(b[c]=t[c]);b.originalType=e,b.mdxType="string"==typeof e?e:a,o[1]=b;for(var l=2;l=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var l=o.a.createContext({}),p=function(e){var t=o.a.useContext(l),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},s=function(e){var t=p(e.components);return o.a.createElement(l.Provider,{value:t},e.children)},f={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},d=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,l=u(e,["components","mdxType","originalType","parentName"]),s=p(r),d=n,m=s["".concat(c,".").concat(d)]||s[d]||f[d]||a;return r?o.a.createElement(m,i(i({ref:t},l),{},{components:r})):o.a.createElement(m,i({ref:t},l))}));function m(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var a=r.length,c=new Array(a);c[0]=d;var i={};for(var u in t)hasOwnProperty.call(t,u)&&(i[u]=t[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var l=2;l=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var l=o.a.createContext({}),p=function(e){var t=o.a.useContext(l),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},s=function(e){var t=p(e.components);return o.a.createElement(l.Provider,{value:t},e.children)},f={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},d=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,l=u(e,["components","mdxType","originalType","parentName"]),s=p(r),d=n,m=s["".concat(c,".").concat(d)]||s[d]||f[d]||a;return r?o.a.createElement(m,i(i({ref:t},l),{},{components:r})):o.a.createElement(m,i({ref:t},l))}));function m(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var a=r.length,c=new Array(a);c[0]=d;var i={};for(var u in t)hasOwnProperty.call(t,u)&&(i[u]=t[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var l=2;l=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=o.a.createContext({}),l=function(e){var r=o.a.useContext(p),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},s=function(e){var r=l(e.components);return o.a.createElement(p.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},b=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),s=l(t),b=n,d=s["".concat(c,".").concat(b)]||s[b]||f[b]||a;return t?o.a.createElement(d,i(i({ref:r},p),{},{components:t})):o.a.createElement(d,i({ref:r},p))}));function d(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,c=new Array(a);c[0]=b;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var p=2;p=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=o.a.createContext({}),l=function(e){var r=o.a.useContext(p),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},s=function(e){var r=l(e.components);return o.a.createElement(p.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},b=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),s=l(t),b=n,d=s["".concat(c,".").concat(b)]||s[b]||f[b]||a;return t?o.a.createElement(d,i(i({ref:r},p),{},{components:t})):o.a.createElement(d,i({ref:r},p))}));function d(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,c=new Array(a);c[0]=b;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var p=2;pSaveChanges \u4e8b\u4ef6",id:"9222-\u5173\u4e8e-savechanges-\u4e8b\u4ef6",children:[]},{value:"9.22.3 \u5982\u4f55\u4f7f\u7528",id:"9223-\u5982\u4f55\u4f7f\u7528",children:[]},{value:"9.22.4 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9224-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],l={rightToc:b};function s(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},l,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"9221-\u5ba1\u8ba1\u65e5\u5fd7"},"9.22.1 \u5ba1\u8ba1\u65e5\u5fd7"),Object(i.b)("p",null,"\u5728\u4e00\u4e2a\u4f01\u4e1a\u5e94\u7528\u7cfb\u7edf\u4e2d\uff0c\u7528\u6237\u5bf9\u7cfb\u7edf\u6240\u6709\u7684\u64cd\u4f5c\u5305\u62ec\u8bf7\u6c42\uff0c\u6570\u636e\u5e93\u64cd\u4f5c\u7b49\u7b49\u90fd\u5e94\u8be5\u8bb0\u5f55\u8d77\u6765\uff0c\u90a3\u4e48\u8fd9\u4e9b\u65e5\u5fd7\u6211\u4eec\u6210\u4e3a\u64cd\u4f5c\u65e5\u5fd7\uff0c\u4e5f\u53ef\u4ee5\u8bf4\u5ba1\u8ba1\u65e5\u5fd7\u3002"),Object(i.b)("p",null,"\u901a\u5e38\u6765\u8bf4\uff0c\u6211\u4eec\u5ba1\u8ba1\u65e5\u5fd7\u66f4\u591a\u6307\u7684\u662f\u6570\u636e\u5e93\u7684\u64cd\u4f5c\u8bb0\u5f55\u3002"),Object(i.b)("p",null,"\u5ba1\u8ba1\u65e5\u5fd7\u4e00\u822c\u4f1a\u8bb0\u5f55\u4ee5\u4e0b\u4e09\u4e2a\u64cd\u4f5c\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"\u65b0\u589e\u64cd\u4f5c"),"\uff1a\u8bb0\u5f55\u67d0\u67d0\u4eba\u5728\u67d0\u67d0\u65f6\u95f4\u5bf9\u54ea\u4e2a\u8868\u65b0\u589e\u4e86\u4ec0\u4e48\u6570\u636e"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"\u66f4\u65b0\u64cd\u4f5c"),"\uff1a\u8bb0\u5f55\u67d0\u67d0\u4eba\u5728\u67d0\u67d0\u65f6\u95f4\u5bf9\u54ea\u4e2a\u8868\u7684\u54ea\u4e9b\u6570\u636e\u505a\u4e86\u66f4\u6539\uff0c\u8bb0\u5f55\u66f4\u6539\u524d\u7684\u503c\u548c\u66f4\u6539\u540e\u7684\u503c"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"\u5220\u9664\u64cd\u4f5c"),"\uff1a\u8bb0\u5f55\u67d0\u67d0\u4eba\u5728\u67d0\u67d0\u65f6\u95f4\u5bf9\u54ea\u4e2a\u8868\u5220\u9664\u4e86\u4ec0\u4e48\u6570\u636e")),Object(i.b)("h2",{id:"9222-\u5173\u4e8e-savechanges-\u4e8b\u4ef6"},"9.22.2 \u5173\u4e8e ",Object(i.b)("inlineCode",{parentName:"h2"},"SaveChanges")," \u4e8b\u4ef6"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u4e3a\u6240\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u5b50\u7c7b\u90fd\u63d0\u4f9b\u4e86\u4e09\u4e2a\u53ef\u91cd\u5199\u7684\u65b9\u6cd5\uff0c\u8fd9\u4e09\u4e2a\u65b9\u6cd5\u5206\u522b\u7531\u4e09\u4e2a\u4e8b\u4ef6\u89e6\u53d1\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"\u63d0\u4ea4\u66f4\u6539\u4e4b\u524d SavingChanges \u4e8b\u4ef6"),"\uff1a\u89e6\u53d1 ",Object(i.b)("inlineCode",{parentName:"li"},"void SavingChangesEvent(object sender, SavingChangesEventArgs e)")," \u65b9\u6cd5"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"\u63d0\u4ea4\u66f4\u6539\u4e4b\u540e SavedChanges \u4e8b\u4ef6"),"\uff1a\u89e6\u53d1 ",Object(i.b)("inlineCode",{parentName:"li"},"void SavedChangesEvent(object sender, SavedChangesEventArgs e)")," \u65b9\u6cd5"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"\u63d0\u4ea4\u66f4\u6539\u5931\u8d25 SaveChangesFailed \u4e8b\u4ef6"),"\uff1a\u89e6\u53d1 ",Object(i.b)("inlineCode",{parentName:"li"},"void SaveChangesFailedEvent(object sender, SaveChangesFailedEventArgs e)")," \u65b9\u6cd5")),Object(i.b)("p",null,"\u901a\u8fc7\u8fd9\u4e09\u4e2a\u4e8b\u4ef6\u6211\u4eec\u5c31\u53ef\u4ee5\u6355\u83b7\u6240\u6709\u66f4\u6539\u7684\u5b9e\u4f53\u7136\u540e\u4fdd\u5b58\u5230\u6570\u636e\u5e93\u5ba1\u8ba1\u65e5\u5fd7\u4e2d\u3002"),Object(i.b)("h2",{id:"9223-\u5982\u4f55\u4f7f\u7528"},"9.22.3 \u5982\u4f55\u4f7f\u7528"),Object(i.b)("p",null,"\u6211\u4eec\u53ea\u9700\u8981\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u5b50\u7c7b\u4e2d\u91cd\u5199 ",Object(i.b)("inlineCode",{parentName:"p"},"SavingChanges")," \u4e8b\u4ef6\u5bf9\u5e94\u65b9\u6cd5\u5373\u53ef\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{23}","{23}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\nusing System;\nusing System.Linq;\nusing System.Security.AccessControl;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class FurDbContext : AppDbContext\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n /// \n /// \u91cd\u5199\u4fdd\u5b58\u4e4b\u524d\u4e8b\u4ef6\n /// \n /// \n /// \n protected override void SavingChangesEvent(object sender, SavingChangesEventArgs e)\n {\n // \u83b7\u53d6\u5f53\u524d\u4e8b\u4ef6\u5bf9\u5e94\u4e0a\u4e0b\u6587\n var dbContext = sender as FurDbContext;\n\n // \u5f3a\u5236\u91cd\u65b0\u68c0\u67e5\u4e00\u8fb9\u5b9e\u4f53\u66f4\u6539\u4fe1\u606f\n dbContext.ChangeTracker.DetectChanges();\n\n // \u83b7\u53d6\u6240\u6709\u66f4\u6539\uff0c\u5220\u9664\uff0c\u65b0\u589e\u7684\u5b9e\u4f53\uff0c\u4f46\u6392\u9664\u5ba1\u8ba1\u5b9e\u4f53\uff08\u907f\u514d\u6b7b\u5faa\u73af\uff09\n var entities = dbContext.ChangeTracker.Entries()\n .Where(u => u.Entity.GetType() != typeof(Audit) && (u.State == EntityState.Modified || u.State == EntityState.Deleted || u.State == EntityState.Added));\n\n // \u901a\u8fc7\u8bf7\u6c42\u4e2d\u83b7\u53d6\u5f53\u524d\u64cd\u4f5c\u4eba\n var userId = App.GetService().HttpContext.Items["UserId"];\n\n // \u83b7\u53d6\u6240\u6709\u5df2\u66f4\u6539\u7684\u5b9e\u4f53\n foreach (var entity in entities)\n {\n // \u83b7\u53d6\u5b9e\u4f53\u7c7b\u578b\n var entityType = entity.Entity.GetType();\n\n // \u83b7\u53d6\u6240\u6709\u5b9e\u4f53\u6709\u6548\u5c5e\u6027\uff0c\u6392\u9664 [NotMapper] \u5c5e\u6027\n var props = entity.OriginalValues.Properties;\n\n // \u83b7\u53d6\u5b9e\u4f53\u5f53\u524d\uff08\u73b0\u5728\uff09\u7684\u503c\n var currentValues = entity.CurrentValues;\n\n // \u83b7\u53d6\u6570\u636e\u5e93\u4e2d\u5b9e\u4f53\u7684\u503c\n var databaseValues = entity.GetDatabaseValues();\n\n // \u904d\u5386\u6240\u6709\u5c5e\u6027\n foreach (var prop in props)\n {\n // \u83b7\u53d6\u5c5e\u6027\u540d\n var propName = prop.Name;\n\n // \u83b7\u53d6\u73b0\u5728\u7684\u5b9e\u4f53\u503c\n var newValue = currentValues[propName];\n\n object oldValue = null;\n // \u5982\u679c\u662f\u65b0\u589e\u6570\u636e\uff0c\u5219 databaseValues \u4e3a\u7a7a\uff0c\u6240\u4ee5\u9700\u8981\u5224\u65ad\u4e00\u4e0b\n if (databaseValues != null)\n {\n oldValue = databaseValues[propName];\n }\n\n // \u63d2\u5165\u5ba1\u8ba1\u65e5\u5fd7\u8868\n dbContext.Audits.Add(new Audit\n {\n Table = entityType.Name, // \u8868\u540d\n Column = propName, // \u66f4\u65b0\u7684\u5217\n NewValue = newValue, // \u65b0\u503c\n OldValue = oldValue, // \u65e7\u503c\n CreatedTime = DateTime.Now, // \u64cd\u4f5c\u65f6\u95f4\n UserId = userId, // \u64cd\u4f5c\u4eba\n Operate = entity.State.ToString(); // \u64cd\u4f5c\u65b9\u5f0f\uff1a\u65b0\u589e\u3001\u66f4\u65b0\u3001\u5220\u9664\n });\n }\n }\n }\n }\n}\n')),Object(i.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u5982\u679c\u5bf9\u6027\u80fd\u6709\u6240\u8981\u6c42\uff0c\u90a3\u4e48\u5efa\u8bae\u5ba1\u8ba1\u65e5\u5fd7\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"\u65e5\u5fd7\u7ec4\u4ef6")," \u5199\u5165\u6570\u636e\u5e93\uff0c\u5982\uff0c\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"Nlog\u3001Log4Net")," \u8fd9\u4e9b\u7b49\uff1a"),Object(i.b)("pre",{parentName:"div"},Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u63d2\u5165\u5ba1\u8ba1\u65e5\u5fd7\u8868\ndbContext.Audits.Add(new Audit\n{\n Table = entityType.Name, // \u8868\u540d\n Column = propName, // \u66f4\u65b0\u7684\u5217\n newValue = newValue, // \u65b0\u503c\n OldValue = oldValue, // \u65e7\u503c\n CreatedTime = DateTime.Now, // \u64cd\u4f5c\u65f6\u95f4\n UserId = userId, // \u64cd\u4f5c\u4eba\n Operate = entity.State.ToString(); // \u64cd\u4f5c\u65b9\u5f0f\uff1a\u65b0\u589e\u3001\u66f4\u65b0\u3001\u5220\u9664\n});\n")),Object(i.b)("p",{parentName:"div"},"\u66ff\u6362\u4e3a\uff1a"),Object(i.b)("pre",{parentName:"div"},Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"logger.Information(JsonConvert.SerializeObject(new Audit\n{\n Table = entityType.Name, // \u8868\u540d\n Column = propName, // \u66f4\u65b0\u7684\u5217\n newValue = newValue, // \u65b0\u503c\n OldValue = oldValue, // \u65e7\u503c\n CreatedTime = DateTime.Now, // \u64cd\u4f5c\u65f6\u95f4\n UserId = userId, // \u64cd\u4f5c\u4eba\n Operate = entity.State.ToString(); // \u64cd\u4f5c\u65b9\u5f0f\uff1a\u65b0\u589e\u3001\u66f4\u65b0\u3001\u5220\u9664\n}));\n")))),Object(i.b)("p",null,"\u901a\u8fc7\u4e0a\u9762\u7684\u4f8b\u5b50\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5bf9\u6570\u636e\u5e93\u6240\u6709\u7684\u65b0\u589e\u3001\u66f4\u65b0\u3001\u5220\u9664\u8fdb\u884c\u76d1\u63a7\u4e86\u3002"),Object(i.b)("h2",{id:"9224-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.22.4 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}s.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return p})),t.d(n,"b",(function(){return m}));var a=t(0),r=t.n(a);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function c(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var l=r.a.createContext({}),s=function(e){var n=r.a.useContext(l),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},p=function(e){var n=s(e.components);return r.a.createElement(l.Provider,{value:n},e.children)},d={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},u=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,i=e.originalType,o=e.parentName,l=b(e,["components","mdxType","originalType","parentName"]),p=s(t),u=a,m=p["".concat(o,".").concat(u)]||p[u]||d[u]||i;return t?r.a.createElement(m,c(c({ref:n},l),{},{components:t})):r.a.createElement(m,c({ref:n},l))}));function m(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var i=t.length,o=new Array(i);o[0]=u;var c={};for(var b in n)hasOwnProperty.call(n,b)&&(c[b]=n[b]);c.originalType=e,c.mdxType="string"==typeof e?e:a,o[1]=c;for(var l=2;lSaveChanges \u4e8b\u4ef6",id:"9222-\u5173\u4e8e-savechanges-\u4e8b\u4ef6",children:[]},{value:"9.22.3 \u5982\u4f55\u4f7f\u7528",id:"9223-\u5982\u4f55\u4f7f\u7528",children:[]},{value:"9.22.4 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9224-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],l={rightToc:b};function s(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},l,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"9221-\u5ba1\u8ba1\u65e5\u5fd7"},"9.22.1 \u5ba1\u8ba1\u65e5\u5fd7"),Object(i.b)("p",null,"\u5728\u4e00\u4e2a\u4f01\u4e1a\u5e94\u7528\u7cfb\u7edf\u4e2d\uff0c\u7528\u6237\u5bf9\u7cfb\u7edf\u6240\u6709\u7684\u64cd\u4f5c\u5305\u62ec\u8bf7\u6c42\uff0c\u6570\u636e\u5e93\u64cd\u4f5c\u7b49\u7b49\u90fd\u5e94\u8be5\u8bb0\u5f55\u8d77\u6765\uff0c\u90a3\u4e48\u8fd9\u4e9b\u65e5\u5fd7\u6211\u4eec\u6210\u4e3a\u64cd\u4f5c\u65e5\u5fd7\uff0c\u4e5f\u53ef\u4ee5\u8bf4\u5ba1\u8ba1\u65e5\u5fd7\u3002"),Object(i.b)("p",null,"\u901a\u5e38\u6765\u8bf4\uff0c\u6211\u4eec\u5ba1\u8ba1\u65e5\u5fd7\u66f4\u591a\u6307\u7684\u662f\u6570\u636e\u5e93\u7684\u64cd\u4f5c\u8bb0\u5f55\u3002"),Object(i.b)("p",null,"\u5ba1\u8ba1\u65e5\u5fd7\u4e00\u822c\u4f1a\u8bb0\u5f55\u4ee5\u4e0b\u4e09\u4e2a\u64cd\u4f5c\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"\u65b0\u589e\u64cd\u4f5c"),"\uff1a\u8bb0\u5f55\u67d0\u67d0\u4eba\u5728\u67d0\u67d0\u65f6\u95f4\u5bf9\u54ea\u4e2a\u8868\u65b0\u589e\u4e86\u4ec0\u4e48\u6570\u636e"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"\u66f4\u65b0\u64cd\u4f5c"),"\uff1a\u8bb0\u5f55\u67d0\u67d0\u4eba\u5728\u67d0\u67d0\u65f6\u95f4\u5bf9\u54ea\u4e2a\u8868\u7684\u54ea\u4e9b\u6570\u636e\u505a\u4e86\u66f4\u6539\uff0c\u8bb0\u5f55\u66f4\u6539\u524d\u7684\u503c\u548c\u66f4\u6539\u540e\u7684\u503c"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"\u5220\u9664\u64cd\u4f5c"),"\uff1a\u8bb0\u5f55\u67d0\u67d0\u4eba\u5728\u67d0\u67d0\u65f6\u95f4\u5bf9\u54ea\u4e2a\u8868\u5220\u9664\u4e86\u4ec0\u4e48\u6570\u636e")),Object(i.b)("h2",{id:"9222-\u5173\u4e8e-savechanges-\u4e8b\u4ef6"},"9.22.2 \u5173\u4e8e ",Object(i.b)("inlineCode",{parentName:"h2"},"SaveChanges")," \u4e8b\u4ef6"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u4e3a\u6240\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u5b50\u7c7b\u90fd\u63d0\u4f9b\u4e86\u4e09\u4e2a\u53ef\u91cd\u5199\u7684\u65b9\u6cd5\uff0c\u8fd9\u4e09\u4e2a\u65b9\u6cd5\u5206\u522b\u7531\u4e09\u4e2a\u4e8b\u4ef6\u89e6\u53d1\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"\u63d0\u4ea4\u66f4\u6539\u4e4b\u524d SavingChanges \u4e8b\u4ef6"),"\uff1a\u89e6\u53d1 ",Object(i.b)("inlineCode",{parentName:"li"},"void SavingChangesEvent(object sender, SavingChangesEventArgs e)")," \u65b9\u6cd5"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"\u63d0\u4ea4\u66f4\u6539\u4e4b\u540e SavedChanges \u4e8b\u4ef6"),"\uff1a\u89e6\u53d1 ",Object(i.b)("inlineCode",{parentName:"li"},"void SavedChangesEvent(object sender, SavedChangesEventArgs e)")," \u65b9\u6cd5"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"\u63d0\u4ea4\u66f4\u6539\u5931\u8d25 SaveChangesFailed \u4e8b\u4ef6"),"\uff1a\u89e6\u53d1 ",Object(i.b)("inlineCode",{parentName:"li"},"void SaveChangesFailedEvent(object sender, SaveChangesFailedEventArgs e)")," \u65b9\u6cd5")),Object(i.b)("p",null,"\u901a\u8fc7\u8fd9\u4e09\u4e2a\u4e8b\u4ef6\u6211\u4eec\u5c31\u53ef\u4ee5\u6355\u83b7\u6240\u6709\u66f4\u6539\u7684\u5b9e\u4f53\u7136\u540e\u4fdd\u5b58\u5230\u6570\u636e\u5e93\u5ba1\u8ba1\u65e5\u5fd7\u4e2d\u3002"),Object(i.b)("h2",{id:"9223-\u5982\u4f55\u4f7f\u7528"},"9.22.3 \u5982\u4f55\u4f7f\u7528"),Object(i.b)("p",null,"\u6211\u4eec\u53ea\u9700\u8981\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u5b50\u7c7b\u4e2d\u91cd\u5199 ",Object(i.b)("inlineCode",{parentName:"p"},"SavingChanges")," \u4e8b\u4ef6\u5bf9\u5e94\u65b9\u6cd5\u5373\u53ef\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{23}","{23}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\nusing System;\nusing System.Linq;\nusing System.Security.AccessControl;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class FurDbContext : AppDbContext\n {\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n /// \n /// \u91cd\u5199\u4fdd\u5b58\u4e4b\u524d\u4e8b\u4ef6\n /// \n /// \n /// \n protected override void SavingChangesEvent(object sender, SavingChangesEventArgs e)\n {\n // \u83b7\u53d6\u5f53\u524d\u4e8b\u4ef6\u5bf9\u5e94\u4e0a\u4e0b\u6587\n var dbContext = sender as FurDbContext;\n\n // \u5f3a\u5236\u91cd\u65b0\u68c0\u67e5\u4e00\u8fb9\u5b9e\u4f53\u66f4\u6539\u4fe1\u606f\n dbContext.ChangeTracker.DetectChanges();\n\n // \u83b7\u53d6\u6240\u6709\u66f4\u6539\uff0c\u5220\u9664\uff0c\u65b0\u589e\u7684\u5b9e\u4f53\uff0c\u4f46\u6392\u9664\u5ba1\u8ba1\u5b9e\u4f53\uff08\u907f\u514d\u6b7b\u5faa\u73af\uff09\n var entities = dbContext.ChangeTracker.Entries()\n .Where(u => u.Entity.GetType() != typeof(Audit) && (u.State == EntityState.Modified || u.State == EntityState.Deleted || u.State == EntityState.Added));\n\n // \u901a\u8fc7\u8bf7\u6c42\u4e2d\u83b7\u53d6\u5f53\u524d\u64cd\u4f5c\u4eba\n var userId = App.GetService().HttpContext.Items["UserId"];\n\n // \u83b7\u53d6\u6240\u6709\u5df2\u66f4\u6539\u7684\u5b9e\u4f53\n foreach (var entity in entities)\n {\n // \u83b7\u53d6\u5b9e\u4f53\u7c7b\u578b\n var entityType = entity.Entity.GetType();\n\n // \u83b7\u53d6\u6240\u6709\u5b9e\u4f53\u6709\u6548\u5c5e\u6027\uff0c\u6392\u9664 [NotMapper] \u5c5e\u6027\n var props = entity.OriginalValues.Properties;\n\n // \u83b7\u53d6\u5b9e\u4f53\u5f53\u524d\uff08\u73b0\u5728\uff09\u7684\u503c\n var currentValues = entity.CurrentValues;\n\n // \u83b7\u53d6\u6570\u636e\u5e93\u4e2d\u5b9e\u4f53\u7684\u503c\n var databaseValues = entity.GetDatabaseValues();\n\n // \u904d\u5386\u6240\u6709\u5c5e\u6027\n foreach (var prop in props)\n {\n // \u83b7\u53d6\u5c5e\u6027\u540d\n var propName = prop.Name;\n\n // \u83b7\u53d6\u73b0\u5728\u7684\u5b9e\u4f53\u503c\n var newValue = currentValues[propName];\n\n object oldValue = null;\n // \u5982\u679c\u662f\u65b0\u589e\u6570\u636e\uff0c\u5219 databaseValues \u4e3a\u7a7a\uff0c\u6240\u4ee5\u9700\u8981\u5224\u65ad\u4e00\u4e0b\n if (databaseValues != null)\n {\n oldValue = databaseValues[propName];\n }\n\n // \u63d2\u5165\u5ba1\u8ba1\u65e5\u5fd7\u8868\n dbContext.Audits.Add(new Audit\n {\n Table = entityType.Name, // \u8868\u540d\n Column = propName, // \u66f4\u65b0\u7684\u5217\n NewValue = newValue, // \u65b0\u503c\n OldValue = oldValue, // \u65e7\u503c\n CreatedTime = DateTime.Now, // \u64cd\u4f5c\u65f6\u95f4\n UserId = userId, // \u64cd\u4f5c\u4eba\n Operate = entity.State.ToString(); // \u64cd\u4f5c\u65b9\u5f0f\uff1a\u65b0\u589e\u3001\u66f4\u65b0\u3001\u5220\u9664\n });\n }\n }\n }\n }\n}\n')),Object(i.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u5982\u679c\u5bf9\u6027\u80fd\u6709\u6240\u8981\u6c42\uff0c\u90a3\u4e48\u5efa\u8bae\u5ba1\u8ba1\u65e5\u5fd7\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"\u65e5\u5fd7\u7ec4\u4ef6")," \u5199\u5165\u6570\u636e\u5e93\uff0c\u5982\uff0c\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"Nlog\u3001Log4Net")," \u8fd9\u4e9b\u7b49\uff1a"),Object(i.b)("pre",{parentName:"div"},Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u63d2\u5165\u5ba1\u8ba1\u65e5\u5fd7\u8868\ndbContext.Audits.Add(new Audit\n{\n Table = entityType.Name, // \u8868\u540d\n Column = propName, // \u66f4\u65b0\u7684\u5217\n newValue = newValue, // \u65b0\u503c\n OldValue = oldValue, // \u65e7\u503c\n CreatedTime = DateTime.Now, // \u64cd\u4f5c\u65f6\u95f4\n UserId = userId, // \u64cd\u4f5c\u4eba\n Operate = entity.State.ToString(); // \u64cd\u4f5c\u65b9\u5f0f\uff1a\u65b0\u589e\u3001\u66f4\u65b0\u3001\u5220\u9664\n});\n")),Object(i.b)("p",{parentName:"div"},"\u66ff\u6362\u4e3a\uff1a"),Object(i.b)("pre",{parentName:"div"},Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"logger.Information(JsonConvert.SerializeObject(new Audit\n{\n Table = entityType.Name, // \u8868\u540d\n Column = propName, // \u66f4\u65b0\u7684\u5217\n newValue = newValue, // \u65b0\u503c\n OldValue = oldValue, // \u65e7\u503c\n CreatedTime = DateTime.Now, // \u64cd\u4f5c\u65f6\u95f4\n UserId = userId, // \u64cd\u4f5c\u4eba\n Operate = entity.State.ToString(); // \u64cd\u4f5c\u65b9\u5f0f\uff1a\u65b0\u589e\u3001\u66f4\u65b0\u3001\u5220\u9664\n}));\n")))),Object(i.b)("p",null,"\u901a\u8fc7\u4e0a\u9762\u7684\u4f8b\u5b50\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5bf9\u6570\u636e\u5e93\u6240\u6709\u7684\u65b0\u589e\u3001\u66f4\u65b0\u3001\u5220\u9664\u8fdb\u884c\u76d1\u63a7\u4e86\u3002"),Object(i.b)("h2",{id:"9224-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.22.4 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}s.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return p})),t.d(n,"b",(function(){return m}));var a=t(0),r=t.n(a);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function c(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var l=r.a.createContext({}),s=function(e){var n=r.a.useContext(l),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},p=function(e){var n=s(e.components);return r.a.createElement(l.Provider,{value:n},e.children)},d={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},u=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,i=e.originalType,o=e.parentName,l=b(e,["components","mdxType","originalType","parentName"]),p=s(t),u=a,m=p["".concat(o,".").concat(u)]||p[u]||d[u]||i;return t?r.a.createElement(m,c(c({ref:n},l),{},{components:t})):r.a.createElement(m,c({ref:n},l))}));function m(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var i=t.length,o=new Array(i);o[0]=u;var c={};for(var b in n)hasOwnProperty.call(n,b)&&(c[b]=n[b]);c.originalType=e,c.mdxType="string"==typeof e?e:a,o[1]=c;for(var l=2;lobject",id:"91431-\u6807\u91cf\u51fd\u6570\u8fd4\u56de-object",children:[]},{value:"9.14.3.2 \u6807\u91cf\u51fd\u6570\u8fd4\u56de T",id:"91432-\u6807\u91cf\u51fd\u6570\u8fd4\u56de-t",children:[]},{value:"9.14.3.3 \u8868\u503c\u51fd\u6570\u8fd4\u56de DataTable",id:"91433-\u8868\u503c\u51fd\u6570\u8fd4\u56de-datatable",children:[]},{value:"9.14.3.4 \u8868\u503c\u51fd\u6570\u8fd4\u56de List<T>",id:"91434-\u8868\u503c\u51fd\u6570\u8fd4\u56de-listt",children:[]}]},{value:"9.14.4 \u5728 Linq \u4e2d\u4f7f\u7528 \u6807\u91cf\u51fd\u6570",id:"9144-\u5728-linq-\u4e2d\u4f7f\u7528-\u6807\u91cf\u51fd\u6570",children:[{value:"9.14.4.1 \u521b\u5efa\u6807\u91cf\u51fd\u6570",id:"91441-\u521b\u5efa\u6807\u91cf\u51fd\u6570",children:[]},{value:"9.14.4.2 \u521b\u5efa\u9759\u6001\u7c7b\u548c\u9759\u6001\u65b9\u6cd5",id:"91442-\u521b\u5efa\u9759\u6001\u7c7b\u548c\u9759\u6001\u65b9\u6cd5",children:[]},{value:"9.14.4.3 \u5728 Linq \u4e2d\u4f7f\u7528",id:"91443-\u5728-linq-\u4e2d\u4f7f\u7528",children:[]}]},{value:"9.14.5 \u5728 Linq \u4e2d\u4f7f\u7528 \u8868\u503c\u51fd\u6570",id:"9145-\u5728-linq-\u4e2d\u4f7f\u7528-\u8868\u503c\u51fd\u6570",children:[{value:"9.14.5.1 \u521b\u5efa\u8868\u503c\u51fd\u6570",id:"91451-\u521b\u5efa\u8868\u503c\u51fd\u6570",children:[]},{value:"9.14.5.2 \u521b\u5efa\u8868\u503c\u51fd\u6570\u6a21\u578b",id:"91452-\u521b\u5efa\u8868\u503c\u51fd\u6570\u6a21\u578b",children:[]},{value:"9.14.5.3 \u8868\u503c\u51fd\u6570\u914d\u7f6e",id:"91453-\u8868\u503c\u51fd\u6570\u914d\u7f6e",children:[]},{value:"9.14.5.4 \u5728 Linq \u4e2d\u4f7f\u7528",id:"91454-\u5728-linq-\u4e2d\u4f7f\u7528",children:[]}]},{value:"9.14.6 \u5728 EF Core \u5185\u7f6e\u51fd\u6570",id:"9146-\u5728-ef-core-\u5185\u7f6e\u51fd\u6570",children:[]},{value:"9.14.7 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9147-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],d={rightToc:o};function u(e){var t=e.components,n=Object(c.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},d,n,{components:t,mdxType:"MDXLayout"}),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u6e29\u99a8\u63d0\u793a")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u63a8\u8350\u4f7f\u7528 \u300a",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"/docs/dbcontext-sql-proxy"}),"9.15 Sql \u9ad8\u7ea7\u4ee3\u7406"),"\u300b\u4ee3\u66ff\u672c\u7ae0\u8282\u529f\u80fd\u3002",Object(r.b)("inlineCode",{parentName:"p"},"Sql \u9ad8\u7ea7\u4ee3\u7406")," \u80fd\u591f\u63d0\u4f9b\u66f4\u5bb9\u6613\u4e14\u66f4\u6613\u7ef4\u62a4\u7684\u65b9\u5f0f\u3002"))),Object(r.b)("h2",{id:"9141-\u6570\u636e\u5e93\u51fd\u6570"},"9.14.1 \u6570\u636e\u5e93\u51fd\u6570"),Object(r.b)("p",null,"\u5f15\u7528\u767e\u5ea6\u767e\u79d1\uff1a"),Object(r.b)("blockquote",null,Object(r.b)("p",{parentName:"blockquote"},"\u6570\u636e\u5e93\u51fd\u6570\u662f\u6307\u5f53\u9700\u8981\u5206\u6790\u6570\u636e\u6e05\u5355\u4e2d\u7684\u6570\u503c\u662f\u5426\u7b26\u5408\u7279\u5b9a\u6761\u4ef6\u65f6\uff0c\u4f7f\u7528\u6570\u636e\u5e93\u5de5\u4f5c\u8868\u51fd\u6570\u3002")),Object(r.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u6570\u636e\u5e93\u51fd\u6570\u5c31\u662f\u7528\u4e8e\u5b50\u8ba1\u7b97\u7684\u51fd\u6570\u3002\u5176\u8ba1\u7b97\u7684\u7ed3\u679c\u53ef\u4ee5\u7528\u4e8e\u6784\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u8bed\u53e5\u3002"),Object(r.b)("h3",{id:"91411-\u652f\u6301\u6807\u91cf\u51fd\u6570\u7684\u6570\u636e\u5e93"},"9.14.1.1 \u652f\u6301\u6807\u91cf\u51fd\u6570\u7684\u6570\u636e\u5e93"),Object(r.b)("table",null,Object(r.b)("thead",{parentName:"table"},Object(r.b)("tr",{parentName:"thead"},Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"SqlServer"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Sqlite"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Cosmos"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"InMemoryDatabase"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"MySql"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"PostgreSQL"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Oracle"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Firebird"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Dm"))),Object(r.b)("tbody",{parentName:"table"},Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}))))),Object(r.b)("h3",{id:"91412-\u652f\u6301\u8868\u503c\u51fd\u6570\u7684\u6570\u636e\u5e93"},"9.14.1.2 \u652f\u6301\u8868\u503c\u51fd\u6570\u7684\u6570\u636e\u5e93"),Object(r.b)("table",null,Object(r.b)("thead",{parentName:"table"},Object(r.b)("tr",{parentName:"thead"},Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"SqlServer"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Sqlite"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Cosmos"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"InMemoryDatabase"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"MySql"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"PostgreSQL"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Oracle"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Firebird"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Dm"))),Object(r.b)("tbody",{parentName:"table"},Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}))))),Object(r.b)("h2",{id:"9142-\u6570\u636e\u5e93\u51fd\u6570\u7c7b\u578b"},"9.14.2 \u6570\u636e\u5e93\u51fd\u6570\u7c7b\u578b"),Object(r.b)("p",null,"\u5728\u5173\u7cfb\u578b\u6570\u636e\u5e93\u4e2d\uff0c\u6570\u636e\u5e93\u51fd\u6570\u6709\u8fd9\u4e24\u79cd\u7c7b\u578b\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u6807\u91cf\u51fd\u6570"),"\uff1a\u53ea\u80fd\u8fd4\u56de\u5355\u4e2a\u503c"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u8868\u503c\u51fd\u6570"),"\uff1a\u53ea\u80fd\u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u96c6")),Object(r.b)("h2",{id:"9143-\u51fd\u6570\u7684\u4f7f\u7528"},"9.14.3 \u51fd\u6570\u7684\u4f7f\u7528"),Object(r.b)("h3",{id:"91431-\u6807\u91cf\u51fd\u6570\u8fd4\u56de-object"},"9.14.3.1 \u6807\u91cf\u51fd\u6570\u8fd4\u56de ",Object(r.b)("inlineCode",{parentName:"h3"},"object")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar value = _sqlRepository.SqlFunctionScalar("func_GetValue");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar value = _sqlExecuteProxy.GetValue(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar value = _personRepository.SqlFunctionScalar("func_GetValue");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar value = _repository.Sql().SqlFunctionScalar("func_GetValue");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u51fd\u6570\u540d\u6267\u884c\nvar value = "func_GetValue".SqlFunctionScalar();\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(r.b)("h3",{id:"91432-\u6807\u91cf\u51fd\u6570\u8fd4\u56de-t"},"9.14.3.2 \u6807\u91cf\u51fd\u6570\u8fd4\u56de ",Object(r.b)("inlineCode",{parentName:"h3"},"T")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar value = _sqlRepository.SqlFunctionScalar("func_GetValue");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar value = _sqlExecuteProxy.GetValue(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar value = _personRepository.SqlFunctionScalar("func_GetValue");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar value = _repository.Sql().SqlFunctionScalar("func_GetValue");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u51fd\u6570\u540d\u6267\u884c\nvar value = "func_GetValue".SqlFunctionScalar();\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(r.b)("h3",{id:"91433-\u8868\u503c\u51fd\u6570\u8fd4\u56de-datatable"},"9.14.3.3 \u8868\u503c\u51fd\u6570\u8fd4\u56de ",Object(r.b)("inlineCode",{parentName:"h3"},"DataTable")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar value = _sqlRepository.SqlFunctionQuery("func_GetTable");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar value = _sqlExecuteProxy.GetTable(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar value = _personRepository.SqlFunctionQuery("func_GetTable");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar value = _repository.Sql().SqlFunctionQuery("func_GetTable");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u51fd\u6570\u540d\u6267\u884c\nvar value = "func_GetTable".SqlFunctionQuery();\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(r.b)("h3",{id:"91434-\u8868\u503c\u51fd\u6570\u8fd4\u56de-listt"},"9.14.3.4 \u8868\u503c\u51fd\u6570\u8fd4\u56de ",Object(r.b)("inlineCode",{parentName:"h3"},"List")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar value = _sqlRepository.SqlFunctionQuery("func_GetTable");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar value = _sqlExecuteProxy.GetTable(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar value = _personRepository.SqlFunctionQuery("func_GetTable");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar value = _repository.Sql().SqlFunctionQuery("func_GetTable");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u51fd\u6570\u540d\u6267\u884c\nvar value = "func_GetTable".SqlFunctionQuery();\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(r.b)("h2",{id:"9144-\u5728-linq-\u4e2d\u4f7f\u7528-\u6807\u91cf\u51fd\u6570"},"9.14.4 \u5728 ",Object(r.b)("inlineCode",{parentName:"h2"},"Linq")," \u4e2d\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"h2"},"\u6807\u91cf\u51fd\u6570")),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u975e\u5e38\u7075\u6d3b\u7684\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Linq")," \u4e2d\u4f7f\u7528\u6807\u91cf\u51fd\u6570\u7684\u65b9\u6cd5\u3002\u5982\u679c\u50cf\u4f7f\u7528\u8fd9\u6837\u7684\u65b9\u5f0f\uff0c\u9700\u8981\u6ee1\u8db3\u4ee5\u4e0b\u4e24\u4e2a\u6761\u4ef6\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u6807\u91cf\u51fd\u6570\u5fc5\u987b\u5b9a\u4e49\u5728",Object(r.b)("strong",{parentName:"li"},"\u516c\u5f00\u9759\u6001\u7c7b"),"\u4e2d\uff0c\u4e14\u81ea\u5df1\u4e5f\u662f",Object(r.b)("strong",{parentName:"li"},"\u516c\u5f00\u9759\u6001\u65b9\u6cd5")),Object(r.b)("li",{parentName:"ul"},"\u8be5",Object(r.b)("strong",{parentName:"li"},"\u516c\u5f00\u9759\u6001\u65b9\u6cd5"),"\u5fc5\u987b\u8d34\u6709 ",Object(r.b)("inlineCode",{parentName:"li"},"[QueryableFunction]")," \u7279\u6027")),Object(r.b)("p",null,"\u793a\u4f8b\u5982\u4e0b\uff1a"),Object(r.b)("h3",{id:"91441-\u521b\u5efa\u6807\u91cf\u51fd\u6570"},"9.14.4.1 \u521b\u5efa\u6807\u91cf\u51fd\u6570"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql"}),"CREATE FUNCTION FN_GetId\n(\n @id INT\n)\nRETURNS INT\nAS\nBEGIN\n RETURN @id + 1;\nEND;\n")),Object(r.b)("h3",{id:"91442-\u521b\u5efa\u9759\u6001\u7c7b\u548c\u9759\u6001\u65b9\u6cd5"},"9.14.4.2 \u521b\u5efa\u9759\u6001\u7c7b\u548c\u9759\u6001\u65b9\u6cd5"),Object(r.b)("p",null,"\u521b\u5efa\u9759\u6001\u7c7b\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"p"},"QueryFunctions"),"\uff0c\u5c06\u8be5 ",Object(r.b)("inlineCode",{parentName:"p"},"\u6807\u91cf\u51fd\u6570")," \u653e\u5728\u9759\u6001\u7c7b\u4e2d\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1, 7, 10-11}","{1,":!0,"7,":!0,"10-11}":!0}),'using Fur.DatabaseAccessor;\nusing System;\n\nnamespace Fur.Application\n{\n // \u5fc5\u987b\u662f\u516c\u5f00\u9759\u6001\u7684\n public static class QueryFunctions\n {\n // \u5fc5\u987b\u662f\u9759\u6001\u65b9\u6cd5\n [QueryableFunction("FN_GetId", "dbo")] // \u914d\u7f6e\u6807\u91cf\u51fd\u6570\n public static int GetId(int id) => throw new NotSupportedException();\n }\n}\n')),Object(r.b)("h3",{id:"91443-\u5728-linq-\u4e2d\u4f7f\u7528"},"9.14.4.3 \u5728 ",Object(r.b)("inlineCode",{parentName:"h3"},"Linq")," \u4e2d\u4f7f\u7528"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"_personRepository.Where(u => u.Id > QueryFunctions.GetId(1)).ToList();\n")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql"}),"SELECT [p].[Id], [p].[Address], [p].[Age], [p].[CreatedTime], [p].[IsDeleted], [p].[Name], [p].[UpdatedTime]\nFROM [Person] AS [p]\nWHERE [p].[Id] > [dbo].[FN_GetId](1) // \ud83d\udca5 \u6ce8\u610f\u8fd9\u91cc\n")),Object(r.b)("img",{src:Object(b.a)("img/fn1.png")}),Object(r.b)("h2",{id:"9145-\u5728-linq-\u4e2d\u4f7f\u7528-\u8868\u503c\u51fd\u6570"},"9.14.5 \u5728 ",Object(r.b)("inlineCode",{parentName:"h2"},"Linq")," \u4e2d\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"h2"},"\u8868\u503c\u51fd\u6570")),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"EF Core 5.0")," \u7248\u672c\u652f\u6301\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Linq")," \u4e2d\u64cd\u4f5c ",Object(r.b)("inlineCode",{parentName:"p"},"\u8868\u503c\u51fd\u6570"),"\uff0c\u64cd\u4f5c\u6709\u70b9\u7c7b\u4f3c ",Object(r.b)("inlineCode",{parentName:"p"},"\u89c6\u56fe\u64cd\u4f5c")),Object(r.b)("p",null,"\u793a\u4f8b\u5982\u4e0b\uff1a"),Object(r.b)("h3",{id:"91451-\u521b\u5efa\u8868\u503c\u51fd\u6570"},"9.14.5.1 \u521b\u5efa\u8868\u503c\u51fd\u6570"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql"}),"CREATE FUNCTION dbo.GetPersons\n(\n @id INT\n)\nRETURNS TABLE\nAS\nRETURN\n(\n SELECT Id,\n Name,\n Age,\n Address\n FROM dbo.Person\n WHERE Id > @id\n);\n")),Object(r.b)("h3",{id:"91452-\u521b\u5efa\u8868\u503c\u51fd\u6570\u6a21\u578b"},"9.14.5.2 \u521b\u5efa\u8868\u503c\u51fd\u6570\u6a21\u578b"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"namespace Fur.Core\n{\n public class F_Person\n {\n /// \n /// \u4e3b\u952eId\n /// \n public int Id { get; set; }\n\n /// \n /// \u59d3\u540d\n /// \n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n\n /// \n /// \u4f4f\u5740\n /// \n public string Address { get; set; }\n }\n}\n")),Object(r.b)("h3",{id:"91453-\u8868\u503c\u51fd\u6570\u914d\u7f6e"},"9.14.5.3 \u8868\u503c\u51fd\u6570\u914d\u7f6e"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"DbContext")," \u7c7b\u4e2d\u5b9a\u4e49\u65b9\u6cd5\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{3,10,20-21}","{3,10,20-21}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing System.Linq;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class FurDbContext : AppDbContext\n {\n public IQueryable GetPersons(int id) => FromExpression(() => GetPersons(id));\n\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n protected override void OnModelCreating(ModelBuilder modelBuilder)\n {\n base.OnModelCreating(modelBuilder);\n\n modelBuilder.Entity(typeof(F_Person)).HasNoKey();\n modelBuilder.HasDbFunction(() => GetPersons(default));\n }\n }\n}\n')),Object(r.b)("h3",{id:"91454-\u5728-linq-\u4e2d\u4f7f\u7528"},"9.14.5.4 \u5728 ",Object(r.b)("inlineCode",{parentName:"h3"},"Linq")," \u4e2d\u4f7f\u7528"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'IQueryable query = _repository.DynamicDbContext.GetPersons(1);\nvar result = query.Where(u => u.Name.Equals("Fur")).ToList();\n')),Object(r.b)("p",null,"\u6700\u7ec8\u751f\u6210 ",Object(r.b)("inlineCode",{parentName:"p"},"Sql")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql"}),"SELECT [g].Id, [g].Name, [g].Age, [g].Address\nFROM dbo.GetPersons(1) AS [g]\nWHERE [g].Name == N'Fur';\n")),Object(r.b)("h2",{id:"9146-\u5728-ef-core-\u5185\u7f6e\u51fd\u6570"},"9.14.6 \u5728 ",Object(r.b)("inlineCode",{parentName:"h2"},"EF Core")," \u5185\u7f6e\u51fd\u6570"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"EF Core")," \u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u5f88\u591a\u5e38\u7528\u7684\u5185\u7f6e\u51fd\u6570\uff0c\u53ef\u4ee5\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Lambda")," \u6761\u4ef6\u4e2d\u4f7f\u7528\uff0c\u4e3b\u8981\u662f\u901a\u8fc7 EF.Functions \u8c03\u7528\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"_repository.Where(u => EF.Functions.DateDiffHour(u.CreatedDt, DateTime.Now) > 8).FirstOrDefault();\n")),Object(r.b)("p",null,"\u8fd9\u4e2a\u8bed\u53e5\u4f7f\u7528\u4e86 EF.Functions.DateDiffHour \u6700\u7ec8\u751f\u6210\u7684 Sql \u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql"}),"SELECT TOP(1) [a].*\nFROM [dbo].[TEST] AS [a]\nWHERE DATEDIFF(HOUR, [a].[CREATED_DT], GETDATE()) > 8\n")),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"EF Core")," \u5185\u7f6e\u51fd\u6570\u5c31\u4e0d\u4e00\u4e00\u5217\u51fa\u4e86\uff0c\u53ef\u4ee5\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"EF.Functions")," \u67e5\u770b\u66f4\u591a\uff0c\u5982\u679c\u4e0d\u80fd\u6ee1\u8db3\u81ea\u5df1\u7684\u9700\u6c42\uff0c\u90a3\u4e48\u53ef\u4ee5\u81ea\u5b9a\u4e49 ",Object(r.b)("inlineCode",{parentName:"p"},"Linq")," \u6807\u91cf\u51fd\u6570"),Object(r.b)("h2",{id:"9147-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.14.7 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}u.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return O}));var a=n(0),c=n.n(a);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function i(e){for(var t=1;t=0||(c[n]=e[n]);return c}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(c[n]=e[n])}return c}var o=c.a.createContext({}),d=function(e){var t=c.a.useContext(o),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},u=function(e){var t=d(e.components);return c.a.createElement(o.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return c.a.createElement(c.a.Fragment,{},t)}},p=c.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,r=e.originalType,b=e.parentName,o=l(e,["components","mdxType","originalType","parentName"]),u=d(n),p=a,O=u["".concat(b,".").concat(p)]||u[p]||s[p]||r;return n?c.a.createElement(O,i(i({ref:t},o),{},{components:n})):c.a.createElement(O,i({ref:t},o))}));function O(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var r=n.length,b=new Array(r);b[0]=p;var i={};for(var l in t)hasOwnProperty.call(t,l)&&(i[l]=t[l]);i.originalType=e,i.mdxType="string"==typeof e?e:a,b[1]=i;for(var o=2;oobject",id:"91431-\u6807\u91cf\u51fd\u6570\u8fd4\u56de-object",children:[]},{value:"9.14.3.2 \u6807\u91cf\u51fd\u6570\u8fd4\u56de T",id:"91432-\u6807\u91cf\u51fd\u6570\u8fd4\u56de-t",children:[]},{value:"9.14.3.3 \u8868\u503c\u51fd\u6570\u8fd4\u56de DataTable",id:"91433-\u8868\u503c\u51fd\u6570\u8fd4\u56de-datatable",children:[]},{value:"9.14.3.4 \u8868\u503c\u51fd\u6570\u8fd4\u56de List<T>",id:"91434-\u8868\u503c\u51fd\u6570\u8fd4\u56de-listt",children:[]}]},{value:"9.14.4 \u5728 Linq \u4e2d\u4f7f\u7528 \u6807\u91cf\u51fd\u6570",id:"9144-\u5728-linq-\u4e2d\u4f7f\u7528-\u6807\u91cf\u51fd\u6570",children:[{value:"9.14.4.1 \u521b\u5efa\u6807\u91cf\u51fd\u6570",id:"91441-\u521b\u5efa\u6807\u91cf\u51fd\u6570",children:[]},{value:"9.14.4.2 \u521b\u5efa\u9759\u6001\u7c7b\u548c\u9759\u6001\u65b9\u6cd5",id:"91442-\u521b\u5efa\u9759\u6001\u7c7b\u548c\u9759\u6001\u65b9\u6cd5",children:[]},{value:"9.14.4.3 \u5728 Linq \u4e2d\u4f7f\u7528",id:"91443-\u5728-linq-\u4e2d\u4f7f\u7528",children:[]}]},{value:"9.14.5 \u5728 Linq \u4e2d\u4f7f\u7528 \u8868\u503c\u51fd\u6570",id:"9145-\u5728-linq-\u4e2d\u4f7f\u7528-\u8868\u503c\u51fd\u6570",children:[{value:"9.14.5.1 \u521b\u5efa\u8868\u503c\u51fd\u6570",id:"91451-\u521b\u5efa\u8868\u503c\u51fd\u6570",children:[]},{value:"9.14.5.2 \u521b\u5efa\u8868\u503c\u51fd\u6570\u6a21\u578b",id:"91452-\u521b\u5efa\u8868\u503c\u51fd\u6570\u6a21\u578b",children:[]},{value:"9.14.5.3 \u8868\u503c\u51fd\u6570\u914d\u7f6e",id:"91453-\u8868\u503c\u51fd\u6570\u914d\u7f6e",children:[]},{value:"9.14.5.4 \u5728 Linq \u4e2d\u4f7f\u7528",id:"91454-\u5728-linq-\u4e2d\u4f7f\u7528",children:[]}]},{value:"9.14.6 \u5728 EF Core \u5185\u7f6e\u51fd\u6570",id:"9146-\u5728-ef-core-\u5185\u7f6e\u51fd\u6570",children:[]},{value:"9.14.7 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9147-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],d={rightToc:o};function u(e){var t=e.components,n=Object(c.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},d,n,{components:t,mdxType:"MDXLayout"}),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u6e29\u99a8\u63d0\u793a")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u63a8\u8350\u4f7f\u7528 \u300a",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"/fur/docs/dbcontext-sql-proxy"}),"9.15 Sql \u9ad8\u7ea7\u4ee3\u7406"),"\u300b\u4ee3\u66ff\u672c\u7ae0\u8282\u529f\u80fd\u3002",Object(r.b)("inlineCode",{parentName:"p"},"Sql \u9ad8\u7ea7\u4ee3\u7406")," \u80fd\u591f\u63d0\u4f9b\u66f4\u5bb9\u6613\u4e14\u66f4\u6613\u7ef4\u62a4\u7684\u65b9\u5f0f\u3002"))),Object(r.b)("h2",{id:"9141-\u6570\u636e\u5e93\u51fd\u6570"},"9.14.1 \u6570\u636e\u5e93\u51fd\u6570"),Object(r.b)("p",null,"\u5f15\u7528\u767e\u5ea6\u767e\u79d1\uff1a"),Object(r.b)("blockquote",null,Object(r.b)("p",{parentName:"blockquote"},"\u6570\u636e\u5e93\u51fd\u6570\u662f\u6307\u5f53\u9700\u8981\u5206\u6790\u6570\u636e\u6e05\u5355\u4e2d\u7684\u6570\u503c\u662f\u5426\u7b26\u5408\u7279\u5b9a\u6761\u4ef6\u65f6\uff0c\u4f7f\u7528\u6570\u636e\u5e93\u5de5\u4f5c\u8868\u51fd\u6570\u3002")),Object(r.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u6570\u636e\u5e93\u51fd\u6570\u5c31\u662f\u7528\u4e8e\u5b50\u8ba1\u7b97\u7684\u51fd\u6570\u3002\u5176\u8ba1\u7b97\u7684\u7ed3\u679c\u53ef\u4ee5\u7528\u4e8e\u6784\u5efa ",Object(r.b)("inlineCode",{parentName:"p"},"sql")," \u8bed\u53e5\u3002"),Object(r.b)("h3",{id:"91411-\u652f\u6301\u6807\u91cf\u51fd\u6570\u7684\u6570\u636e\u5e93"},"9.14.1.1 \u652f\u6301\u6807\u91cf\u51fd\u6570\u7684\u6570\u636e\u5e93"),Object(r.b)("table",null,Object(r.b)("thead",{parentName:"table"},Object(r.b)("tr",{parentName:"thead"},Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"SqlServer"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Sqlite"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Cosmos"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"InMemoryDatabase"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"MySql"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"PostgreSQL"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Oracle"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Firebird"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Dm"))),Object(r.b)("tbody",{parentName:"table"},Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}))))),Object(r.b)("h3",{id:"91412-\u652f\u6301\u8868\u503c\u51fd\u6570\u7684\u6570\u636e\u5e93"},"9.14.1.2 \u652f\u6301\u8868\u503c\u51fd\u6570\u7684\u6570\u636e\u5e93"),Object(r.b)("table",null,Object(r.b)("thead",{parentName:"table"},Object(r.b)("tr",{parentName:"thead"},Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"SqlServer"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Sqlite"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Cosmos"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"InMemoryDatabase"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"MySql"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"PostgreSQL"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Oracle"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Firebird"),Object(r.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Dm"))),Object(r.b)("tbody",{parentName:"table"},Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u2714"),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(a.a)({parentName:"tr"},{align:null}))))),Object(r.b)("h2",{id:"9142-\u6570\u636e\u5e93\u51fd\u6570\u7c7b\u578b"},"9.14.2 \u6570\u636e\u5e93\u51fd\u6570\u7c7b\u578b"),Object(r.b)("p",null,"\u5728\u5173\u7cfb\u578b\u6570\u636e\u5e93\u4e2d\uff0c\u6570\u636e\u5e93\u51fd\u6570\u6709\u8fd9\u4e24\u79cd\u7c7b\u578b\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u6807\u91cf\u51fd\u6570"),"\uff1a\u53ea\u80fd\u8fd4\u56de\u5355\u4e2a\u503c"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u8868\u503c\u51fd\u6570"),"\uff1a\u53ea\u80fd\u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u96c6")),Object(r.b)("h2",{id:"9143-\u51fd\u6570\u7684\u4f7f\u7528"},"9.14.3 \u51fd\u6570\u7684\u4f7f\u7528"),Object(r.b)("h3",{id:"91431-\u6807\u91cf\u51fd\u6570\u8fd4\u56de-object"},"9.14.3.1 \u6807\u91cf\u51fd\u6570\u8fd4\u56de ",Object(r.b)("inlineCode",{parentName:"h3"},"object")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar value = _sqlRepository.SqlFunctionScalar("func_GetValue");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar value = _sqlExecuteProxy.GetValue(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar value = _personRepository.SqlFunctionScalar("func_GetValue");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar value = _repository.Sql().SqlFunctionScalar("func_GetValue");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u51fd\u6570\u540d\u6267\u884c\nvar value = "func_GetValue".SqlFunctionScalar();\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(r.b)("h3",{id:"91432-\u6807\u91cf\u51fd\u6570\u8fd4\u56de-t"},"9.14.3.2 \u6807\u91cf\u51fd\u6570\u8fd4\u56de ",Object(r.b)("inlineCode",{parentName:"h3"},"T")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar value = _sqlRepository.SqlFunctionScalar("func_GetValue");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar value = _sqlExecuteProxy.GetValue(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar value = _personRepository.SqlFunctionScalar("func_GetValue");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar value = _repository.Sql().SqlFunctionScalar("func_GetValue");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u51fd\u6570\u540d\u6267\u884c\nvar value = "func_GetValue".SqlFunctionScalar();\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(r.b)("h3",{id:"91433-\u8868\u503c\u51fd\u6570\u8fd4\u56de-datatable"},"9.14.3.3 \u8868\u503c\u51fd\u6570\u8fd4\u56de ",Object(r.b)("inlineCode",{parentName:"h3"},"DataTable")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar value = _sqlRepository.SqlFunctionQuery("func_GetTable");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar value = _sqlExecuteProxy.GetTable(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar value = _personRepository.SqlFunctionQuery("func_GetTable");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar value = _repository.Sql().SqlFunctionQuery("func_GetTable");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u51fd\u6570\u540d\u6267\u884c\nvar value = "func_GetTable".SqlFunctionQuery();\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(r.b)("h3",{id:"91434-\u8868\u503c\u51fd\u6570\u8fd4\u56de-listt"},"9.14.3.4 \u8868\u503c\u51fd\u6570\u8fd4\u56de ",Object(r.b)("inlineCode",{parentName:"h3"},"List")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// ISqlRepository \u65b9\u6cd5\nvar value = _sqlRepository.SqlFunctionQuery("func_GetTable");\n\n// ISqlDispatchProxy \u65b9\u5f0f\nvar value = _sqlExecuteProxy.GetTable(); // \u63a8\u8350\u65b9\u5f0f\n\n// \u5b9e\u4f53\u4ed3\u50a8\u65b9\u5f0f\nvar value = _personRepository.SqlFunctionQuery("func_GetTable");\n\n// IRepository \u975e\u6cdb\u578b\u65b9\u5f0f\nvar value = _repository.Sql().SqlFunctionQuery("func_GetTable");\n\n// \u53d8\u6001\u61d2\u4eba\u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u51fd\u6570\u540d\u6267\u884c\nvar value = "func_GetTable".SqlFunctionQuery();\n')),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5173\u4e8e\u5f02\u6b65")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u6bcf\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u90fd\u652f\u6301\u5f02\u6b65\u65b9\u5f0f\uff0c\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u5c31\u4e0d\u5217\u4e3e\u5f02\u6b65\u65b9\u5f0f\u4e86\u3002"))),Object(r.b)("h2",{id:"9144-\u5728-linq-\u4e2d\u4f7f\u7528-\u6807\u91cf\u51fd\u6570"},"9.14.4 \u5728 ",Object(r.b)("inlineCode",{parentName:"h2"},"Linq")," \u4e2d\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"h2"},"\u6807\u91cf\u51fd\u6570")),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u975e\u5e38\u7075\u6d3b\u7684\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Linq")," \u4e2d\u4f7f\u7528\u6807\u91cf\u51fd\u6570\u7684\u65b9\u6cd5\u3002\u5982\u679c\u50cf\u4f7f\u7528\u8fd9\u6837\u7684\u65b9\u5f0f\uff0c\u9700\u8981\u6ee1\u8db3\u4ee5\u4e0b\u4e24\u4e2a\u6761\u4ef6\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u6807\u91cf\u51fd\u6570\u5fc5\u987b\u5b9a\u4e49\u5728",Object(r.b)("strong",{parentName:"li"},"\u516c\u5f00\u9759\u6001\u7c7b"),"\u4e2d\uff0c\u4e14\u81ea\u5df1\u4e5f\u662f",Object(r.b)("strong",{parentName:"li"},"\u516c\u5f00\u9759\u6001\u65b9\u6cd5")),Object(r.b)("li",{parentName:"ul"},"\u8be5",Object(r.b)("strong",{parentName:"li"},"\u516c\u5f00\u9759\u6001\u65b9\u6cd5"),"\u5fc5\u987b\u8d34\u6709 ",Object(r.b)("inlineCode",{parentName:"li"},"[QueryableFunction]")," \u7279\u6027")),Object(r.b)("p",null,"\u793a\u4f8b\u5982\u4e0b\uff1a"),Object(r.b)("h3",{id:"91441-\u521b\u5efa\u6807\u91cf\u51fd\u6570"},"9.14.4.1 \u521b\u5efa\u6807\u91cf\u51fd\u6570"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql"}),"CREATE FUNCTION FN_GetId\n(\n @id INT\n)\nRETURNS INT\nAS\nBEGIN\n RETURN @id + 1;\nEND;\n")),Object(r.b)("h3",{id:"91442-\u521b\u5efa\u9759\u6001\u7c7b\u548c\u9759\u6001\u65b9\u6cd5"},"9.14.4.2 \u521b\u5efa\u9759\u6001\u7c7b\u548c\u9759\u6001\u65b9\u6cd5"),Object(r.b)("p",null,"\u521b\u5efa\u9759\u6001\u7c7b\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"p"},"QueryFunctions"),"\uff0c\u5c06\u8be5 ",Object(r.b)("inlineCode",{parentName:"p"},"\u6807\u91cf\u51fd\u6570")," \u653e\u5728\u9759\u6001\u7c7b\u4e2d\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1, 7, 10-11}","{1,":!0,"7,":!0,"10-11}":!0}),'using Fur.DatabaseAccessor;\nusing System;\n\nnamespace Fur.Application\n{\n // \u5fc5\u987b\u662f\u516c\u5f00\u9759\u6001\u7684\n public static class QueryFunctions\n {\n // \u5fc5\u987b\u662f\u9759\u6001\u65b9\u6cd5\n [QueryableFunction("FN_GetId", "dbo")] // \u914d\u7f6e\u6807\u91cf\u51fd\u6570\n public static int GetId(int id) => throw new NotSupportedException();\n }\n}\n')),Object(r.b)("h3",{id:"91443-\u5728-linq-\u4e2d\u4f7f\u7528"},"9.14.4.3 \u5728 ",Object(r.b)("inlineCode",{parentName:"h3"},"Linq")," \u4e2d\u4f7f\u7528"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"_personRepository.Where(u => u.Id > QueryFunctions.GetId(1)).ToList();\n")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql"}),"SELECT [p].[Id], [p].[Address], [p].[Age], [p].[CreatedTime], [p].[IsDeleted], [p].[Name], [p].[UpdatedTime]\nFROM [Person] AS [p]\nWHERE [p].[Id] > [dbo].[FN_GetId](1) // \ud83d\udca5 \u6ce8\u610f\u8fd9\u91cc\n")),Object(r.b)("img",{src:Object(b.a)("img/fn1.png")}),Object(r.b)("h2",{id:"9145-\u5728-linq-\u4e2d\u4f7f\u7528-\u8868\u503c\u51fd\u6570"},"9.14.5 \u5728 ",Object(r.b)("inlineCode",{parentName:"h2"},"Linq")," \u4e2d\u4f7f\u7528 ",Object(r.b)("inlineCode",{parentName:"h2"},"\u8868\u503c\u51fd\u6570")),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"EF Core 5.0")," \u7248\u672c\u652f\u6301\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Linq")," \u4e2d\u64cd\u4f5c ",Object(r.b)("inlineCode",{parentName:"p"},"\u8868\u503c\u51fd\u6570"),"\uff0c\u64cd\u4f5c\u6709\u70b9\u7c7b\u4f3c ",Object(r.b)("inlineCode",{parentName:"p"},"\u89c6\u56fe\u64cd\u4f5c")),Object(r.b)("p",null,"\u793a\u4f8b\u5982\u4e0b\uff1a"),Object(r.b)("h3",{id:"91451-\u521b\u5efa\u8868\u503c\u51fd\u6570"},"9.14.5.1 \u521b\u5efa\u8868\u503c\u51fd\u6570"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql"}),"CREATE FUNCTION dbo.GetPersons\n(\n @id INT\n)\nRETURNS TABLE\nAS\nRETURN\n(\n SELECT Id,\n Name,\n Age,\n Address\n FROM dbo.Person\n WHERE Id > @id\n);\n")),Object(r.b)("h3",{id:"91452-\u521b\u5efa\u8868\u503c\u51fd\u6570\u6a21\u578b"},"9.14.5.2 \u521b\u5efa\u8868\u503c\u51fd\u6570\u6a21\u578b"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"namespace Fur.Core\n{\n public class F_Person\n {\n /// \n /// \u4e3b\u952eId\n /// \n public int Id { get; set; }\n\n /// \n /// \u59d3\u540d\n /// \n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n\n /// \n /// \u4f4f\u5740\n /// \n public string Address { get; set; }\n }\n}\n")),Object(r.b)("h3",{id:"91453-\u8868\u503c\u51fd\u6570\u914d\u7f6e"},"9.14.5.3 \u8868\u503c\u51fd\u6570\u914d\u7f6e"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"DbContext")," \u7c7b\u4e2d\u5b9a\u4e49\u65b9\u6cd5\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{3,10,20-21}","{3,10,20-21}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\nusing System.Linq;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Sqlite3ConnectionString")]\n public class FurDbContext : AppDbContext\n {\n public IQueryable GetPersons(int id) => FromExpression(() => GetPersons(id));\n\n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n\n protected override void OnModelCreating(ModelBuilder modelBuilder)\n {\n base.OnModelCreating(modelBuilder);\n\n modelBuilder.Entity(typeof(F_Person)).HasNoKey();\n modelBuilder.HasDbFunction(() => GetPersons(default));\n }\n }\n}\n')),Object(r.b)("h3",{id:"91454-\u5728-linq-\u4e2d\u4f7f\u7528"},"9.14.5.4 \u5728 ",Object(r.b)("inlineCode",{parentName:"h3"},"Linq")," \u4e2d\u4f7f\u7528"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'IQueryable query = _repository.DynamicDbContext.GetPersons(1);\nvar result = query.Where(u => u.Name.Equals("Fur")).ToList();\n')),Object(r.b)("p",null,"\u6700\u7ec8\u751f\u6210 ",Object(r.b)("inlineCode",{parentName:"p"},"Sql")),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql"}),"SELECT [g].Id, [g].Name, [g].Age, [g].Address\nFROM dbo.GetPersons(1) AS [g]\nWHERE [g].Name == N'Fur';\n")),Object(r.b)("h2",{id:"9146-\u5728-ef-core-\u5185\u7f6e\u51fd\u6570"},"9.14.6 \u5728 ",Object(r.b)("inlineCode",{parentName:"h2"},"EF Core")," \u5185\u7f6e\u51fd\u6570"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"EF Core")," \u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u5f88\u591a\u5e38\u7528\u7684\u5185\u7f6e\u51fd\u6570\uff0c\u53ef\u4ee5\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Lambda")," \u6761\u4ef6\u4e2d\u4f7f\u7528\uff0c\u4e3b\u8981\u662f\u901a\u8fc7 EF.Functions \u8c03\u7528\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"_repository.Where(u => EF.Functions.DateDiffHour(u.CreatedDt, DateTime.Now) > 8).FirstOrDefault();\n")),Object(r.b)("p",null,"\u8fd9\u4e2a\u8bed\u53e5\u4f7f\u7528\u4e86 EF.Functions.DateDiffHour \u6700\u7ec8\u751f\u6210\u7684 Sql \u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql"}),"SELECT TOP(1) [a].*\nFROM [dbo].[TEST] AS [a]\nWHERE DATEDIFF(HOUR, [a].[CREATED_DT], GETDATE()) > 8\n")),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"EF Core")," \u5185\u7f6e\u51fd\u6570\u5c31\u4e0d\u4e00\u4e00\u5217\u51fa\u4e86\uff0c\u53ef\u4ee5\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"EF.Functions")," \u67e5\u770b\u66f4\u591a\uff0c\u5982\u679c\u4e0d\u80fd\u6ee1\u8db3\u81ea\u5df1\u7684\u9700\u6c42\uff0c\u90a3\u4e48\u53ef\u4ee5\u81ea\u5b9a\u4e49 ",Object(r.b)("inlineCode",{parentName:"p"},"Linq")," \u6807\u91cf\u51fd\u6570"),Object(r.b)("h2",{id:"9147-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.14.7 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}u.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return O}));var a=n(0),c=n.n(a);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function i(e){for(var t=1;t=0||(c[n]=e[n]);return c}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(c[n]=e[n])}return c}var o=c.a.createContext({}),d=function(e){var t=c.a.useContext(o),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},u=function(e){var t=d(e.components);return c.a.createElement(o.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return c.a.createElement(c.a.Fragment,{},t)}},p=c.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,r=e.originalType,b=e.parentName,o=l(e,["components","mdxType","originalType","parentName"]),u=d(n),p=a,O=u["".concat(b,".").concat(p)]||u[p]||s[p]||r;return n?c.a.createElement(O,i(i({ref:t},o),{},{components:n})):c.a.createElement(O,i({ref:t},o))}));function O(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var r=n.length,b=new Array(r);b[0]=p;var i={};for(var l in t)hasOwnProperty.call(t,l)&&(i[l]=t[l]);i.originalType=e,i.mdxType="string"==typeof e?e:a,b[1]=i;for(var o=2;o=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var u=o.a.createContext({}),l=function(e){var t=o.a.useContext(u),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},s=function(e){var t=l(e.components);return o.a.createElement(u.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},f=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,u=p(e,["components","mdxType","originalType","parentName"]),s=l(r),f=n,m=s["".concat(c,".").concat(f)]||s[f]||d[f]||a;return r?o.a.createElement(m,i(i({ref:t},u),{},{components:r})):o.a.createElement(m,i({ref:t},u))}));function m(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var a=r.length,c=new Array(a);c[0]=f;var i={};for(var p in t)hasOwnProperty.call(t,p)&&(i[p]=t[p]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var u=2;u=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=o.a.createContext({}),l=function(e){var r=o.a.useContext(p),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},s=function(e){var r=l(e.components);return o.a.createElement(p.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),s=l(t),d=n,m=s["".concat(c,".").concat(d)]||s[d]||f[d]||a;return t?o.a.createElement(m,i(i({ref:r},p),{},{components:t})):o.a.createElement(m,i({ref:r},p))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,c=new Array(a);c[0]=d;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var p=2;p0||b)&&r.a.createElement("footer",{className:"row margin-vert--lg"},w.length>0&&r.a.createElement("div",{className:"col"},r.a.createElement("strong",null,"Tags:"),w.map((function(e){var a=e.label,t=e.permalink;return r.a.createElement(i.a,{key:t,className:"margin-horiz--sm",to:t},a)}))),b&&r.a.createElement("div",{className:"col text--right"},r.a.createElement(i.a,{to:_.permalink,"aria-label":"Read more about "+P},r.a.createElement("strong",null,"Read More"))))))}}}]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([[56],{140:function(e,a,t){"use strict";t.r(a);var n=t(0),r=t.n(n),l=t(143),m=t(153),c=t(156),i=t(151);var o=function(e){var a=e.metadata,t=a.previousPage,n=a.nextPage;return r.a.createElement("nav",{className:"pagination-nav","aria-label":"Blog list page navigation"},r.a.createElement("div",{className:"pagination-nav__item"},t&&r.a.createElement(i.a,{className:"pagination-nav__link",to:t},r.a.createElement("h4",{className:"pagination-nav__label"},"\xab Newer Entries"))),r.a.createElement("div",{className:"pagination-nav__item pagination-nav__item--next"},n&&r.a.createElement(i.a,{className:"pagination-nav__link",to:n},r.a.createElement("h4",{className:"pagination-nav__label"},"Older Entries \xbb"))))};a.default=function(e){var a=e.metadata,t=e.items,n=Object(l.a)().siteConfig.title,i="/"===a.permalink?n:"Blog",s=a.blogDescription;return r.a.createElement(m.a,{title:i,description:s},r.a.createElement("div",{className:"container margin-vert--lg"},r.a.createElement("div",{className:"row"},r.a.createElement("main",{className:"col col--8 col--offset-2"},t.map((function(e){var a=e.content;return r.a.createElement(c.a,{key:a.metadata.permalink,frontMatter:a.frontMatter,metadata:a.metadata,truncated:a.metadata.truncated},r.a.createElement(a,null))})),r.a.createElement(o,{metadata:a})))))}},154:function(e,a,t){"use strict";var n=t(152);t.d(a,"a",(function(){return n.a}))},156:function(e,a,t){"use strict";var n=t(0),r=t.n(n),l=t(146),m=t(142),c=t(155),i=t(151),o=t(159),s=t(144),g=t(48),u=t.n(g),E=["January","February","March","April","May","June","July","August","September","October","November","December"];a.a=function(e){var a,t,n,g,v,d=e.children,p=e.frontMatter,_=e.metadata,b=e.truncated,h=e.isBlogPostPage,N=void 0!==h&&h,f=_.date,k=_.permalink,w=_.tags,y=_.readingTime,M=p.author,P=p.title,J=p.image,O=p.keywords,T=p.author_url||p.authorURL,j=p.author_title||p.authorTitle,x=p.author_image_url||p.authorImageURL,F=Object(s.a)(J,{absolute:!0});return r.a.createElement(r.a.Fragment,null,r.a.createElement(c.a,null,O&&O.length&&r.a.createElement("meta",{name:"keywords",content:O.join(",")}),J&&r.a.createElement("meta",{property:"og:image",content:F}),J&&r.a.createElement("meta",{property:"twitter:image",content:F}),J&&r.a.createElement("meta",{name:"twitter:image:alt",content:"Image for "+P})),r.a.createElement("article",{className:N?void 0:"margin-bottom--xl"},(a=N?"h1":"h2",t=f.substring(0,10).split("-"),n=t[0],g=E[parseInt(t[1],10)-1],v=parseInt(t[2],10),r.a.createElement("header",null,r.a.createElement(a,{className:Object(l.a)("margin-bottom--sm",u.a.blogPostTitle)},N?P:r.a.createElement(i.a,{to:k},P)),r.a.createElement("div",{className:"margin-vert--md"},r.a.createElement("time",{dateTime:f,className:u.a.blogPostDate},g," ",v,", ",n," ",y&&r.a.createElement(r.a.Fragment,null," \xb7 ",Math.ceil(y)," min read"))),r.a.createElement("div",{className:"avatar margin-vert--md"},x&&r.a.createElement("a",{className:"avatar__photo-link avatar__photo",href:T,target:"_blank",rel:"noreferrer noopener"},r.a.createElement("img",{src:x,alt:M})),r.a.createElement("div",{className:"avatar__intro"},M&&r.a.createElement(r.a.Fragment,null,r.a.createElement("h4",{className:"avatar__name"},r.a.createElement("a",{href:T,target:"_blank",rel:"noreferrer noopener"},M)),r.a.createElement("small",{className:"avatar__subtitle"},j)))))),r.a.createElement("section",{className:"markdown"},r.a.createElement(m.a,{components:o.a},d)),(w.length>0||b)&&r.a.createElement("footer",{className:"row margin-vert--lg"},w.length>0&&r.a.createElement("div",{className:"col"},r.a.createElement("strong",null,"Tags:"),w.map((function(e){var a=e.label,t=e.permalink;return r.a.createElement(i.a,{key:t,className:"margin-horiz--sm",to:t},a)}))),b&&r.a.createElement("div",{className:"col text--right"},r.a.createElement(i.a,{to:_.permalink,"aria-label":"Read more about "+P},r.a.createElement("strong",null,"Read More"))))))}}}]); \ No newline at end of file diff --git a/handbook/build/a74774ac.19465b58.js b/handbook/build/a74774ac.19465b58.js deleted file mode 100644 index 40c9c9672d0..00000000000 --- a/handbook/build/a74774ac.19465b58.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[54],{109:function(e,t,r){"use strict";r.r(t),r.d(t,"frontMatter",(function(){return i})),r.d(t,"metadata",(function(){return c})),r.d(t,"rightToc",(function(){return u})),r.d(t,"default",(function(){return p}));var n=r(2),o=r(6),a=(r(0),r(142)),i={id:"logging",title:"19. \u65e5\u5fd7\u8bb0\u5f55",sidebar_label:"19. \u65e5\u5fd7\u8bb0\u5f55"},c={unversionedId:"logging",id:"logging",isDocsHomePage:!1,title:"19. \u65e5\u5fd7\u8bb0\u5f55",source:"@site/docs\\logging.mdx",slug:"/logging",permalink:"/docs/logging",editUrl:"https://gitee.com/monksoul/Fur/tree/main/handbook/docs/logging.mdx",version:"current",sidebar_label:"19. \u65e5\u5fd7\u8bb0\u5f55",sidebar:"docs",previous:{title:"18. \u4e8b\u4ef6\u603b\u7ebf",permalink:"/docs/event-bus"},next:{title:"20. \u7f51\u7edc\u8bf7\u6c42",permalink:"/docs/http"}},u=[],l={rightToc:u};function p(e){var t=e.components,r=Object(o.a)(e,["components"]);return Object(a.b)("wrapper",Object(n.a)({},l,r,{components:t,mdxType:"MDXLayout"}))}p.isMDXComponent=!0},142:function(e,t,r){"use strict";r.d(t,"a",(function(){return s})),r.d(t,"b",(function(){return d}));var n=r(0),o=r.n(n);function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var l=o.a.createContext({}),p=function(e){var t=o.a.useContext(l),r=t;return e&&(r="function"==typeof e?e(t):c(c({},t),e)),r},s=function(e){var t=p(e.components);return o.a.createElement(l.Provider,{value:t},e.children)},f={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},g=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,a=e.originalType,i=e.parentName,l=u(e,["components","mdxType","originalType","parentName"]),s=p(r),g=n,d=s["".concat(i,".").concat(g)]||s[g]||f[g]||a;return r?o.a.createElement(d,c(c({ref:t},l),{},{components:r})):o.a.createElement(d,c({ref:t},l))}));function d(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var a=r.length,i=new Array(a);i[0]=g;var c={};for(var u in t)hasOwnProperty.call(t,u)&&(c[u]=t[u]);c.originalType=e,c.mdxType="string"==typeof e?e:n,i[1]=c;for(var l=2;l=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var l=o.a.createContext({}),p=function(e){var r=o.a.useContext(l),t=r;return e&&(t="function"==typeof e?e(r):c(c({},r),e)),t},s=function(e){var r=p(e.components);return o.a.createElement(l.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},g=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,i=e.parentName,l=u(e,["components","mdxType","originalType","parentName"]),s=p(t),g=n,d=s["".concat(i,".").concat(g)]||s[g]||f[g]||a;return t?o.a.createElement(d,c(c({ref:r},l),{},{components:t})):o.a.createElement(d,c({ref:r},l))}));function d(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,i=new Array(a);i[0]=g;var c={};for(var u in r)hasOwnProperty.call(r,u)&&(c[u]=r[u]);c.originalType=e,c.mdxType="string"==typeof e?e:n,i[1]=c;for(var l=2;lPerson",id:"92021-\u521b\u5efa\u5b9e\u4f53\u6a21\u578b-person",children:[]},{value:"9.20.2.2 \u6253\u5f00 \u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0",id:"92022-\u6253\u5f00-\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0",children:[]},{value:"9.20.2.3 \u5207\u6362\u9ed8\u8ba4\u9879\u76ee",id:"92023-\u5207\u6362\u9ed8\u8ba4\u9879\u76ee",children:[]},{value:"9.20.2.4 \u521b\u5efa\u6a21\u578b\u7248\u672c",id:"92024-\u521b\u5efa\u6a21\u578b\u7248\u672c",children:[]},{value:"9.20.2.5 \u66f4\u65b0\u5230\u6570\u636e\u5e93",id:"92025-\u66f4\u65b0\u5230\u6570\u636e\u5e93",children:[]}]},{value:"9.20.3 \u66f4\u65b0\u6a21\u578b",id:"9203-\u66f4\u65b0\u6a21\u578b",children:[]},{value:"9.20.4 \u5bfc\u51fa Sql",id:"9204-\u5bfc\u51fa-sql",children:[]},{value:"9.20.5 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9205-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],d={rightToc:s};function l(e){var t=e.components,n=Object(r.a)(e,["components"]);return Object(c.b)("wrapper",Object(a.a)({},d,n,{components:t,mdxType:"MDXLayout"}),Object(c.b)("h2",{id:"9201-\u6570\u636e\u5e93\u5f00\u53d1\u65b9\u5f0f"},"9.20.1 \u6570\u636e\u5e93\u5f00\u53d1\u65b9\u5f0f"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\u6765 ",Object(c.b)("strong",{parentName:"p"},"\u4fdd\u6301\u5b9e\u4f53\u6a21\u578b\u548c\u6570\u636e\u5e93\u67b6\u6784\u540c\u6b65"),"\u3002"),Object(c.b)("p",null,"\u81f3\u4e8e\u6211\u4eec\u5e94\u8be5\u9009\u7528\u54ea\u4e2a\u65b9\u6cd5\uff0c\u8bf7\u786e\u5b9a\u4f60\u662f\u5e0c\u671b\u4ee5\u5b9e\u4f53\u6a21\u578b\u4e3a\u51c6\u8fd8\u662f\u4ee5\u6570\u636e\u5e93\u4e3a\u51c6\uff1a"),Object(c.b)("ul",null,Object(c.b)("li",{parentName:"ul"},Object(c.b)("p",{parentName:"li"},"\u5982\u679c\u5e0c\u671b ",Object(c.b)("strong",{parentName:"p"},"\u4ee5\u5b9e\u4f53\u6a21\u578b\u4e3a\u51c6"),"\uff0c\u8bf7\u4f7f\u7528\u6b63\u5411\u5de5\u7a0b\uff08Code First\uff09\u3002 \u5bf9\u5b9e\u4f53\u6a21\u578b\u8fdb\u884c\u66f4\u6539\u65f6\uff0c\u6b64\u65b9\u6cd5\u4f1a\u4ee5\u589e\u91cf\u65b9\u5f0f\u5c06\u76f8\u5e94\u67b6\u6784\u66f4\u6539\u5e94\u7528\u5230\u6570\u636e\u5e93\uff0c\u4ee5\u4f7f\u6570\u636e\u5e93\u4fdd\u6301\u4e0e\u5b9e\u4f53\u6a21\u578b\u517c\u5bb9\u3002")),Object(c.b)("li",{parentName:"ul"},Object(c.b)("p",{parentName:"li"},"\u5982\u679c\u5e0c\u671b ",Object(c.b)("strong",{parentName:"p"},"\u4ee5\u6570\u636e\u5e93\u67b6\u6784\u4e3a\u51c6"),"\uff0c\u8bf7\u4f7f\u7528\u53cd\u5411\u5de5\u7a0b\uff08Database First\uff09\u3002 \u4f7f\u7528\u6b64\u65b9\u6cd5\uff0c\u53ef\u901a\u8fc7\u5c06\u6570\u636e\u5e93\u67b6\u6784\u53cd\u5411\u5de5\u7a0b\u5230\u5b9e\u4f53\u6a21\u578b\u6765\u751f\u6210\u76f8\u5e94\u7684\u5b9e\u4f53\u7c7b\u578b\u3002"))),Object(c.b)("p",null,"\u672c\u7ae0\u8282\u662f ",Object(c.b)("strong",{parentName:"p"},"\u6b63\u5411\u5de5\u7a0b\uff08Code First\uff09")," \u7684\u76f8\u5173\u5185\u5bb9\u3002"),Object(c.b)("h2",{id:"9202-\u64cd\u4f5c\u6307\u5357"},"9.20.2 \u64cd\u4f5c\u6307\u5357"),Object(c.b)("h3",{id:"92021-\u521b\u5efa\u5b9e\u4f53\u6a21\u578b-person"},"9.20.2.1 \u521b\u5efa\u5b9e\u4f53\u6a21\u578b ",Object(c.b)("inlineCode",{parentName:"h3"},"Person")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,6,8}","{1,6,8}":!0}),"using Fur.DatabaseAccessor;\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Core\n{\n public class Person : Entity\n {\n /// \n /// \u6784\u9020\u51fd\u6570\n /// \n public Person()\n {\n CreatedTime = DateTime.Now;\n IsDeleted = false;\n }\n\n /// \n /// \u59d3\u540d\n /// \n [MaxLength(32)]\n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n\n /// \n /// \u4f4f\u5740\n /// \n public string Address { get; set; }\n }\n}\n")),Object(c.b)("div",{className:"admonition admonition-important alert alert--info"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u5b9e\u4f53\u7ea6\u5b9a")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u6240\u6709\u6570\u636e\u5e93\u5b9e\u4f53\u5fc5\u987b\u76f4\u63a5\u6216\u95f4\u63a5\u7ee7\u627f ",Object(c.b)("inlineCode",{parentName:"p"},"IEntity")," \u63a5\u53e3\u3002"))),Object(c.b)("h3",{id:"92022-\u6253\u5f00-\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0"},"9.20.2.2 \u6253\u5f00 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0")),Object(c.b)("img",{src:Object(i.a)("img/dbfirst1.png")}),Object(c.b)("h3",{id:"92023-\u5207\u6362\u9ed8\u8ba4\u9879\u76ee"},"9.20.2.3 \u5207\u6362\u9ed8\u8ba4\u9879\u76ee"),Object(c.b)("p",null,"\u5c06 ",Object(c.b)("inlineCode",{parentName:"p"},"\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0")," \u9ed8\u8ba4\u9879\u76ee\u8bbe\u7f6e\u4e3a ",Object(c.b)("inlineCode",{parentName:"p"},"Fur.Database.Migrations")),Object(c.b)("img",{src:Object(i.a)("img/codefirst1.png")}),Object(c.b)("h3",{id:"92024-\u521b\u5efa\u6a21\u578b\u7248\u672c"},"9.20.2.4 \u521b\u5efa\u6a21\u578b\u7248\u672c"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Add-Migration v1.0.0\n")),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},Object(c.b)("strong",{parentName:"p"},"v1.0.0")," \u662f\u6b64\u5904\u6570\u636e\u5e93\u66f4\u6539\u7684\u7248\u672c\u53f7\uff0c\u53ef\u4ee5\u5199\u4efb\u4f55\u5b57\u7b26\u4e32\uff0c\u4f46\u63a8\u8350\u5199\u7248\u672c\u53f7\uff0c\u6bcf\u6b21 ",Object(c.b)("strong",{parentName:"p"},"+1"),"\u3002"))),Object(c.b)("p",null,"\u6700\u7ec8\u547d\u4ee4\u5982\u4e0b\uff1a"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"PM> Add-Migration v1.0.0\nBuild started...\nBuild succeeded.\nMicrosoft.EntityFrameworkCore.Model.Validation[10400]\n Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data, this mode should only be enabled during development.\nMicrosoft.EntityFrameworkCore.Infrastructure[10403]\n Entity Framework Core 5.0.0-rc.1.20451.13 initialized 'FurDbContext' using provider 'Microsoft.EntityFrameworkCore.Sqlite' with options: SensitiveDataLoggingEnabled DetailedErrorsEnabled MaxPoolSize=100 MigrationsAssembly=Fur.Database.Migrations\nTo undo this action, use Remove-Migration.\nPM>\n")),Object(c.b)("p",null,"\u751f\u6210\u6210\u529f\u540e\uff0c",Object(c.b)("inlineCode",{parentName:"p"},"Fur.Database.Migrations")," \u9879\u76ee\u4e0b\u4f1a\u65b0\u589e ",Object(c.b)("inlineCode",{parentName:"p"},"Migrations")," \u6587\u4ef6\u5939\uff08\u5982\u679c\u6ca1\u6709\uff09\uff0c\u540c\u65f6\u672c\u6b21\u7684\u67b6\u6784\u751f\u6210\u6587\u4ef6\uff0c\u5982\uff1a"),Object(c.b)("img",{src:Object(i.a)("img/codefirst3.png")}),Object(c.b)("h3",{id:"92025-\u66f4\u65b0\u5230\u6570\u636e\u5e93"},"9.20.2.5 \u66f4\u65b0\u5230\u6570\u636e\u5e93"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database\n")),Object(c.b)("p",null,"\u6267\u884c\u8be5\u547d\u4ee4\u540e\uff0c\u6570\u636e\u5e93\u5c31\u4f1a\u81ea\u52a8\u6839\u636e\u6a21\u578b\u751f\u6210\u5bf9\u4e8e\u7684\u8868\u3002"),Object(c.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u5982\u679c ",Object(c.b)("inlineCode",{parentName:"p"},"Update-Database")," \u540e\u9762\u5e26\u5b57\u7b26\u4e32\u53c2\u6570\uff0c\u5219\u4f1a\u81ea\u52a8\u8fd8\u539f\u6570\u636e\u5e93\u5230\u6307\u5b9a\u7248\u672c\uff0c\u5982\uff1a"),Object(c.b)("pre",{parentName:"div"},Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database v0.0.3\n")),Object(c.b)("p",{parentName:"div"},"\u5c06\u6570\u636e\u5e93\u8fd8\u539f\u5230 ",Object(c.b)("inlineCode",{parentName:"p"},"v0.0.3")," \u7248\u672c"))),Object(c.b)("h2",{id:"9203-\u66f4\u65b0\u6a21\u578b"},"9.20.3 \u66f4\u65b0\u6a21\u578b"),Object(c.b)("p",null,"\u5982\u679c\u6a21\u578b\u6539\u53d8\u4e86\uff0c\u91cd\u590d\u4e0a\u9762\u64cd\u4f5c\u5373\u53ef\uff0c\u5982\uff1a"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Add-Migration v1.0.1\n")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database\n")),Object(c.b)("h2",{id:"9204-\u5bfc\u51fa-sql"},"9.20.4 \u5bfc\u51fa ",Object(c.b)("inlineCode",{parentName:"h2"},"Sql")),Object(c.b)("p",null,"\u6709\u4e9b\u65f6\u5019\uff0c\u6211\u4eec\u6ca1\u6709\u76f4\u63a5\u66f4\u65b0\u6570\u636e\u5e93\u7684\u6743\u9650\uff0c\u6216\u8005\u6015\u51fa\u95ee\u9898\uff0c\u6211\u4eec\u90fd\u4f1a\u5148\u751f\u6210 ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u770b\u770b\uff0c\u8fd9\u65f6\u5019\u53ea\u9700\u8981\u901a\u8fc7 ",Object(c.b)("inlineCode",{parentName:"p"},"Script-Migration")," \u5bfc\u51fa\u5373\u53ef\uff0c\u5982\uff1a"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Script-Migration\n")),Object(c.b)("img",{src:Object(i.a)("img/codefirst2.png")}),Object(c.b)("h2",{id:"9205-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.20.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))),Object(c.b)("hr",null),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(c.b)("inlineCode",{parentName:"p"},"\u6b63\u5411\u5de5\u5382")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli"}),"EF Core - \u7ba1\u7406\u6570\u636e\u5e93\u67b6\u6784")," \u7ae0\u8282\u3002"))))}l.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return l})),n.d(t,"b",(function(){return u}));var a=n(0),r=n.n(a);function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=r.a.createContext({}),d=function(e){var t=r.a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},l=function(e){var t=d(e.components);return r.a.createElement(s.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},m=r.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,c=e.originalType,i=e.parentName,s=b(e,["components","mdxType","originalType","parentName"]),l=d(n),m=a,u=l["".concat(i,".").concat(m)]||l[m]||p[m]||c;return n?r.a.createElement(u,o(o({ref:t},s),{},{components:n})):r.a.createElement(u,o({ref:t},s))}));function u(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var c=n.length,i=new Array(c);i[0]=m;var o={};for(var b in t)hasOwnProperty.call(t,b)&&(o[b]=t[b]);o.originalType=e,o.mdxType="string"==typeof e?e:a,i[1]=o;for(var s=2;sPerson",id:"92021-\u521b\u5efa\u5b9e\u4f53\u6a21\u578b-person",children:[]},{value:"9.20.2.2 \u6253\u5f00 \u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0",id:"92022-\u6253\u5f00-\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0",children:[]},{value:"9.20.2.3 \u5207\u6362\u9ed8\u8ba4\u9879\u76ee",id:"92023-\u5207\u6362\u9ed8\u8ba4\u9879\u76ee",children:[]},{value:"9.20.2.4 \u521b\u5efa\u6a21\u578b\u7248\u672c",id:"92024-\u521b\u5efa\u6a21\u578b\u7248\u672c",children:[]},{value:"9.20.2.5 \u66f4\u65b0\u5230\u6570\u636e\u5e93",id:"92025-\u66f4\u65b0\u5230\u6570\u636e\u5e93",children:[]}]},{value:"9.20.3 \u66f4\u65b0\u6a21\u578b",id:"9203-\u66f4\u65b0\u6a21\u578b",children:[]},{value:"9.20.4 \u5bfc\u51fa Sql",id:"9204-\u5bfc\u51fa-sql",children:[]},{value:"9.20.5 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9205-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],d={rightToc:s};function l(e){var t=e.components,n=Object(r.a)(e,["components"]);return Object(c.b)("wrapper",Object(a.a)({},d,n,{components:t,mdxType:"MDXLayout"}),Object(c.b)("h2",{id:"9201-\u6570\u636e\u5e93\u5f00\u53d1\u65b9\u5f0f"},"9.20.1 \u6570\u636e\u5e93\u5f00\u53d1\u65b9\u5f0f"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\u6765 ",Object(c.b)("strong",{parentName:"p"},"\u4fdd\u6301\u5b9e\u4f53\u6a21\u578b\u548c\u6570\u636e\u5e93\u67b6\u6784\u540c\u6b65"),"\u3002"),Object(c.b)("p",null,"\u81f3\u4e8e\u6211\u4eec\u5e94\u8be5\u9009\u7528\u54ea\u4e2a\u65b9\u6cd5\uff0c\u8bf7\u786e\u5b9a\u4f60\u662f\u5e0c\u671b\u4ee5\u5b9e\u4f53\u6a21\u578b\u4e3a\u51c6\u8fd8\u662f\u4ee5\u6570\u636e\u5e93\u4e3a\u51c6\uff1a"),Object(c.b)("ul",null,Object(c.b)("li",{parentName:"ul"},Object(c.b)("p",{parentName:"li"},"\u5982\u679c\u5e0c\u671b ",Object(c.b)("strong",{parentName:"p"},"\u4ee5\u5b9e\u4f53\u6a21\u578b\u4e3a\u51c6"),"\uff0c\u8bf7\u4f7f\u7528\u6b63\u5411\u5de5\u7a0b\uff08Code First\uff09\u3002 \u5bf9\u5b9e\u4f53\u6a21\u578b\u8fdb\u884c\u66f4\u6539\u65f6\uff0c\u6b64\u65b9\u6cd5\u4f1a\u4ee5\u589e\u91cf\u65b9\u5f0f\u5c06\u76f8\u5e94\u67b6\u6784\u66f4\u6539\u5e94\u7528\u5230\u6570\u636e\u5e93\uff0c\u4ee5\u4f7f\u6570\u636e\u5e93\u4fdd\u6301\u4e0e\u5b9e\u4f53\u6a21\u578b\u517c\u5bb9\u3002")),Object(c.b)("li",{parentName:"ul"},Object(c.b)("p",{parentName:"li"},"\u5982\u679c\u5e0c\u671b ",Object(c.b)("strong",{parentName:"p"},"\u4ee5\u6570\u636e\u5e93\u67b6\u6784\u4e3a\u51c6"),"\uff0c\u8bf7\u4f7f\u7528\u53cd\u5411\u5de5\u7a0b\uff08Database First\uff09\u3002 \u4f7f\u7528\u6b64\u65b9\u6cd5\uff0c\u53ef\u901a\u8fc7\u5c06\u6570\u636e\u5e93\u67b6\u6784\u53cd\u5411\u5de5\u7a0b\u5230\u5b9e\u4f53\u6a21\u578b\u6765\u751f\u6210\u76f8\u5e94\u7684\u5b9e\u4f53\u7c7b\u578b\u3002"))),Object(c.b)("p",null,"\u672c\u7ae0\u8282\u662f ",Object(c.b)("strong",{parentName:"p"},"\u6b63\u5411\u5de5\u7a0b\uff08Code First\uff09")," \u7684\u76f8\u5173\u5185\u5bb9\u3002"),Object(c.b)("h2",{id:"9202-\u64cd\u4f5c\u6307\u5357"},"9.20.2 \u64cd\u4f5c\u6307\u5357"),Object(c.b)("h3",{id:"92021-\u521b\u5efa\u5b9e\u4f53\u6a21\u578b-person"},"9.20.2.1 \u521b\u5efa\u5b9e\u4f53\u6a21\u578b ",Object(c.b)("inlineCode",{parentName:"h3"},"Person")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,6,8}","{1,6,8}":!0}),"using Fur.DatabaseAccessor;\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Core\n{\n public class Person : Entity\n {\n /// \n /// \u6784\u9020\u51fd\u6570\n /// \n public Person()\n {\n CreatedTime = DateTime.Now;\n IsDeleted = false;\n }\n\n /// \n /// \u59d3\u540d\n /// \n [MaxLength(32)]\n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n\n /// \n /// \u4f4f\u5740\n /// \n public string Address { get; set; }\n }\n}\n")),Object(c.b)("div",{className:"admonition admonition-important alert alert--info"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u5b9e\u4f53\u7ea6\u5b9a")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u6240\u6709\u6570\u636e\u5e93\u5b9e\u4f53\u5fc5\u987b\u76f4\u63a5\u6216\u95f4\u63a5\u7ee7\u627f ",Object(c.b)("inlineCode",{parentName:"p"},"IEntity")," \u63a5\u53e3\u3002"))),Object(c.b)("h3",{id:"92022-\u6253\u5f00-\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0"},"9.20.2.2 \u6253\u5f00 ",Object(c.b)("inlineCode",{parentName:"h3"},"\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0")),Object(c.b)("img",{src:Object(i.a)("img/dbfirst1.png")}),Object(c.b)("h3",{id:"92023-\u5207\u6362\u9ed8\u8ba4\u9879\u76ee"},"9.20.2.3 \u5207\u6362\u9ed8\u8ba4\u9879\u76ee"),Object(c.b)("p",null,"\u5c06 ",Object(c.b)("inlineCode",{parentName:"p"},"\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0")," \u9ed8\u8ba4\u9879\u76ee\u8bbe\u7f6e\u4e3a ",Object(c.b)("inlineCode",{parentName:"p"},"Fur.Database.Migrations")),Object(c.b)("img",{src:Object(i.a)("img/codefirst1.png")}),Object(c.b)("h3",{id:"92024-\u521b\u5efa\u6a21\u578b\u7248\u672c"},"9.20.2.4 \u521b\u5efa\u6a21\u578b\u7248\u672c"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Add-Migration v1.0.0\n")),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},Object(c.b)("strong",{parentName:"p"},"v1.0.0")," \u662f\u6b64\u5904\u6570\u636e\u5e93\u66f4\u6539\u7684\u7248\u672c\u53f7\uff0c\u53ef\u4ee5\u5199\u4efb\u4f55\u5b57\u7b26\u4e32\uff0c\u4f46\u63a8\u8350\u5199\u7248\u672c\u53f7\uff0c\u6bcf\u6b21 ",Object(c.b)("strong",{parentName:"p"},"+1"),"\u3002"))),Object(c.b)("p",null,"\u6700\u7ec8\u547d\u4ee4\u5982\u4e0b\uff1a"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"PM> Add-Migration v1.0.0\nBuild started...\nBuild succeeded.\nMicrosoft.EntityFrameworkCore.Model.Validation[10400]\n Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data, this mode should only be enabled during development.\nMicrosoft.EntityFrameworkCore.Infrastructure[10403]\n Entity Framework Core 5.0.0-rc.1.20451.13 initialized 'FurDbContext' using provider 'Microsoft.EntityFrameworkCore.Sqlite' with options: SensitiveDataLoggingEnabled DetailedErrorsEnabled MaxPoolSize=100 MigrationsAssembly=Fur.Database.Migrations\nTo undo this action, use Remove-Migration.\nPM>\n")),Object(c.b)("p",null,"\u751f\u6210\u6210\u529f\u540e\uff0c",Object(c.b)("inlineCode",{parentName:"p"},"Fur.Database.Migrations")," \u9879\u76ee\u4e0b\u4f1a\u65b0\u589e ",Object(c.b)("inlineCode",{parentName:"p"},"Migrations")," \u6587\u4ef6\u5939\uff08\u5982\u679c\u6ca1\u6709\uff09\uff0c\u540c\u65f6\u672c\u6b21\u7684\u67b6\u6784\u751f\u6210\u6587\u4ef6\uff0c\u5982\uff1a"),Object(c.b)("img",{src:Object(i.a)("img/codefirst3.png")}),Object(c.b)("h3",{id:"92025-\u66f4\u65b0\u5230\u6570\u636e\u5e93"},"9.20.2.5 \u66f4\u65b0\u5230\u6570\u636e\u5e93"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database\n")),Object(c.b)("p",null,"\u6267\u884c\u8be5\u547d\u4ee4\u540e\uff0c\u6570\u636e\u5e93\u5c31\u4f1a\u81ea\u52a8\u6839\u636e\u6a21\u578b\u751f\u6210\u5bf9\u4e8e\u7684\u8868\u3002"),Object(c.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u5982\u679c ",Object(c.b)("inlineCode",{parentName:"p"},"Update-Database")," \u540e\u9762\u5e26\u5b57\u7b26\u4e32\u53c2\u6570\uff0c\u5219\u4f1a\u81ea\u52a8\u8fd8\u539f\u6570\u636e\u5e93\u5230\u6307\u5b9a\u7248\u672c\uff0c\u5982\uff1a"),Object(c.b)("pre",{parentName:"div"},Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database v0.0.3\n")),Object(c.b)("p",{parentName:"div"},"\u5c06\u6570\u636e\u5e93\u8fd8\u539f\u5230 ",Object(c.b)("inlineCode",{parentName:"p"},"v0.0.3")," \u7248\u672c"))),Object(c.b)("h2",{id:"9203-\u66f4\u65b0\u6a21\u578b"},"9.20.3 \u66f4\u65b0\u6a21\u578b"),Object(c.b)("p",null,"\u5982\u679c\u6a21\u578b\u6539\u53d8\u4e86\uff0c\u91cd\u590d\u4e0a\u9762\u64cd\u4f5c\u5373\u53ef\uff0c\u5982\uff1a"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Add-Migration v1.0.1\n")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Update-Database\n")),Object(c.b)("h2",{id:"9204-\u5bfc\u51fa-sql"},"9.20.4 \u5bfc\u51fa ",Object(c.b)("inlineCode",{parentName:"h2"},"Sql")),Object(c.b)("p",null,"\u6709\u4e9b\u65f6\u5019\uff0c\u6211\u4eec\u6ca1\u6709\u76f4\u63a5\u66f4\u65b0\u6570\u636e\u5e93\u7684\u6743\u9650\uff0c\u6216\u8005\u6015\u51fa\u95ee\u9898\uff0c\u6211\u4eec\u90fd\u4f1a\u5148\u751f\u6210 ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u770b\u770b\uff0c\u8fd9\u65f6\u5019\u53ea\u9700\u8981\u901a\u8fc7 ",Object(c.b)("inlineCode",{parentName:"p"},"Script-Migration")," \u5bfc\u51fa\u5373\u53ef\uff0c\u5982\uff1a"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-shell"}),"Script-Migration\n")),Object(c.b)("img",{src:Object(i.a)("img/codefirst2.png")}),Object(c.b)("h2",{id:"9205-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.20.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))),Object(c.b)("hr",null),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(c.b)("inlineCode",{parentName:"p"},"\u6b63\u5411\u5de5\u5382")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli"}),"EF Core - \u7ba1\u7406\u6570\u636e\u5e93\u67b6\u6784")," \u7ae0\u8282\u3002"))))}l.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return l})),n.d(t,"b",(function(){return u}));var a=n(0),r=n.n(a);function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=r.a.createContext({}),d=function(e){var t=r.a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},l=function(e){var t=d(e.components);return r.a.createElement(s.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},m=r.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,c=e.originalType,i=e.parentName,s=b(e,["components","mdxType","originalType","parentName"]),l=d(n),m=a,u=l["".concat(i,".").concat(m)]||l[m]||p[m]||c;return n?r.a.createElement(u,o(o({ref:t},s),{},{components:n})):r.a.createElement(u,o({ref:t},s))}));function u(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var c=n.length,i=new Array(c);i[0]=m;var o={};for(var b in t)hasOwnProperty.call(t,b)&&(o[b]=t[b]);o.originalType=e,o.mdxType="string"==typeof e?e:a,i[1]=o;for(var s=2;s=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var l=o.a.createContext({}),u=function(e){var r=o.a.useContext(l),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},s=function(e){var r=u(e.components);return o.a.createElement(l.Provider,{value:r},e.children)},d={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},f=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,l=p(e,["components","mdxType","originalType","parentName"]),s=u(t),f=n,y=s["".concat(c,".").concat(f)]||s[f]||d[f]||a;return t?o.a.createElement(y,i(i({ref:r},l),{},{components:t})):o.a.createElement(y,i({ref:r},l))}));function y(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,c=new Array(a);c[0]=f;var i={};for(var p in r)hasOwnProperty.call(r,p)&&(i[p]=r[p]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var l=2;l=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var u=o.a.createContext({}),l=function(e){var r=o.a.useContext(u),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},s=function(e){var r=l(e.components);return o.a.createElement(u.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,u=p(e,["components","mdxType","originalType","parentName"]),s=l(t),d=n,y=s["".concat(c,".").concat(d)]||s[d]||f[d]||a;return t?o.a.createElement(y,i(i({ref:r},u),{},{components:t})):o.a.createElement(y,i({ref:r},u))}));function y(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,c=new Array(a);c[0]=d;var i={};for(var p in r)hasOwnProperty.call(r,p)&&(i[p]=r[p]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var u=2;u=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var l=o.a.createContext({}),b=function(e){var t=o.a.useContext(l),r=t;return e&&(r="function"==typeof e?e(t):c(c({},t),e)),r},p=function(e){var t=b(e.components);return o.a.createElement(l.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},d=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,i=e.originalType,a=e.parentName,l=u(e,["components","mdxType","originalType","parentName"]),p=b(r),d=n,f=p["".concat(a,".").concat(d)]||p[d]||s[d]||i;return r?o.a.createElement(f,c(c({ref:t},l),{},{components:r})):o.a.createElement(f,c({ref:t},l))}));function f(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var i=r.length,a=new Array(i);a[0]=d;var c={};for(var u in t)hasOwnProperty.call(t,u)&&(c[u]=t[u]);c.originalType=e,c.mdxType="string"==typeof e?e:n,a[1]=c;for(var l=2;l=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var l=o.a.createContext({}),b=function(e){var t=o.a.useContext(l),r=t;return e&&(r="function"==typeof e?e(t):c(c({},t),e)),r},p=function(e){var t=b(e.components);return o.a.createElement(l.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},d=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,i=e.originalType,a=e.parentName,l=u(e,["components","mdxType","originalType","parentName"]),p=b(r),d=n,f=p["".concat(a,".").concat(d)]||p[d]||s[d]||i;return r?o.a.createElement(f,c(c({ref:t},l),{},{components:r})):o.a.createElement(f,c({ref:t},l))}));function f(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var i=r.length,a=new Array(i);a[0]=d;var c={};for(var u in t)hasOwnProperty.call(t,u)&&(c[u]=t[u]);c.originalType=e,c.mdxType="string"==typeof e?e:n,a[1]=c;for(var l=2;l")," \u5373\u53ef\u3002"),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u5b9a\u4e49\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{11}","{11}":!0}),'using Fur.DependencyInjection;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.DatabaseAccessor\n{\n /// \n /// \u9ed8\u8ba4\u5e94\u7528\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\n /// \n /// \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\n [NonBeScan]\n public abstract class AppDbContext : AppDbContext\n where TDbContext : DbContext\n {\n /// \n /// \u6784\u9020\u51fd\u6570\n /// \n /// \n public AppDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(o.b)("h2",{id:"925-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u652f\u6301\u5bf9\u8c61"},"9.2.5 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u652f\u6301\u5bf9\u8c61"),Object(o.b)("p",null,"\u76ee\u524d\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u652f\u6301\u4ee5\u4e0b\u591a\u4e2a\u5bf9\u8c61\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext"),"\uff1a\u6570\u636e\u4e0a\u4e0b\u6587"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IRepository"),": Sql \u64cd\u4f5c\u4ed3\u50a8"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Func"),"\uff1a\u4f9d\u8d56\u6ce8\u5165\u83b7\u53d6\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Entity")," \uff1a\u5b9e\u4f53\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"EntityBase"),"\uff1a\u5b9e\u4f53\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"EntityNotKey"),"\uff1a\u65e0\u952e\u5b9e\u4f53\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IEntitySeedData"),"\uff1a\u79cd\u5b50\u6570\u636e\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IEntityTypeBuilder"),"\uff1a\u5b9e\u4f53\u7c7b\u578b\u6784\u5efa\u5668"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IModelBuilderFilter"),"\uff1a\u6a21\u578b\u6784\u5efa\u7b5b\u9009\u5668"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"[QueryableFunction(DbContextLocators=Type[])]"),"\uff1a\u67e5\u8be2\u51fd\u6570")),Object(o.b)("h2",{id:"926-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.2.6 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return s}));var a=n(0),r=n.n(a);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var l=r.a.createContext({}),p=function(e){var t=r.a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):b(b({},t),e)),n},u=function(e){var t=p(e.components);return r.a.createElement(l.Provider,{value:t},e.children)},m={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},d=r.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,o=e.originalType,c=e.parentName,l=i(e,["components","mdxType","originalType","parentName"]),u=p(n),d=a,s=u["".concat(c,".").concat(d)]||u[d]||m[d]||o;return n?r.a.createElement(s,b(b({ref:t},l),{},{components:n})):r.a.createElement(s,b({ref:t},l))}));function s(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=n.length,c=new Array(o);c[0]=d;var b={};for(var i in t)hasOwnProperty.call(t,i)&&(b[i]=t[i]);b.originalType=e,b.mdxType="string"==typeof e?e:a,c[1]=b;for(var l=2;l")," \u5373\u53ef\u3002"),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"AppDbContext")," \u5b9a\u4e49\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{11}","{11}":!0}),'using Fur.DependencyInjection;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.DatabaseAccessor\n{\n /// \n /// \u9ed8\u8ba4\u5e94\u7528\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\n /// \n /// \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\n [NonBeScan]\n public abstract class AppDbContext : AppDbContext\n where TDbContext : DbContext\n {\n /// \n /// \u6784\u9020\u51fd\u6570\n /// \n /// \n public AppDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(o.b)("h2",{id:"925-\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u652f\u6301\u5bf9\u8c61"},"9.2.5 \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u652f\u6301\u5bf9\u8c61"),Object(o.b)("p",null,"\u76ee\u524d\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u652f\u6301\u4ee5\u4e0b\u591a\u4e2a\u5bf9\u8c61\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AppDbContext"),"\uff1a\u6570\u636e\u4e0a\u4e0b\u6587"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IRepository"),": Sql \u64cd\u4f5c\u4ed3\u50a8"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Func"),"\uff1a\u4f9d\u8d56\u6ce8\u5165\u83b7\u53d6\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Entity")," \uff1a\u5b9e\u4f53\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"EntityBase"),"\uff1a\u5b9e\u4f53\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"EntityNotKey"),"\uff1a\u65e0\u952e\u5b9e\u4f53\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IEntitySeedData"),"\uff1a\u79cd\u5b50\u6570\u636e\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IEntityTypeBuilder"),"\uff1a\u5b9e\u4f53\u7c7b\u578b\u6784\u5efa\u5668"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IModelBuilderFilter"),"\uff1a\u6a21\u578b\u6784\u5efa\u7b5b\u9009\u5668"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"[QueryableFunction(DbContextLocators=Type[])]"),"\uff1a\u67e5\u8be2\u51fd\u6570")),Object(o.b)("h2",{id:"926-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.2.6 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return s}));var a=n(0),r=n.n(a);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var l=r.a.createContext({}),p=function(e){var t=r.a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):b(b({},t),e)),n},u=function(e){var t=p(e.components);return r.a.createElement(l.Provider,{value:t},e.children)},m={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},d=r.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,o=e.originalType,c=e.parentName,l=i(e,["components","mdxType","originalType","parentName"]),u=p(n),d=a,s=u["".concat(c,".").concat(d)]||u[d]||m[d]||o;return n?r.a.createElement(s,b(b({ref:t},l),{},{components:n})):r.a.createElement(s,b({ref:t},l))}));function s(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=n.length,c=new Array(o);c[0]=d;var b={};for(var i in t)hasOwnProperty.call(t,i)&&(b[i]=t[i]);b.originalType=e,b.mdxType="string"==typeof e?e:a,c[1]=b;for(var l=2;l -Blog | Fur - - - - - - - - - +Blog | Fur + + + + + + + + +
-

Fur 介绍

dotnet中国

dotnet中国

为中国 .NET 开发者提供优质的资讯和技术分享。

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

- - - - - - - - - +

Fur 介绍

dotnet中国

dotnet中国

为中国 .NET 开发者提供优质的资讯和技术分享。

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

+ + + + + + + + + \ No newline at end of file diff --git a/handbook/build/blog/tags/fur/index.html b/handbook/build/blog/tags/fur/index.html index 39e777f3fd6..0a268b9bd00 100644 --- a/handbook/build/blog/tags/fur/index.html +++ b/handbook/build/blog/tags/fur/index.html @@ -4,28 +4,28 @@ -Posts tagged "fur" | Fur - - - - - - - - - +Posts tagged "fur" | Fur + + + + + + + + +
-

1 post tagged with "fur"

View All Tags

Fur 介绍

dotnet中国

dotnet中国

为中国 .NET 开发者提供优质的资讯和技术分享。

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

- - - - - - - - - +

1 post tagged with "fur"

View All Tags

Fur 介绍

dotnet中国

dotnet中国

为中国 .NET 开发者提供优质的资讯和技术分享。

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

+ + + + + + + + + \ No newline at end of file diff --git a/handbook/build/blog/tags/furos/index.html b/handbook/build/blog/tags/furos/index.html index dbbf384ada9..745f2f1becf 100644 --- a/handbook/build/blog/tags/furos/index.html +++ b/handbook/build/blog/tags/furos/index.html @@ -4,28 +4,28 @@ -Posts tagged "furos" | Fur - - - - - - - - - +Posts tagged "furos" | Fur + + + + + + + + +
-

1 post tagged with "furos"

View All Tags

Fur 介绍

dotnet中国

dotnet中国

为中国 .NET 开发者提供优质的资讯和技术分享。

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

- - - - - - - - - +

1 post tagged with "furos"

View All Tags

Fur 介绍

dotnet中国

dotnet中国

为中国 .NET 开发者提供优质的资讯和技术分享。

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

+ + + + + + + + + \ No newline at end of file diff --git a/handbook/build/blog/tags/index.html b/handbook/build/blog/tags/index.html index cb39023bc97..3fed0179192 100644 --- a/handbook/build/blog/tags/index.html +++ b/handbook/build/blog/tags/index.html @@ -4,24 +4,24 @@ -Tags | Fur - - - - - - - +Tags | Fur + + + + + + + - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/handbook/build/blog/tags/net-5/index.html b/handbook/build/blog/tags/net-5/index.html index a0b17c7d0a5..62f4eb961ec 100644 --- a/handbook/build/blog/tags/net-5/index.html +++ b/handbook/build/blog/tags/net-5/index.html @@ -4,28 +4,28 @@ -Posts tagged ".net5" | Fur - - - - - - - - - +Posts tagged ".net5" | Fur + + + + + + + + +
-

1 post tagged with ".net5"

View All Tags

Fur 介绍

dotnet中国

dotnet中国

为中国 .NET 开发者提供优质的资讯和技术分享。

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

- - - - - - - - - +

1 post tagged with ".net5"

View All Tags

Fur 介绍

dotnet中国

dotnet中国

为中国 .NET 开发者提供优质的资讯和技术分享。

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

+ + + + + + + + + \ No newline at end of file diff --git a/handbook/build/blog/tags/net/index.html b/handbook/build/blog/tags/net/index.html index bfa678c92df..c64f64b8c96 100644 --- a/handbook/build/blog/tags/net/index.html +++ b/handbook/build/blog/tags/net/index.html @@ -4,28 +4,28 @@ -Posts tagged ".net" | Fur - - - - - - - - - +Posts tagged ".net" | Fur + + + + + + + + +
-

1 post tagged with ".net"

View All Tags

Fur 介绍

dotnet中国

dotnet中国

为中国 .NET 开发者提供优质的资讯和技术分享。

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

- - - - - - - - - +

1 post tagged with ".net"

View All Tags

Fur 介绍

dotnet中国

dotnet中国

为中国 .NET 开发者提供优质的资讯和技术分享。

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

+ + + + + + + + + \ No newline at end of file diff --git a/handbook/build/blog/tags/netcore/index.html b/handbook/build/blog/tags/netcore/index.html index 959db2ca8db..3cb8faf79b0 100644 --- a/handbook/build/blog/tags/netcore/index.html +++ b/handbook/build/blog/tags/netcore/index.html @@ -4,28 +4,28 @@ -Posts tagged ".netcore" | Fur - - - - - - - - - +Posts tagged ".netcore" | Fur + + + + + + + + +
-

1 post tagged with ".netcore"

View All Tags

Fur 介绍

dotnet中国

dotnet中国

为中国 .NET 开发者提供优质的资讯和技术分享。

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

- - - - - - - - - +

1 post tagged with ".netcore"

View All Tags

Fur 介绍

dotnet中国

dotnet中国

为中国 .NET 开发者提供优质的资讯和技术分享。

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

+ + + + + + + + + \ No newline at end of file diff --git a/handbook/build/blog/welcome/index.html b/handbook/build/blog/welcome/index.html index 2a4400f7602..aa8aee0efa8 100644 --- a/handbook/build/blog/welcome/index.html +++ b/handbook/build/blog/welcome/index.html @@ -4,26 +4,26 @@ -Fur 介绍 | Fur - - - - - - - - +Fur 介绍 | Fur + + + + + + + +
-

Fur 介绍

dotnet中国

dotnet中国

为中国 .NET 开发者提供优质的资讯和技术分享。

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

🌭 开源地址

🍿 Docker 镜像

  • Docker Hub 线上镜像
docker run --name fur -p 5000:80 monksoul/fur:v1.0.0-2020.10.14
  • 手动 打包镜像

打开 CMD/Shell/PowerShell 进入 Fur 项目根目录打包 Fur 镜像:

docker build -t fur:v1.0.0-2020.10.14 .

打包成功后,直接 docker run

docker run --name fur -p 5000:80 fur:v1.0.0-2020.10.14

🥞 架构设计

正在整理中...

🥝 功能模块

🥐 框架依赖

Fur 为了追求极速入门,极致性能,尽可能的不使用或减少第三方依赖。目前 Fur 仅集成了以下三个依赖:

麻雀虽小五脏俱全。Fur 即使只集成了这三个依赖,但是主流的 依赖注入/控制反转AOP 面向切面编程,事件总线数据验证数据库操作 等等一个都不少。

🥗 环境要求

  • Visual Studio 2019 Preview 16.8 +
  • .NET 5 SDK +
  • .Net Standard 2.1 +

🥪 支持平台

  • 运行环境
    • Windows
    • Linux
    • MacOS
    • Docker/K8S/K3S/Rancher
    • Xamarin/MAUI
  • 数据库
    • SqlServer
    • Sqlite
    • Azure Cosmos
    • MySql
    • PostgreSQL
    • InMemoryDatabase
    • Oracle
    • Firebird
    • 达梦数据库
  • 应用部署
    • Kestrel
    • Nginx
    • Jexus
    • IIS
    • Apache
    • PM2
    • Supervisor
    • 单文件
    • 容器(Docker/K8S/K3S/Rancher)

🍖 关于性能

Fur 目前采用 Visual Studio 2019 Preview 16.8 自带性能测试和 JMeter 进行测试,由于篇幅有限,只贴部分测试图,测试结果如下:


🍚 关于作者

一个拥有 12 年开发经验 .NETer。喜欢分享,喜欢新技术,在互联网多个技术领域皆有涉猎。

🍤 项目成员

🎈 欢迎更多的开发者加入 Fur 大家庭。

🍝 他们都在用

  • 百签科技(广东)有限公司
  • 码为科技(广州)有限公司
  • 广州启顺国际货运代理有限公司
  • 森丰供应链服务(广州)有限公司
  • 中山赢友网络科技有限公司
  • 中山模思软件科技有限公司
  • 珠海市恒泰新软件有限责任公司
  • 珠海思诺锐创软件有限公司
  • 深圳市易胜科技有限公司
  • 重庆虫儿飞科技有限公司
  • 重庆林木森科技有限公司
  • 深圳市品立方科技有限公司

如果您的项目使用到 Fur 开发,可以告诉我们。

🍻 贡献代码

Fur 遵循 Apache-2.0 开源协议,欢迎大家提交 PRIssue

如果要为项目做出贡献,请查看贡献指南。

🍍 捐赠列表

注:排序按捐赠顺序书写

捐赠人昵称捐赠金额(元)附语
🤴 爱吃油麦菜100感谢您的开源项目!
👳‍♂️ 麦壳饼200感谢您的开源项目!
👨 Sun100感谢您的开源项目!
👶 d61761720感谢您的开源项目!
👦 Diqiguoji00816.66见贤思齐
👲 nodyang100感谢您的开源项目!
👳‍♀️ mictxd100吹过的牛都实现。
🧓 欧流全10希望将来超越 Spring
👨‍⚕️ lionkon10...看了框架感觉拿来学习是很不错的...
😤 好人!10...Nice 的小僧,我们的 dotnetchina 马上火起来了...
😮 木木 Woody10感谢您的开源项目!

非常感谢您们的支持,正是因为您们,中国开源才可以越走越远,Fur 越走越远。

🥔 QQ 交流群

🧆 友情链接

👉 Fur 👉 SqlSugar 👉 Layx 👉 t-io 👉 ThinkPHP 👉 Hutool 👉 BootstrapAdmin 👉 BootstrapBlazor

- - - - - - - - +

Fur 介绍

dotnet中国

dotnet中国

为中国 .NET 开发者提供优质的资讯和技术分享。

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

🌭 开源地址

🍿 Docker 镜像

  • Docker Hub 线上镜像
docker run --name fur -p 5000:80 monksoul/fur:v1.0.0-2020.10.14
  • 手动 打包镜像

打开 CMD/Shell/PowerShell 进入 Fur 项目根目录打包 Fur 镜像:

docker build -t fur:v1.0.0-2020.10.14 .

打包成功后,直接 docker run

docker run --name fur -p 5000:80 fur:v1.0.0-2020.10.14

🥞 架构设计

正在整理中...

🥝 功能模块

🥐 框架依赖

Fur 为了追求极速入门,极致性能,尽可能的不使用或减少第三方依赖。目前 Fur 仅集成了以下三个依赖:

麻雀虽小五脏俱全。Fur 即使只集成了这三个依赖,但是主流的 依赖注入/控制反转AOP 面向切面编程,事件总线数据验证数据库操作 等等一个都不少。

🥗 环境要求

  • Visual Studio 2019 Preview 16.8 +
  • .NET 5 SDK +
  • .Net Standard 2.1 +

🥪 支持平台

  • 运行环境
    • Windows
    • Linux
    • MacOS
    • Docker/K8S/K3S/Rancher
    • Xamarin/MAUI
  • 数据库
    • SqlServer
    • Sqlite
    • Azure Cosmos
    • MySql
    • PostgreSQL
    • InMemoryDatabase
    • Oracle
    • Firebird
    • 达梦数据库
  • 应用部署
    • Kestrel
    • Nginx
    • Jexus
    • IIS
    • Apache
    • PM2
    • Supervisor
    • 单文件
    • 容器(Docker/K8S/K3S/Rancher)

🍖 关于性能

Fur 目前采用 Visual Studio 2019 Preview 16.8 自带性能测试和 JMeter 进行测试,由于篇幅有限,只贴部分测试图,测试结果如下:


🍚 关于作者

一个拥有 12 年开发经验 .NETer。喜欢分享,喜欢新技术,在互联网多个技术领域皆有涉猎。

🍤 项目成员

🎈 欢迎更多的开发者加入 Fur 大家庭。

🍝 他们都在用

  • 百签科技(广东)有限公司
  • 码为科技(广州)有限公司
  • 广州启顺国际货运代理有限公司
  • 森丰供应链服务(广州)有限公司
  • 中山赢友网络科技有限公司
  • 中山模思软件科技有限公司
  • 珠海市恒泰新软件有限责任公司
  • 珠海思诺锐创软件有限公司
  • 深圳市易胜科技有限公司
  • 重庆虫儿飞科技有限公司
  • 重庆林木森科技有限公司
  • 深圳市品立方科技有限公司

如果您的项目使用到 Fur 开发,可以告诉我们。

🍻 贡献代码

Fur 遵循 Apache-2.0 开源协议,欢迎大家提交 PRIssue

如果要为项目做出贡献,请查看贡献指南。

🍍 捐赠列表

注:排序按捐赠顺序书写

捐赠人昵称捐赠金额(元)附语
🤴 爱吃油麦菜100感谢您的开源项目!
👳‍♂️ 麦壳饼200感谢您的开源项目!
👨 Sun100感谢您的开源项目!
👶 d61761720感谢您的开源项目!
👦 Diqiguoji00816.66见贤思齐
👲 nodyang100感谢您的开源项目!
👳‍♀️ mictxd100吹过的牛都实现。
🧓 欧流全10希望将来超越 Spring
👨‍⚕️ lionkon10...看了框架感觉拿来学习是很不错的...
😤 好人!10...Nice 的小僧,我们的 dotnetchina 马上火起来了...
😮 木木 Woody10感谢您的开源项目!

非常感谢您们的支持,正是因为您们,中国开源才可以越走越远,Fur 越走越远。

🥔 QQ 交流群

🧆 友情链接

👉 Fur 👉 SqlSugar 👉 Layx 👉 t-io 👉 ThinkPHP 👉 Hutool 👉 BootstrapAdmin 👉 BootstrapBlazor

+ + + + + + + + \ No newline at end of file diff --git a/handbook/build/c456980b.530a8035.js b/handbook/build/c456980b.530a8035.js deleted file mode 100644 index 52ac2c1d4b7..00000000000 --- a/handbook/build/c456980b.530a8035.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[59],{114:function(e,r,t){"use strict";t.r(r),t.d(r,"frontMatter",(function(){return c})),t.d(r,"metadata",(function(){return i})),t.d(r,"rightToc",(function(){return u})),t.d(r,"default",(function(){return l}));var n=t(2),o=t(6),a=(t(0),t(142)),c={id:"performance",title:"27.2 \u6027\u80fd\u6d4b\u8bd5",sidebar_label:"27.2 \u6027\u80fd\u6d4b\u8bd5"},i={unversionedId:"performance",id:"performance",isDocsHomePage:!1,title:"27.2 \u6027\u80fd\u6d4b\u8bd5",source:"@site/docs\\performance.mdx",slug:"/performance",permalink:"/docs/performance",editUrl:"https://gitee.com/monksoul/Fur/tree/main/handbook/docs/performance.mdx",version:"current",sidebar_label:"27.2 \u6027\u80fd\u6d4b\u8bd5",sidebar:"docs",previous:{title:"27.1 \u5355\u5143\u6d4b\u8bd5",permalink:"/docs/unittest"},next:{title:"28. \u8d21\u732e\u6307\u5357",permalink:"/docs/contribute"}},u=[],p={rightToc:u};function l(e){var r=e.components,t=Object(o.a)(e,["components"]);return Object(a.b)("wrapper",Object(n.a)({},p,t,{components:r,mdxType:"MDXLayout"}))}l.isMDXComponent=!0},142:function(e,r,t){"use strict";t.d(r,"a",(function(){return f})),t.d(r,"b",(function(){return d}));var n=t(0),o=t.n(n);function a(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function i(e){for(var r=1;r=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=o.a.createContext({}),l=function(e){var r=o.a.useContext(p),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},f=function(e){var r=l(e.components);return o.a.createElement(p.Provider,{value:r},e.children)},s={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},m=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),f=l(t),m=n,d=f["".concat(c,".").concat(m)]||f[m]||s[m]||a;return t?o.a.createElement(d,i(i({ref:r},p),{},{components:t})):o.a.createElement(d,i({ref:r},p))}));function d(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,c=new Array(a);c[0]=m;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var p=2;p=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=o.a.createContext({}),l=function(e){var r=o.a.useContext(p),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},f=function(e){var r=l(e.components);return o.a.createElement(p.Provider,{value:r},e.children)},s={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},m=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),f=l(t),m=n,d=f["".concat(c,".").concat(m)]||f[m]||s[m]||a;return t?o.a.createElement(d,i(i({ref:r},p),{},{components:t})):o.a.createElement(d,i({ref:r},p))}));function d(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,c=new Array(a);c[0]=m;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var p=2;p=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=o.a.createContext({}),l=function(e){var r=o.a.useContext(p),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},s=function(e){var r=l(e.components);return o.a.createElement(p.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),s=l(t),d=n,m=s["".concat(c,".").concat(d)]||s[d]||f[d]||a;return t?o.a.createElement(m,i(i({ref:r},p),{},{components:t})):o.a.createElement(m,i({ref:r},p))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,c=new Array(a);c[0]=d;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var p=2;p=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=o.a.createContext({}),l=function(e){var r=o.a.useContext(p),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},s=function(e){var r=l(e.components);return o.a.createElement(p.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),s=l(t),d=n,m=s["".concat(c,".").concat(d)]||s[d]||f[d]||a;return t?o.a.createElement(m,i(i({ref:r},p),{},{components:t})):o.a.createElement(m,i({ref:r},p))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,c=new Array(a);c[0]=d;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var p=2;p0||f)&&r.a.createElement("footer",{className:"row margin-vert--lg"},w.length>0&&r.a.createElement("div",{className:"col"},r.a.createElement("strong",null,"Tags:"),w.map((function(e){var a=e.label,t=e.permalink;return r.a.createElement(c.a,{key:t,className:"margin-horiz--sm",to:t},a)}))),f&&r.a.createElement("div",{className:"col text--right"},r.a.createElement(c.a,{to:p.permalink,"aria-label":"Read more about "+x},r.a.createElement("strong",null,"Read More"))))))}},162:function(e,a,t){"use strict";var n=t(0),r=t.n(n);var l=function(e,a,t){var r=Object(n.useState)(void 0),l=r[0],m=r[1];Object(n.useEffect)((function(){var n,r;function i(){var i=function(){var e=0,a=null;for(n=document.getElementsByClassName("anchor");e=0&&l<=t&&(a=r),e+=1}return a}();if(i){var c=0,o=!1;for(r=document.getElementsByClassName(e);c0||f)&&r.a.createElement("footer",{className:"row margin-vert--lg"},w.length>0&&r.a.createElement("div",{className:"col"},r.a.createElement("strong",null,"Tags:"),w.map((function(e){var a=e.label,t=e.permalink;return r.a.createElement(c.a,{key:t,className:"margin-horiz--sm",to:t},a)}))),f&&r.a.createElement("div",{className:"col text--right"},r.a.createElement(c.a,{to:p.permalink,"aria-label":"Read more about "+x},r.a.createElement("strong",null,"Read More"))))))}},162:function(e,a,t){"use strict";var n=t(0),r=t.n(n);var l=function(e,a,t){var r=Object(n.useState)(void 0),l=r[0],m=r[1];Object(n.useEffect)((function(){var n,r;function i(){var i=function(){var e=0,a=null;for(n=document.getElementsByClassName("anchor");e=0&&l<=t&&(a=r),e+=1}return a}();if(i){var c=0,o=!1;for(r=document.getElementsByClassName(e);c=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var u=a.a.createContext({}),p=function(e){var t=a.a.useContext(u),r=t;return e&&(r="function"==typeof e?e(t):b(b({},t),e)),r},l=function(e){var t=p(e.components);return a.a.createElement(u.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},m=a.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,o=e.originalType,c=e.parentName,u=i(e,["components","mdxType","originalType","parentName"]),l=p(r),m=n,O=l["".concat(c,".").concat(m)]||l[m]||s[m]||o;return r?a.a.createElement(O,b(b({ref:t},u),{},{components:r})):a.a.createElement(O,b({ref:t},u))}));function O(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var o=r.length,c=new Array(o);c[0]=m;var b={};for(var i in t)hasOwnProperty.call(t,i)&&(b[i]=t[i]);b.originalType=e,b.mdxType="string"==typeof e?e:n,c[1]=b;for(var u=2;u=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var p=a.a.createContext({}),u=function(e){var t=a.a.useContext(p),r=t;return e&&(r="function"==typeof e?e(t):b(b({},t),e)),r},l=function(e){var t=u(e.components);return a.a.createElement(p.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},m=a.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,o=e.originalType,c=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),l=u(r),m=n,O=l["".concat(c,".").concat(m)]||l[m]||s[m]||o;return r?a.a.createElement(O,b(b({ref:t},p),{},{components:r})):a.a.createElement(O,b({ref:t},p))}));function O(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var o=r.length,c=new Array(o);c[0]=m;var b={};for(var i in t)hasOwnProperty.call(t,i)&&(b[i]=t[i]);b.originalType=e,b.mdxType="string"==typeof e?e:n,c[1]=b;for(var p=2;p[FakeDelete] \u6807\u8bb0",id:"9881-\u6dfb\u52a0-fakedelete-\u6807\u8bb0",children:[]},{value:"9.8.8.2 \u5047\u5220\u9664\u4f7f\u7528",id:"9882-\u5047\u5220\u9664\u4f7f\u7528",children:[]}]},{value:"9.8.9 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"989-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],l={rightToc:s};function b(e){var t=e.components,n=Object(r.a)(e,["components"]);return Object(c.b)("wrapper",Object(a.a)({},l,n,{components:t,mdxType:"MDXLayout"}),Object(c.b)("h2",{id:"981-\u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.8.1 \u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.Delete(user);\n\n// \u793a\u4f8b\u4e8c\nuser.Delete();\n\n// \u793a\u4f8b\u4e09\nrepository.ChangeEntityState(user, EntityState.Deleted);\n\n// \u793a\u4f8b\u56db\nrepository.Entities.Remove(user);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.DeleteAsync(user);\n\n// \u793a\u4f8b\u4e8c\nawait user.DeleteAsync();\n")),Object(c.b)("h2",{id:"982-\u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.8.2 \u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.DeleteNow(user);\n\n// \u793a\u4f8b\u4e8c\nuser.DeleteNow();\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.DeleteNowAsync(user);\n\n// \u793a\u4f8b\u4e8c\nawait user.DeleteNowAsync();\n")),Object(c.b)("h2",{id:"983-\u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.8.3 \u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.Delete(1);\n\n// \u793a\u4f8b\u4e8c\nuser.Delete(1);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.DeleteAsync(1);\n\n// \u793a\u4f8b\u4e8c\nawait user.DeleteAsync(1);\n")),Object(c.b)("h2",{id:"984-\u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.8.4 \u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.DeleteNow(1);\n\n// \u793a\u4f8b\u4e8c\nuser.DeleteNow(1);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.DeleteNowAsync(1);\n\n// \u793a\u4f8b\u4e8c\nawait user.DeleteNowAsync(1);\n")),Object(c.b)("h2",{id:"985-\u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.8.5 \u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.DeleteExists(1);\n\n// \u793a\u4f8b\u4e8c\nuser.DeleteExists(1);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.DeleteExistsAsync(1);\n\n// \u793a\u4f8b\u4e8c\nawait user.DeleteExistsAsync(1);\n")),Object(c.b)("h2",{id:"986-\u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.8.6 \u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.DeleteExistsNow(1);\n\n// \u793a\u4f8b\u4e8c\nuser.DeleteExistsNow(1);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.DeleteExistsNowAsync(1);\n\n// \u793a\u4f8b\u4e8c\nawait user.DeleteExistsNowAsync(1);\n")),Object(c.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u6240\u6709\u5e26 ",Object(c.b)("inlineCode",{parentName:"p"},"Now")," \u7ed3\u5c3e\u7684\u8868\u793a\u7acb\u5373\u63d0\u4ea4\u5230\u6570\u636e\u5e93\uff0c\u4e5f\u5c31\u662f\u7acb\u5373\u8c03\u7528 ",Object(c.b)("inlineCode",{parentName:"p"},"SaveChanges")," \u6216 ",Object(c.b)("inlineCode",{parentName:"p"},"SaveChangesAsync"),"\u3002"))),Object(c.b)("h2",{id:"988-\u5047\u5220\u9664\u8f6f\u5220\u9664"},"9.8.8 \u5047\u5220\u9664/\u8f6f\u5220\u9664"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u53ef\u4ee5\u901a\u8fc7 ",Object(c.b)("inlineCode",{parentName:"p"},"[FakeDelete]")," \u7279\u6027\u6807\u8bb0\u5047\u5220\u9664\u7279\u6027\uff0c\u5982\uff1a"),Object(c.b)("h3",{id:"9881-\u6dfb\u52a0-fakedelete-\u6807\u8bb0"},"9.8.8.1 \u6dfb\u52a0 ",Object(c.b)("inlineCode",{parentName:"h3"},"[FakeDelete]")," \u6807\u8bb0"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{3}","{3}":!0}),"public class Model: IEntity\n{\n [FakeDelete(true)] // \u8bbe\u7f6e\u5047\u5220\u9664\u7684\u503c\n public bool IsDeleted { get; set; }\n}\n")),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"[FakeDelete]")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},Object(c.b)("strong",{parentName:"p"},"`","[FakeDelete]")," \u5c5e\u6027\u62e5\u6709\u5e26\u4e00\u4e2a\u53c2\u6570\u7684\u6784\u9020\u51fd\u6570\uff0c\u8fd9\u4e2a\u53c2\u6570\u662f\u5047\u5220\u9664\u7684\u503c"))),Object(c.b)("h3",{id:"9882-\u5047\u5220\u9664\u4f7f\u7528"},"9.8.8.2 \u5047\u5220\u9664\u4f7f\u7528"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.FakeDelete(entity);\n\n// \u793a\u4f8b\u4e8c\nrepository.FakeDeleteNow(entity);\n\n// \u793a\u4f8b\u4e09\nrepository.FakeDelete(1);\n\n// \u793a\u4f8b\u56db\nrepository.FakeDeleteNow(1);\n\n// \u793a\u4f8b\u4e94\nentity.FakeDelete();\n\n// \u793a\u4f8b\u516d\nrepository.UpdateInclude(user, u => u.IsDeleted);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.FakeDeleteAsync(entity);\n\n// \u793a\u4f8b\u4e8c\nawait repository.FakeDeleteNowAsync(entity);\n\n// \u793a\u4f8b\u4e09\nawait repository.FakeDeleteAsync(1);\n\n// \u793a\u4f8b\u56db\nawait repository.FakeDeleteNowAsync(1);\n\n// \u793a\u4f8b\u4e94\nawait entity.FakeDeleteAsync();\n\n// \u793a\u4f8b\u516d\nawait repository.UpdateIncludeAsync(user, u => u.IsDeleted);\n")),Object(c.b)("h2",{id:"989-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.8.9 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}b.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return d})),n.d(t,"b",(function(){return m}));var a=n(0),r=n.n(a);function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var l=r.a.createContext({}),b=function(e){var t=r.a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},d=function(e){var t=b(e.components);return r.a.createElement(l.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},u=r.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,c=e.originalType,i=e.parentName,l=s(e,["components","mdxType","originalType","parentName"]),d=b(n),u=a,m=d["".concat(i,".").concat(u)]||d[u]||p[u]||c;return n?r.a.createElement(m,o(o({ref:t},l),{},{components:n})):r.a.createElement(m,o({ref:t},l))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var c=n.length,i=new Array(c);i[0]=u;var o={};for(var s in t)hasOwnProperty.call(t,s)&&(o[s]=t[s]);o.originalType=e,o.mdxType="string"==typeof e?e:a,i[1]=o;for(var l=2;l[FakeDelete] \u6807\u8bb0",id:"9881-\u6dfb\u52a0-fakedelete-\u6807\u8bb0",children:[]},{value:"9.8.8.2 \u5047\u5220\u9664\u4f7f\u7528",id:"9882-\u5047\u5220\u9664\u4f7f\u7528",children:[]}]},{value:"9.8.9 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"989-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],l={rightToc:s};function b(e){var t=e.components,n=Object(r.a)(e,["components"]);return Object(c.b)("wrapper",Object(a.a)({},l,n,{components:t,mdxType:"MDXLayout"}),Object(c.b)("h2",{id:"981-\u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.8.1 \u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.Delete(user);\n\n// \u793a\u4f8b\u4e8c\nuser.Delete();\n\n// \u793a\u4f8b\u4e09\nrepository.ChangeEntityState(user, EntityState.Deleted);\n\n// \u793a\u4f8b\u56db\nrepository.Entities.Remove(user);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.DeleteAsync(user);\n\n// \u793a\u4f8b\u4e8c\nawait user.DeleteAsync();\n")),Object(c.b)("h2",{id:"982-\u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.8.2 \u5220\u9664\u4e00\u4e2a\u5b9e\u4f53\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.DeleteNow(user);\n\n// \u793a\u4f8b\u4e8c\nuser.DeleteNow();\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.DeleteNowAsync(user);\n\n// \u793a\u4f8b\u4e8c\nawait user.DeleteNowAsync();\n")),Object(c.b)("h2",{id:"983-\u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.8.3 \u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.Delete(1);\n\n// \u793a\u4f8b\u4e8c\nuser.Delete(1);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.DeleteAsync(1);\n\n// \u793a\u4f8b\u4e8c\nawait user.DeleteAsync(1);\n")),Object(c.b)("h2",{id:"984-\u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.8.4 \u6839\u636e\u4e3b\u952e\u5220\u9664\u8bb0\u5f55\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.DeleteNow(1);\n\n// \u793a\u4f8b\u4e8c\nuser.DeleteNow(1);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.DeleteNowAsync(1);\n\n// \u793a\u4f8b\u4e8c\nawait user.DeleteNowAsync(1);\n")),Object(c.b)("h2",{id:"985-\u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"},"9.8.5 \u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\uff08\u4e0d\u7acb\u5373\u63d0\u4ea4\uff09"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.DeleteExists(1);\n\n// \u793a\u4f8b\u4e8c\nuser.DeleteExists(1);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.DeleteExistsAsync(1);\n\n// \u793a\u4f8b\u4e8c\nawait user.DeleteExistsAsync(1);\n")),Object(c.b)("h2",{id:"986-\u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.8.6 \u6570\u636e\u5b58\u5728\u624d\u6839\u636e\u4e3b\u952e\u5220\u9664\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.DeleteExistsNow(1);\n\n// \u793a\u4f8b\u4e8c\nuser.DeleteExistsNow(1);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.DeleteExistsNowAsync(1);\n\n// \u793a\u4f8b\u4e8c\nawait user.DeleteExistsNowAsync(1);\n")),Object(c.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u6240\u6709\u5e26 ",Object(c.b)("inlineCode",{parentName:"p"},"Now")," \u7ed3\u5c3e\u7684\u8868\u793a\u7acb\u5373\u63d0\u4ea4\u5230\u6570\u636e\u5e93\uff0c\u4e5f\u5c31\u662f\u7acb\u5373\u8c03\u7528 ",Object(c.b)("inlineCode",{parentName:"p"},"SaveChanges")," \u6216 ",Object(c.b)("inlineCode",{parentName:"p"},"SaveChangesAsync"),"\u3002"))),Object(c.b)("h2",{id:"988-\u5047\u5220\u9664\u8f6f\u5220\u9664"},"9.8.8 \u5047\u5220\u9664/\u8f6f\u5220\u9664"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u53ef\u4ee5\u901a\u8fc7 ",Object(c.b)("inlineCode",{parentName:"p"},"[FakeDelete]")," \u7279\u6027\u6807\u8bb0\u5047\u5220\u9664\u7279\u6027\uff0c\u5982\uff1a"),Object(c.b)("h3",{id:"9881-\u6dfb\u52a0-fakedelete-\u6807\u8bb0"},"9.8.8.1 \u6dfb\u52a0 ",Object(c.b)("inlineCode",{parentName:"h3"},"[FakeDelete]")," \u6807\u8bb0"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{3}","{3}":!0}),"public class Model: IEntity\n{\n [FakeDelete(true)] // \u8bbe\u7f6e\u5047\u5220\u9664\u7684\u503c\n public bool IsDeleted { get; set; }\n}\n")),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"[FakeDelete]")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},Object(c.b)("strong",{parentName:"p"},"`","[FakeDelete]")," \u5c5e\u6027\u62e5\u6709\u5e26\u4e00\u4e2a\u53c2\u6570\u7684\u6784\u9020\u51fd\u6570\uff0c\u8fd9\u4e2a\u53c2\u6570\u662f\u5047\u5220\u9664\u7684\u503c"))),Object(c.b)("h3",{id:"9882-\u5047\u5220\u9664\u4f7f\u7528"},"9.8.8.2 \u5047\u5220\u9664\u4f7f\u7528"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.FakeDelete(entity);\n\n// \u793a\u4f8b\u4e8c\nrepository.FakeDeleteNow(entity);\n\n// \u793a\u4f8b\u4e09\nrepository.FakeDelete(1);\n\n// \u793a\u4f8b\u56db\nrepository.FakeDeleteNow(1);\n\n// \u793a\u4f8b\u4e94\nentity.FakeDelete();\n\n// \u793a\u4f8b\u516d\nrepository.UpdateInclude(user, u => u.IsDeleted);\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.FakeDeleteAsync(entity);\n\n// \u793a\u4f8b\u4e8c\nawait repository.FakeDeleteNowAsync(entity);\n\n// \u793a\u4f8b\u4e09\nawait repository.FakeDeleteAsync(1);\n\n// \u793a\u4f8b\u56db\nawait repository.FakeDeleteNowAsync(1);\n\n// \u793a\u4f8b\u4e94\nawait entity.FakeDeleteAsync();\n\n// \u793a\u4f8b\u516d\nawait repository.UpdateIncludeAsync(user, u => u.IsDeleted);\n")),Object(c.b)("h2",{id:"989-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.8.9 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}b.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return d})),n.d(t,"b",(function(){return m}));var a=n(0),r=n.n(a);function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var l=r.a.createContext({}),b=function(e){var t=r.a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},d=function(e){var t=b(e.components);return r.a.createElement(l.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},u=r.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,c=e.originalType,i=e.parentName,l=s(e,["components","mdxType","originalType","parentName"]),d=b(n),u=a,m=d["".concat(i,".").concat(u)]||d[u]||p[u]||c;return n?r.a.createElement(m,o(o({ref:t},l),{},{components:n})):r.a.createElement(m,o({ref:t},l))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var c=n.length,i=new Array(c);i[0]=u;var o={};for(var s in t)hasOwnProperty.call(t,s)&&(o[s]=t[s]);o.originalType=e,o.mdxType="string"==typeof e?e:a,i[1]=o;for(var l=2;lSql \u64cd\u4f5c\u4ed3\u50a8",id:"9414-sql-\u64cd\u4f5c\u4ed3\u50a8",children:[]},{value:"9.4.1.5 \u591a\u6570\u636e\u5e93 Sql \u64cd\u4f5c\u4ed3\u50a8",id:"9415-\u591a\u6570\u636e\u5e93-sql-\u64cd\u4f5c\u4ed3\u50a8",children:[]},{value:"9.4.1.6 \u53ea\u8bfb\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"9416-\u53ea\u8bfb\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.7 \u53ea\u5199\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"9417-\u53ea\u5199\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.8 \u53ea\u5141\u8bb8\u65b0\u589e\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"9418-\u53ea\u5141\u8bb8\u65b0\u589e\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.9 \u53ea\u5141\u8bb8\u66f4\u65b0\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"9419-\u53ea\u5141\u8bb8\u66f4\u65b0\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.10 \u53ea\u5141\u8bb8\u5220\u9664\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"94110-\u53ea\u5141\u8bb8\u5220\u9664\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.11 \u53ea\u5141\u8bb8\u62d3\u5c55\u64cd\u4f5c\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"94111-\u53ea\u5141\u8bb8\u62d3\u5c55\u64cd\u4f5c\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.12 \u53ea\u5141\u8bb8 Sql \u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"94112-\u53ea\u5141\u8bb8-sql-\u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.13 \u53ea\u5141\u8bb8 Sql \u975e\u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"94113-\u53ea\u5141\u8bb8-sql-\u975e\u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.14 \u8bfb\u5199\u5206\u79bb\u4ed3\u50a8",id:"94114-\u8bfb\u5199\u5206\u79bb\u4ed3\u50a8",children:[]}]},{value:"9.4.2 \u4ed3\u50a8\u4f7f\u7528",id:"942-\u4ed3\u50a8\u4f7f\u7528",children:[{value:"9.4.2.1 \u6784\u9020\u51fd\u6570\u6ce8\u5165",id:"9421-\u6784\u9020\u51fd\u6570\u6ce8\u5165",children:[]},{value:"9.4.2.2 \u65b9\u6cd5\u53c2\u6570\u6ce8\u5165",id:"9422-\u65b9\u6cd5\u53c2\u6570\u6ce8\u5165",children:[]},{value:"9.4.2.3 Db.GetRepository \u83b7\u53d6",id:"9423-dbgetrepository-\u83b7\u53d6",children:[]}]},{value:"9.4.3 \u4ed3\u50a8\u9ad8\u7ea7\u7528\u6cd5",id:"943-\u4ed3\u50a8\u9ad8\u7ea7\u7528\u6cd5",children:[{value:"9.4.3.1 \u52a8\u6001\u5207\u6362\u5b9e\u4f53\u4ed3\u50a8",id:"9431-\u52a8\u6001\u5207\u6362\u5b9e\u4f53\u4ed3\u50a8",children:[]},{value:"9.4.3.2 \u52a8\u6001\u5207\u6362\u4ed3\u50a8\u7c7b\u578b",id:"9432-\u52a8\u6001\u5207\u6362\u4ed3\u50a8\u7c7b\u578b",children:[]},{value:"9.4.3.3 \u83b7\u53d6 Sql \u64cd\u4f5c\u4ed3\u50a8",id:"9433-\u83b7\u53d6-sql-\u64cd\u4f5c\u4ed3\u50a8",children:[]}]},{value:"9.4.4 \u591a\u6570\u636e\u5e93\u64cd\u4f5c",id:"944-\u591a\u6570\u636e\u5e93\u64cd\u4f5c",children:[{value:"9.4.4.1 \u52a8\u6001\u5207\u6362\u591a\u4e2a\u6570\u636e\u5e93",id:"9441-\u52a8\u6001\u5207\u6362\u591a\u4e2a\u6570\u636e\u5e93",children:[]}]},{value:"9.4.5 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"945-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],c={rightToc:l};function p(e){var t=e.components,n=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},c,n,{components:t,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"941-\u4ec0\u4e48\u662f\u4ed3\u50a8"},"9.4.1 \u4ec0\u4e48\u662f\u4ed3\u50a8"),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},"\u5728\u9886\u57df\u5c42\u548c\u6570\u636e\u6620\u5c04\u5c42\u7684\u4e2d\u4ecb,\u4f7f\u7528\u7c7b\u4f3c\u96c6\u5408\u7684\u63a5\u53e3\u6765\u5b58\u53d6\u9886\u57df\u5bf9\u8c61\uff0c\u5b9e\u9645\u4e0a\uff0c\u4ed3\u50a8\u88ab\u7528\u4e8e\u9886\u57df\u5bf9\u8c61\u5728\u6570\u636e\u5e93\u4e0a\u7684\u64cd\u4f5c\uff08\u5b9e\u4f53 Entity \u548c\u503c\u5bf9\u8c61 Value types\uff09\u3002\u4e00\u822c\u6765\u8bf4,\u6211\u4eec\u9488\u5bf9\u4e0d\u540c\u7684\u5b9e\u4f53(\u6216\u805a\u5408\u6839 Aggregate Root)\u4f1a\u521b\u5efa\u76f8\u5bf9\u5e94\u7684\u4ed3\u50a8\u3002")),Object(i.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u4ed3\u50a8\u5c31\u662f\u6570\u636e\u5b58\u53d6\u64cd\u4f5c\u7684\u8f7d\u4f53\uff0c\u4f46\u4e0d\u9650\u5b9a\u4e8e\u6570\u636e\u5e93\u3002"),Object(i.b)("h2",{id:"941-\u5185\u7f6e\u4ed3\u50a8"},"9.4.1 \u5185\u7f6e\u4ed3\u50a8"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u5185\u7f6e\u4e86\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u4ed3\u50a8\uff0c\u65b9\u4fbf\u5927\u5bb6\u62d3\u5c55\u548c\u96c6\u6210\uff1a"),Object(i.b)("h3",{id:"9411-\u975e\u6cdb\u578b\u8d85\u7ea7\u4ed3\u50a8"},"9.4.1.1 \u975e\u6cdb\u578b\u8d85\u7ea7\u4ed3\u50a8"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IRepository"),"\uff1a\u9ed8\u8ba4\u975e\u6cdb\u578b\u4ed3\u50a8\u63a5\u53e3\uff0c\u652f\u6301\u5207\u6362\u5230\u4efb\u4f55\u4ed3\u50a8"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"EFCoreRepository"),"\uff1a\u9ed8\u8ba4\u975e\u6cdb\u578b\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9412-\u6cdb\u578b\u5b9e\u4f53\u4ed3\u50a8"},"9.4.1.2 \u6cdb\u578b\u5b9e\u4f53\u4ed3\u50a8"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"EFCoreRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9413-\u6cdb\u578b\u591a\u6570\u636e\u5e93\u5b9e\u4f53\u4ed3\u50a8"},"9.4.1.3 \u6cdb\u578b\u591a\u6570\u636e\u5e93\u5b9e\u4f53\u4ed3\u50a8"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IRepository"),"\uff1a\u4efb\u610f\u6570\u636e\u5e93\u7684\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"EFCoreRepository"),"\uff1a\u4efb\u610f\u6570\u636e\u5e93\u7684\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9414-sql-\u64cd\u4f5c\u4ed3\u50a8"},"9.4.1.4 ",Object(i.b)("inlineCode",{parentName:"h3"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9415-\u591a\u6570\u636e\u5e93-sql-\u64cd\u4f5c\u4ed3\u50a8"},"9.4.1.5 \u591a\u6570\u636e\u5e93 ",Object(i.b)("inlineCode",{parentName:"h3"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlRepository"),"\uff1a\u4efb\u610f\u6570\u636e\u5e93\u7684 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlRepository"),"\uff1a\u4efb\u610f\u6570\u636e\u5e93\u7684 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9416-\u53ea\u8bfb\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.6 \u53ea\u8bfb\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IReadableRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u8bfb\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IReadableRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u8bfb\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9417-\u53ea\u5199\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.7 \u53ea\u5199\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IWritableRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u5199\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IWritableRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u5199\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9418-\u53ea\u5141\u8bb8\u65b0\u589e\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.8 \u53ea\u5141\u8bb8\u65b0\u589e\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IInsertableRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u65b0\u589e\u7684\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IInsertableRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u65b0\u589e\u7684\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9419-\u53ea\u5141\u8bb8\u66f4\u65b0\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.9 \u53ea\u5141\u8bb8\u66f4\u65b0\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IUpdateableRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u66f4\u65b0\u7684\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IUpdateableRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u66f4\u65b0\u7684\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"94110-\u53ea\u5141\u8bb8\u5220\u9664\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.10 \u53ea\u5141\u8bb8\u5220\u9664\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IDeletableRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u5220\u9664\u7684\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IDeletableRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u5220\u9664\u7684\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"94111-\u53ea\u5141\u8bb8\u62d3\u5c55\u64cd\u4f5c\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.11 \u53ea\u5141\u8bb8\u62d3\u5c55\u64cd\u4f5c\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IOperableRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u62d3\u5c55\u64cd\u4f5c\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IOperableRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u62d3\u5c55\u64cd\u4f5c\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"94112-\u53ea\u5141\u8bb8-sql-\u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.12 \u53ea\u5141\u8bb8 ",Object(i.b)("inlineCode",{parentName:"h3"},"Sql")," \u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlReaderRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u5141\u8bb8 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u67e5\u8be2\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlReaderRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u5141\u8bb8 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u67e5\u8be2\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"94113-\u53ea\u5141\u8bb8-sql-\u975e\u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.13 \u53ea\u5141\u8bb8 ",Object(i.b)("inlineCode",{parentName:"h3"},"Sql")," \u975e\u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlExecutableRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u5141\u8bb8 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u975e\u67e5\u8be2\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlExecutableRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u5141\u8bb8 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u975e\u67e5\u8be2\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"94114-\u8bfb\u5199\u5206\u79bb\u4ed3\u50a8"},"9.4.1.14 \u8bfb\u5199\u5206\u79bb\u4ed3\u50a8"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IMSRepository"),"\uff1a\u6700\u591a\u652f\u6301 ",Object(i.b)("strong",{parentName:"li"},"\u4e00\u4e3b7\u4ece")," \u4ed3\u50a8")),Object(i.b)("h2",{id:"942-\u4ed3\u50a8\u4f7f\u7528"},"9.4.2 \u4ed3\u50a8\u4f7f\u7528"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u4e86\u975e\u5e38\u591a\u7684\u65b9\u5f0f\u521b\u5efa\u4ed3\u50a8\uff0c\u76ee\u7684\u662f\u4e3a\u4e86\u8ba9\u5927\u5bb6\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u573a\u666f\u4e2d\u4f7f\u7528\u3002"),Object(i.b)("h3",{id:"9421-\u6784\u9020\u51fd\u6570\u6ce8\u5165"},"9.4.2.1 \u6784\u9020\u51fd\u6570\u6ce8\u5165"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2}","{2}":!0}),"private readonly IRepository _personRepository;\npublic FurService(IRepository personRepository)\n{\n _personRepository = personRepository;\n}\n")),Object(i.b)("h3",{id:"9422-\u65b9\u6cd5\u53c2\u6570\u6ce8\u5165"},"9.4.2.2 \u65b9\u6cd5\u53c2\u6570\u6ce8\u5165"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),"public async Task> GetAll([FromServices] IRepository repository, string keyword)\n{\n var persons = await repository.AsQueryable().ToListAsync();\n return persons.Adapt>();\n}\n")),Object(i.b)("h3",{id:"9423-dbgetrepository-\u83b7\u53d6"},"9.4.2.3 ",Object(i.b)("inlineCode",{parentName:"h3"},"Db.GetRepository")," \u83b7\u53d6"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u975e\u6cdb\u578b\u4ed3\u50a8\nvar repository = Db.GetRepository();\n\n// \u6cdb\u578b\u4ed3\u50a8\nvar repository = Db.GetRepository();\n\n// Sql \u4ed3\u50a8\nvar sqlRepository = Db.GetSqlRepository();\n")),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u8bf4\u660e")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u4e0d\u7ba1\u91c7\u7528\u90a3\u79cd\u65b9\u5f0f\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u90fd\u4fdd\u8bc1\u4e86\u4ed3\u50a8\u4e00\u6b21\u8bf7\u6c42\u552f\u4e00\u6027\u3002\u540c\u65f6 ",Object(i.b)("inlineCode",{parentName:"p"},"Db.GetRepository()")," \u65b9\u5f0f\u652f\u6301\u4efb\u4f55\u9759\u6001\u7c7b\u4e2d\u4f7f\u7528\u3002"))),Object(i.b)("h2",{id:"943-\u4ed3\u50a8\u9ad8\u7ea7\u7528\u6cd5"},"9.4.3 \u4ed3\u50a8\u9ad8\u7ea7\u7528\u6cd5"),Object(i.b)("h3",{id:"9431-\u52a8\u6001\u5207\u6362\u5b9e\u4f53\u4ed3\u50a8"},"9.4.3.1 \u52a8\u6001\u5207\u6362\u5b9e\u4f53\u4ed3\u50a8"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var userRepository = personRepository.Change();\n")),Object(i.b)("h3",{id:"9432-\u52a8\u6001\u5207\u6362\u4ed3\u50a8\u7c7b\u578b"},"9.4.3.2 \u52a8\u6001\u5207\u6362\u4ed3\u50a8\u7c7b\u578b"),Object(i.b)("p",null,"\u6bd4\u5982\uff0c\u8bfb\u5199\u5206\u79bb/\u4e3b\u4ece\u5e93\u4ed3\u50a8\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u53ea\u8bfb\u4ed3\u50a8\nvar readRepository = personRepository.Constraint>();\n\n// \u53ea\u5199\u4ed3\u50a8\nvar readRepository = personRepository.Constraint>();\n")),Object(i.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},".Constraint")," \u652f\u6301\u5207\u6362\u4efb\u4f55\u4ed3\u50a8\u7c7b\u578b\u3002"))),Object(i.b)("h3",{id:"9433-\u83b7\u53d6-sql-\u64cd\u4f5c\u4ed3\u50a8"},"9.4.3.3 \u83b7\u53d6 ",Object(i.b)("inlineCode",{parentName:"h3"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var sqlRepository = repository.Sql();\n")),Object(i.b)("h2",{id:"944-\u591a\u6570\u636e\u5e93\u64cd\u4f5c"},"9.4.4 \u591a\u6570\u636e\u5e93\u64cd\u4f5c"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"DbContextLocator")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u5b9e\u73b0\u591a\u79cd\u6570\u636e\u5e93\u64cd\u4f5c\uff0c\u53ef\u4ee5\u968f\u610f\u5207\u6362\u6570\u636e\u5e93"),Object(i.b)("h3",{id:"9441-\u52a8\u6001\u5207\u6362\u591a\u4e2a\u6570\u636e\u5e93"},"9.4.4.1 \u52a8\u6001\u5207\u6362\u591a\u4e2a\u6570\u636e\u5e93"),Object(i.b)("h4",{id:"\u52a8\u6001\u5207\u6362\u6570\u636e\u5e93"},"\u52a8\u6001\u5207\u6362\u6570\u636e\u5e93"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u5207\u6362\u5230 MSSQL \u64cd\u4f5c Person\u8868\nvar mssqlRepository = repository.Change();\n\n// \u5207\u6362\u5230 MySql \u64cd\u4f5c Person\u8868\nvar mysqlRepository = repository.Change();\n\n// \u5207\u6362\u5230 Sqlite \u64cd\u4f5c Person\u8868\nvar sqliteRepository = repository.Change();\n\n// \u5176\u4ed6\u66f4\u591a\u6570\u636e\u5e93\u4e00\u6837\u7684\u64cd\u4f5c\n")),Object(i.b)("h4",{id:"\u53e6\u5916\u4efb\u4f55\u4ed3\u50a8\u6216\u5b9e\u4f53\u914d\u7f6e\u90fd\u652f\u6301\u591a\u4e2a\u6570\u636e\u5e93\u540c\u65f6\u64cd\u4f5c"},"\u53e6\u5916\u4efb\u4f55\u4ed3\u50a8\u6216\u5b9e\u4f53\u914d\u7f6e\u90fd\u652f\u6301\u591a\u4e2a\u6570\u636e\u5e93\u540c\u65f6\u64cd\u4f5c"),Object(i.b)("p",null,"\u4ed3\u50a8\u65b9\u5f0f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"IRepository mssqlRepository\n\nISqlRepository mssqlRepository;\n")),Object(i.b)("p",null,"\u52a8\u6001 ",Object(i.b)("inlineCode",{parentName:"p"},"sql")," \u65b9\u5f0f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'"select * from person".Change().SqlQuery();\n')),Object(i.b)("p",null,"\u5b9e\u4f53\u914d\u7f6e\u65b9\u5f0f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"public class User:Entity\n{\n}\n")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Sql")," \u4ee3\u7406\u65b9\u5f0f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'[SqlFunction("funcName", DbContextLocator = typeof(MySqlDbContextLocator))]\nint GetAge(int id);\n')),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Linq")," \u4e2d\u65b9\u5f0f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'[QueryableFunction("funcName","dbo", DbContextLocator = typeof(MySqlDbContextLocator))]\nstring GetName()=> throw Oops.Oh("\u4e0d\u652f\u6301\u8be5\u6570\u636e\u5e93\u64cd\u4f5c");\n')),Object(i.b)("h2",{id:"945-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.4.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return j}));var a=n(0),r=n.n(a);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var c=r.a.createContext({}),p=function(e){var t=r.a.useContext(c),n=t;return e&&(n="function"==typeof e?e(t):b(b({},t),e)),n},s=function(e){var t=p(e.components);return r.a.createElement(c.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},O=r.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,i=e.originalType,o=e.parentName,c=l(e,["components","mdxType","originalType","parentName"]),s=p(n),O=a,j=s["".concat(o,".").concat(O)]||s[O]||d[O]||i;return n?r.a.createElement(j,b(b({ref:t},c),{},{components:n})):r.a.createElement(j,b({ref:t},c))}));function j(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var i=n.length,o=new Array(i);o[0]=O;var b={};for(var l in t)hasOwnProperty.call(t,l)&&(b[l]=t[l]);b.originalType=e,b.mdxType="string"==typeof e?e:a,o[1]=b;for(var c=2;cSql \u64cd\u4f5c\u4ed3\u50a8",id:"9414-sql-\u64cd\u4f5c\u4ed3\u50a8",children:[]},{value:"9.4.1.5 \u591a\u6570\u636e\u5e93 Sql \u64cd\u4f5c\u4ed3\u50a8",id:"9415-\u591a\u6570\u636e\u5e93-sql-\u64cd\u4f5c\u4ed3\u50a8",children:[]},{value:"9.4.1.6 \u53ea\u8bfb\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"9416-\u53ea\u8bfb\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.7 \u53ea\u5199\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"9417-\u53ea\u5199\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.8 \u53ea\u5141\u8bb8\u65b0\u589e\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"9418-\u53ea\u5141\u8bb8\u65b0\u589e\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.9 \u53ea\u5141\u8bb8\u66f4\u65b0\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"9419-\u53ea\u5141\u8bb8\u66f4\u65b0\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.10 \u53ea\u5141\u8bb8\u5220\u9664\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"94110-\u53ea\u5141\u8bb8\u5220\u9664\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.11 \u53ea\u5141\u8bb8\u62d3\u5c55\u64cd\u4f5c\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"94111-\u53ea\u5141\u8bb8\u62d3\u5c55\u64cd\u4f5c\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.12 \u53ea\u5141\u8bb8 Sql \u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"94112-\u53ea\u5141\u8bb8-sql-\u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.13 \u53ea\u5141\u8bb8 Sql \u975e\u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",id:"94113-\u53ea\u5141\u8bb8-sql-\u975e\u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09",children:[]},{value:"9.4.1.14 \u8bfb\u5199\u5206\u79bb\u4ed3\u50a8",id:"94114-\u8bfb\u5199\u5206\u79bb\u4ed3\u50a8",children:[]}]},{value:"9.4.2 \u4ed3\u50a8\u4f7f\u7528",id:"942-\u4ed3\u50a8\u4f7f\u7528",children:[{value:"9.4.2.1 \u6784\u9020\u51fd\u6570\u6ce8\u5165",id:"9421-\u6784\u9020\u51fd\u6570\u6ce8\u5165",children:[]},{value:"9.4.2.2 \u65b9\u6cd5\u53c2\u6570\u6ce8\u5165",id:"9422-\u65b9\u6cd5\u53c2\u6570\u6ce8\u5165",children:[]},{value:"9.4.2.3 Db.GetRepository \u83b7\u53d6",id:"9423-dbgetrepository-\u83b7\u53d6",children:[]}]},{value:"9.4.3 \u4ed3\u50a8\u9ad8\u7ea7\u7528\u6cd5",id:"943-\u4ed3\u50a8\u9ad8\u7ea7\u7528\u6cd5",children:[{value:"9.4.3.1 \u52a8\u6001\u5207\u6362\u5b9e\u4f53\u4ed3\u50a8",id:"9431-\u52a8\u6001\u5207\u6362\u5b9e\u4f53\u4ed3\u50a8",children:[]},{value:"9.4.3.2 \u52a8\u6001\u5207\u6362\u4ed3\u50a8\u7c7b\u578b",id:"9432-\u52a8\u6001\u5207\u6362\u4ed3\u50a8\u7c7b\u578b",children:[]},{value:"9.4.3.3 \u83b7\u53d6 Sql \u64cd\u4f5c\u4ed3\u50a8",id:"9433-\u83b7\u53d6-sql-\u64cd\u4f5c\u4ed3\u50a8",children:[]}]},{value:"9.4.4 \u591a\u6570\u636e\u5e93\u64cd\u4f5c",id:"944-\u591a\u6570\u636e\u5e93\u64cd\u4f5c",children:[{value:"9.4.4.1 \u52a8\u6001\u5207\u6362\u591a\u4e2a\u6570\u636e\u5e93",id:"9441-\u52a8\u6001\u5207\u6362\u591a\u4e2a\u6570\u636e\u5e93",children:[]}]},{value:"9.4.5 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"945-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],c={rightToc:l};function p(e){var t=e.components,n=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(a.a)({},c,n,{components:t,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"941-\u4ec0\u4e48\u662f\u4ed3\u50a8"},"9.4.1 \u4ec0\u4e48\u662f\u4ed3\u50a8"),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},"\u5728\u9886\u57df\u5c42\u548c\u6570\u636e\u6620\u5c04\u5c42\u7684\u4e2d\u4ecb,\u4f7f\u7528\u7c7b\u4f3c\u96c6\u5408\u7684\u63a5\u53e3\u6765\u5b58\u53d6\u9886\u57df\u5bf9\u8c61\uff0c\u5b9e\u9645\u4e0a\uff0c\u4ed3\u50a8\u88ab\u7528\u4e8e\u9886\u57df\u5bf9\u8c61\u5728\u6570\u636e\u5e93\u4e0a\u7684\u64cd\u4f5c\uff08\u5b9e\u4f53 Entity \u548c\u503c\u5bf9\u8c61 Value types\uff09\u3002\u4e00\u822c\u6765\u8bf4,\u6211\u4eec\u9488\u5bf9\u4e0d\u540c\u7684\u5b9e\u4f53(\u6216\u805a\u5408\u6839 Aggregate Root)\u4f1a\u521b\u5efa\u76f8\u5bf9\u5e94\u7684\u4ed3\u50a8\u3002")),Object(i.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u4ed3\u50a8\u5c31\u662f\u6570\u636e\u5b58\u53d6\u64cd\u4f5c\u7684\u8f7d\u4f53\uff0c\u4f46\u4e0d\u9650\u5b9a\u4e8e\u6570\u636e\u5e93\u3002"),Object(i.b)("h2",{id:"941-\u5185\u7f6e\u4ed3\u50a8"},"9.4.1 \u5185\u7f6e\u4ed3\u50a8"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u5185\u7f6e\u4e86\u4e00\u4e2a\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u4ed3\u50a8\uff0c\u65b9\u4fbf\u5927\u5bb6\u62d3\u5c55\u548c\u96c6\u6210\uff1a"),Object(i.b)("h3",{id:"9411-\u975e\u6cdb\u578b\u8d85\u7ea7\u4ed3\u50a8"},"9.4.1.1 \u975e\u6cdb\u578b\u8d85\u7ea7\u4ed3\u50a8"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IRepository"),"\uff1a\u9ed8\u8ba4\u975e\u6cdb\u578b\u4ed3\u50a8\u63a5\u53e3\uff0c\u652f\u6301\u5207\u6362\u5230\u4efb\u4f55\u4ed3\u50a8"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"EFCoreRepository"),"\uff1a\u9ed8\u8ba4\u975e\u6cdb\u578b\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9412-\u6cdb\u578b\u5b9e\u4f53\u4ed3\u50a8"},"9.4.1.2 \u6cdb\u578b\u5b9e\u4f53\u4ed3\u50a8"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"EFCoreRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9413-\u6cdb\u578b\u591a\u6570\u636e\u5e93\u5b9e\u4f53\u4ed3\u50a8"},"9.4.1.3 \u6cdb\u578b\u591a\u6570\u636e\u5e93\u5b9e\u4f53\u4ed3\u50a8"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IRepository"),"\uff1a\u4efb\u610f\u6570\u636e\u5e93\u7684\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"EFCoreRepository"),"\uff1a\u4efb\u610f\u6570\u636e\u5e93\u7684\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9414-sql-\u64cd\u4f5c\u4ed3\u50a8"},"9.4.1.4 ",Object(i.b)("inlineCode",{parentName:"h3"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9415-\u591a\u6570\u636e\u5e93-sql-\u64cd\u4f5c\u4ed3\u50a8"},"9.4.1.5 \u591a\u6570\u636e\u5e93 ",Object(i.b)("inlineCode",{parentName:"h3"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlRepository"),"\uff1a\u4efb\u610f\u6570\u636e\u5e93\u7684 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlRepository"),"\uff1a\u4efb\u610f\u6570\u636e\u5e93\u7684 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9416-\u53ea\u8bfb\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.6 \u53ea\u8bfb\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IReadableRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u8bfb\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IReadableRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u8bfb\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9417-\u53ea\u5199\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.7 \u53ea\u5199\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IWritableRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u5199\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IWritableRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u5199\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9418-\u53ea\u5141\u8bb8\u65b0\u589e\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.8 \u53ea\u5141\u8bb8\u65b0\u589e\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IInsertableRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u65b0\u589e\u7684\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IInsertableRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u65b0\u589e\u7684\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"9419-\u53ea\u5141\u8bb8\u66f4\u65b0\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.9 \u53ea\u5141\u8bb8\u66f4\u65b0\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IUpdateableRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u66f4\u65b0\u7684\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IUpdateableRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u66f4\u65b0\u7684\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"94110-\u53ea\u5141\u8bb8\u5220\u9664\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.10 \u53ea\u5141\u8bb8\u5220\u9664\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IDeletableRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u5220\u9664\u7684\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IDeletableRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u5220\u9664\u7684\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"94111-\u53ea\u5141\u8bb8\u62d3\u5c55\u64cd\u4f5c\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.11 \u53ea\u5141\u8bb8\u62d3\u5c55\u64cd\u4f5c\u5b9e\u4f53\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IOperableRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u62d3\u5c55\u64cd\u4f5c\u5b9e\u4f53\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IOperableRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u5141\u8bb8\u62d3\u5c55\u64cd\u4f5c\u5b9e\u4f53\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"94112-\u53ea\u5141\u8bb8-sql-\u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.12 \u53ea\u5141\u8bb8 ",Object(i.b)("inlineCode",{parentName:"h3"},"Sql")," \u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlReaderRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u5141\u8bb8 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u67e5\u8be2\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlReaderRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u5141\u8bb8 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u67e5\u8be2\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"94113-\u53ea\u5141\u8bb8-sql-\u975e\u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"},"9.4.1.13 \u53ea\u5141\u8bb8 ",Object(i.b)("inlineCode",{parentName:"h3"},"Sql")," \u975e\u67e5\u8be2\u4ed3\u50a8\uff08\u652f\u6301\u591a\u5e93\uff09"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlExecutableRepository"),"\uff1a\u9ed8\u8ba4\u6570\u636e\u5e93\u53ea\u5141\u8bb8 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u975e\u67e5\u8be2\u4ed3\u50a8\u63a5\u53e3"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"ISqlExecutableRepository"),"\uff1a\u591a\u6570\u636e\u5e93\u53ea\u5141\u8bb8 ",Object(i.b)("inlineCode",{parentName:"li"},"Sql")," \u975e\u67e5\u8be2\u4ed3\u50a8\u5b9e\u73b0")),Object(i.b)("h3",{id:"94114-\u8bfb\u5199\u5206\u79bb\u4ed3\u50a8"},"9.4.1.14 \u8bfb\u5199\u5206\u79bb\u4ed3\u50a8"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"IMSRepository"),"\uff1a\u6700\u591a\u652f\u6301 ",Object(i.b)("strong",{parentName:"li"},"\u4e00\u4e3b7\u4ece")," \u4ed3\u50a8")),Object(i.b)("h2",{id:"942-\u4ed3\u50a8\u4f7f\u7528"},"9.4.2 \u4ed3\u50a8\u4f7f\u7528"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u4e86\u975e\u5e38\u591a\u7684\u65b9\u5f0f\u521b\u5efa\u4ed3\u50a8\uff0c\u76ee\u7684\u662f\u4e3a\u4e86\u8ba9\u5927\u5bb6\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u573a\u666f\u4e2d\u4f7f\u7528\u3002"),Object(i.b)("h3",{id:"9421-\u6784\u9020\u51fd\u6570\u6ce8\u5165"},"9.4.2.1 \u6784\u9020\u51fd\u6570\u6ce8\u5165"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2}","{2}":!0}),"private readonly IRepository _personRepository;\npublic FurService(IRepository personRepository)\n{\n _personRepository = personRepository;\n}\n")),Object(i.b)("h3",{id:"9422-\u65b9\u6cd5\u53c2\u6570\u6ce8\u5165"},"9.4.2.2 \u65b9\u6cd5\u53c2\u6570\u6ce8\u5165"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),"public async Task> GetAll([FromServices] IRepository repository, string keyword)\n{\n var persons = await repository.AsQueryable().ToListAsync();\n return persons.Adapt>();\n}\n")),Object(i.b)("h3",{id:"9423-dbgetrepository-\u83b7\u53d6"},"9.4.2.3 ",Object(i.b)("inlineCode",{parentName:"h3"},"Db.GetRepository")," \u83b7\u53d6"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u975e\u6cdb\u578b\u4ed3\u50a8\nvar repository = Db.GetRepository();\n\n// \u6cdb\u578b\u4ed3\u50a8\nvar repository = Db.GetRepository();\n\n// Sql \u4ed3\u50a8\nvar sqlRepository = Db.GetSqlRepository();\n")),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u8bf4\u660e")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u4e0d\u7ba1\u91c7\u7528\u90a3\u79cd\u65b9\u5f0f\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u90fd\u4fdd\u8bc1\u4e86\u4ed3\u50a8\u4e00\u6b21\u8bf7\u6c42\u552f\u4e00\u6027\u3002\u540c\u65f6 ",Object(i.b)("inlineCode",{parentName:"p"},"Db.GetRepository()")," \u65b9\u5f0f\u652f\u6301\u4efb\u4f55\u9759\u6001\u7c7b\u4e2d\u4f7f\u7528\u3002"))),Object(i.b)("h2",{id:"943-\u4ed3\u50a8\u9ad8\u7ea7\u7528\u6cd5"},"9.4.3 \u4ed3\u50a8\u9ad8\u7ea7\u7528\u6cd5"),Object(i.b)("h3",{id:"9431-\u52a8\u6001\u5207\u6362\u5b9e\u4f53\u4ed3\u50a8"},"9.4.3.1 \u52a8\u6001\u5207\u6362\u5b9e\u4f53\u4ed3\u50a8"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var userRepository = personRepository.Change();\n")),Object(i.b)("h3",{id:"9432-\u52a8\u6001\u5207\u6362\u4ed3\u50a8\u7c7b\u578b"},"9.4.3.2 \u52a8\u6001\u5207\u6362\u4ed3\u50a8\u7c7b\u578b"),Object(i.b)("p",null,"\u6bd4\u5982\uff0c\u8bfb\u5199\u5206\u79bb/\u4e3b\u4ece\u5e93\u4ed3\u50a8\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u53ea\u8bfb\u4ed3\u50a8\nvar readRepository = personRepository.Constraint>();\n\n// \u53ea\u5199\u4ed3\u50a8\nvar readRepository = personRepository.Constraint>();\n")),Object(i.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},".Constraint")," \u652f\u6301\u5207\u6362\u4efb\u4f55\u4ed3\u50a8\u7c7b\u578b\u3002"))),Object(i.b)("h3",{id:"9433-\u83b7\u53d6-sql-\u64cd\u4f5c\u4ed3\u50a8"},"9.4.3.3 \u83b7\u53d6 ",Object(i.b)("inlineCode",{parentName:"h3"},"Sql")," \u64cd\u4f5c\u4ed3\u50a8"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var sqlRepository = repository.Sql();\n")),Object(i.b)("h2",{id:"944-\u591a\u6570\u636e\u5e93\u64cd\u4f5c"},"9.4.4 \u591a\u6570\u636e\u5e93\u64cd\u4f5c"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"DbContextLocator")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668\u5b9e\u73b0\u591a\u79cd\u6570\u636e\u5e93\u64cd\u4f5c\uff0c\u53ef\u4ee5\u968f\u610f\u5207\u6362\u6570\u636e\u5e93"),Object(i.b)("h3",{id:"9441-\u52a8\u6001\u5207\u6362\u591a\u4e2a\u6570\u636e\u5e93"},"9.4.4.1 \u52a8\u6001\u5207\u6362\u591a\u4e2a\u6570\u636e\u5e93"),Object(i.b)("h4",{id:"\u52a8\u6001\u5207\u6362\u6570\u636e\u5e93"},"\u52a8\u6001\u5207\u6362\u6570\u636e\u5e93"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"// \u5207\u6362\u5230 MSSQL \u64cd\u4f5c Person\u8868\nvar mssqlRepository = repository.Change();\n\n// \u5207\u6362\u5230 MySql \u64cd\u4f5c Person\u8868\nvar mysqlRepository = repository.Change();\n\n// \u5207\u6362\u5230 Sqlite \u64cd\u4f5c Person\u8868\nvar sqliteRepository = repository.Change();\n\n// \u5176\u4ed6\u66f4\u591a\u6570\u636e\u5e93\u4e00\u6837\u7684\u64cd\u4f5c\n")),Object(i.b)("h4",{id:"\u53e6\u5916\u4efb\u4f55\u4ed3\u50a8\u6216\u5b9e\u4f53\u914d\u7f6e\u90fd\u652f\u6301\u591a\u4e2a\u6570\u636e\u5e93\u540c\u65f6\u64cd\u4f5c"},"\u53e6\u5916\u4efb\u4f55\u4ed3\u50a8\u6216\u5b9e\u4f53\u914d\u7f6e\u90fd\u652f\u6301\u591a\u4e2a\u6570\u636e\u5e93\u540c\u65f6\u64cd\u4f5c"),Object(i.b)("p",null,"\u4ed3\u50a8\u65b9\u5f0f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"IRepository mssqlRepository\n\nISqlRepository mssqlRepository;\n")),Object(i.b)("p",null,"\u52a8\u6001 ",Object(i.b)("inlineCode",{parentName:"p"},"sql")," \u65b9\u5f0f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'"select * from person".Change().SqlQuery();\n')),Object(i.b)("p",null,"\u5b9e\u4f53\u914d\u7f6e\u65b9\u5f0f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"public class User:Entity\n{\n}\n")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Sql")," \u4ee3\u7406\u65b9\u5f0f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'[SqlFunction("funcName", DbContextLocator = typeof(MySqlDbContextLocator))]\nint GetAge(int id);\n')),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Linq")," \u4e2d\u65b9\u5f0f"),Object(i.b)("pre",null,Object(i.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'[QueryableFunction("funcName","dbo", DbContextLocator = typeof(MySqlDbContextLocator))]\nstring GetName()=> throw Oops.Oh("\u4e0d\u652f\u6301\u8be5\u6570\u636e\u5e93\u64cd\u4f5c");\n')),Object(i.b)("h2",{id:"945-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.4.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return j}));var a=n(0),r=n.n(a);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function b(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var c=r.a.createContext({}),p=function(e){var t=r.a.useContext(c),n=t;return e&&(n="function"==typeof e?e(t):b(b({},t),e)),n},s=function(e){var t=p(e.components);return r.a.createElement(c.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},O=r.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,i=e.originalType,o=e.parentName,c=l(e,["components","mdxType","originalType","parentName"]),s=p(n),O=a,j=s["".concat(o,".").concat(O)]||s[O]||d[O]||i;return n?r.a.createElement(j,b(b({ref:t},c),{},{components:n})):r.a.createElement(j,b({ref:t},c))}));function j(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var i=n.length,o=new Array(i);o[0]=O;var b={};for(var l in t)hasOwnProperty.call(t,l)&&(b[l]=t[l]);b.originalType=e,b.mdxType="string"==typeof e?e:a,o[1]=b;for(var c=2;c=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=o.a.createContext({}),s=function(e){var r=o.a.useContext(p),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},l=function(e){var r=s(e.components);return o.a.createElement(p.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),l=s(t),d=n,m=l["".concat(c,".").concat(d)]||l[d]||f[d]||a;return t?o.a.createElement(m,i(i({ref:r},p),{},{components:t})):o.a.createElement(m,i({ref:r},p))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,c=new Array(a);c[0]=d;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var p=2;p=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=o.a.createContext({}),s=function(e){var r=o.a.useContext(p),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},l=function(e){var r=s(e.components);return o.a.createElement(p.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,a=e.originalType,c=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),l=s(t),d=n,m=l["".concat(c,".").concat(d)]||l[d]||f[d]||a;return t?o.a.createElement(m,i(i({ref:r},p),{},{components:t})):o.a.createElement(m,i({ref:r},p))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var a=t.length,c=new Array(a);c[0]=d;var i={};for(var u in r)hasOwnProperty.call(r,u)&&(i[u]=r[u]);i.originalType=e,i.mdxType="string"==typeof e?e:n,c[1]=i;for(var p=2;pSql \u6a21\u677f",id:"9161-sql-\u6a21\u677f",children:[]},{value:"9.16.2 Sql \u6a21\u677f\u4f18\u7f3a\u70b9",id:"9162-sql-\u6a21\u677f\u4f18\u7f3a\u70b9",children:[{value:"9.16.2.1 \u4f18\u70b9",id:"91621-\u4f18\u70b9",children:[]},{value:"9.16.2.2 \u7f3a\u70b9",id:"91622-\u7f3a\u70b9",children:[]}]},{value:"9.16.3 \u5982\u4f55\u4f7f\u7528",id:"9163-\u5982\u4f55\u4f7f\u7528",children:[{value:"9.16.3.1 \u5e38\u89c4\u4f7f\u7528",id:"91631-\u5e38\u89c4\u4f7f\u7528",children:[]},{value:"9.16.3.2 \u9ad8\u7ea7\u5d4c\u5957",id:"91632-\u9ad8\u7ea7\u5d4c\u5957",children:[]}]},{value:"9.16.4 Sql \u6a21\u677f\u914d\u7f6e",id:"9164-sql-\u6a21\u677f\u914d\u7f6e",children:[{value:"9.16.4.1 \u666e\u901a\u6a21\u5f0f",id:"91641-\u666e\u901a\u6a21\u5f0f",children:[]},{value:"9.16.4.2 \u66f4\u591a\u914d\u7f6e",id:"91642-\u66f4\u591a\u914d\u7f6e",children:[]}]},{value:"9.16.5 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9165-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],b={rightToc:o};function s(e){var t=e.components,n=Object(a.a)(e,["components"]);return Object(l.b)("wrapper",Object(r.a)({},b,n,{components:t,mdxType:"MDXLayout"}),Object(l.b)("h2",{id:"9161-sql-\u6a21\u677f"},"9.16.1 ",Object(l.b)("inlineCode",{parentName:"h2"},"Sql")," \u6a21\u677f"),Object(l.b)("p",null,"\u901a\u5e38\u6211\u4eec\u7a0b\u5e8f\u4e2d\u6267\u884c\u6570\u636e\u5e93\u7684 ",Object(l.b)("inlineCode",{parentName:"p"},"sql")," \u8bed\u53e5\u90fd\u5199\u5728\u4e86\u7a0b\u5e8f\u96c6\u4e2d\uff0c\u968f\u7a0b\u5e8f\u4e00\u8d77\u7f16\u8bd1\uff0c\u540e\u7eed\u9700\u8981\u4fee\u6539\uff0c\u5219\u91cd\u65b0\u7f16\u8bd1\u4ee3\u7801\u3002"),Object(l.b)("p",null,"\u6240\u4ee5\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u521b\u9020\u51fa\u4e00\u79cd ",Object(l.b)("inlineCode",{parentName:"p"},"Sql")," \u6a21\u677f\u7684\u65b9\u5f0f\uff0c\u7a0b\u5e8f\u6267\u884c ",Object(l.b)("inlineCode",{parentName:"p"},"Sql")," \u65f6\uff0c\u53ea\u9700\u8981\u4f7f\u7528\u7279\u6b8a\u6807\u8bb0\u5373\u53ef\uff1a",Object(l.b)("inlineCode",{parentName:"p"},"#(\u6a21\u677fKey)"),"\uff0c\u8fd9\u4e9b\u771f\u5b9e\u7684 ",Object(l.b)("inlineCode",{parentName:"p"},"Sql")," \u914d\u7f6e\u5728 ",Object(l.b)("inlineCode",{parentName:"p"},".json")," \u6216 ",Object(l.b)("inlineCode",{parentName:"p"},".xml")," \u914d\u7f6e\u6587\u4ef6\u4e2d\u3002"),Object(l.b)("p",null,"\u5982\uff1a"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"Json")," \u65b9\u5f0f")),Object(l.b)("pre",null,Object(l.b)("code",Object(r.a)({parentName:"pre"},{className:"language-json"}),'{\n "Select.User": "select * from User where id > @id"\n}\n')),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"Xml")," \u65b9\u5f0f")),Object(l.b)("pre",null,Object(l.b)("code",Object(r.a)({parentName:"pre"},{className:"language-xml"}),'\n\n select * from User where id > @id\n\n')),Object(l.b)("h2",{id:"9162-sql-\u6a21\u677f\u4f18\u7f3a\u70b9"},"9.16.2 ",Object(l.b)("inlineCode",{parentName:"h2"},"Sql")," \u6a21\u677f\u4f18\u7f3a\u70b9"),Object(l.b)("h3",{id:"91621-\u4f18\u70b9"},"9.16.2.1 \u4f18\u70b9"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u652f\u6301 ",Object(l.b)("inlineCode",{parentName:"li"},"Sql")," \u52a8\u6001\u914d\u7f6e\uff0c\u53ef\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\u52a8\u6001\u8c03\u914d ",Object(l.b)("inlineCode",{parentName:"li"},"Sql")," \u8bed\u53e5"),Object(l.b)("li",{parentName:"ul"},"\u652f\u6301\u7a0b\u5e8f ",Object(l.b)("inlineCode",{parentName:"li"},"Sql")," \u8bed\u53e5\u52a0\u5bc6")),Object(l.b)("h3",{id:"91622-\u7f3a\u70b9"},"9.16.2.2 \u7f3a\u70b9"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u9700\u589e\u52a0\u5bf9\u5e94\u914d\u7f6e\u6587\u4ef6"),Object(l.b)("li",{parentName:"ul"},"\u4e0d\u5bb9\u6613\u8c03\u8bd5 ",Object(l.b)("inlineCode",{parentName:"li"},"Sql")," \u4ee3\u7801")),Object(l.b)("h2",{id:"9163-\u5982\u4f55\u4f7f\u7528"},"9.16.3 \u5982\u4f55\u4f7f\u7528"),Object(l.b)("p",null,"\u5728\u6267\u884c ",Object(l.b)("inlineCode",{parentName:"p"},"Sql")," \u7684\u65f6\u5019\uff0c\u53ea\u9700\u8981\u586b\u5199\u6307\u5b9a\u6a21\u677f\u5373\u53ef\u3002"),Object(l.b)("h3",{id:"91631-\u5e38\u89c4\u4f7f\u7528"},"9.16.3.1 \u5e38\u89c4\u4f7f\u7528"),Object(l.b)("pre",null,Object(l.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// \u4ed3\u50a8\u65b9\u5f0f\nvar users = repository.SqlQuery("#(Select.User)", new { id = 1});\n\n// \u61d2\u4eba\u65b9\u5f0f\nvar users = "#(Select.User)".SqlQuery(new { id = 1});\n\n// Sql \u4ee3\u7406\u65b9\u5f0f\n[SqlExecute("#(Select.User)")]\nList GetUser(int id);\n')),Object(l.b)("h3",{id:"91632-\u9ad8\u7ea7\u5d4c\u5957"},"9.16.3.2 \u9ad8\u7ea7\u5d4c\u5957"),Object(l.b)("pre",null,Object(l.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'var users = repository.SqlQuery(\n@"select * from user u\nleft join #(User.Detail) d on u.Id = d.UserId\nwhere id > @id");\n')),Object(l.b)("h2",{id:"9164-sql-\u6a21\u677f\u914d\u7f6e"},"9.16.4 ",Object(l.b)("inlineCode",{parentName:"h2"},"Sql")," \u6a21\u677f\u914d\u7f6e"),Object(l.b)("h3",{id:"91641-\u666e\u901a\u6a21\u5f0f"},"9.16.4.1 \u666e\u901a\u6a21\u5f0f"),Object(l.b)("pre",null,Object(l.b)("code",Object(r.a)({parentName:"pre"},{className:"language-json"}),'{\n "Select.User": "select * from User"\n}\n')),Object(l.b)("h3",{id:"91642-\u66f4\u591a\u914d\u7f6e"},"9.16.4.2 \u66f4\u591a\u914d\u7f6e"),Object(l.b)("pre",null,Object(l.b)("code",Object(r.a)({parentName:"pre"},{className:"language-json"}),'{\n "Select.User": {\n "Sql": "select * from User where id > @id and Name = @name",\n "Params": [\n {\n "Name": " Id",\n "Value": "1",\n "DbType": "Int16",\n "Size": 10\n },\n {\n "Name": " Name",\n "Value": "\u767e\u5c0f\u50e7",\n "DbType": "String",\n "Size": 10\n }\n ]\n }\n}\n')),Object(l.b)("h2",{id:"9165-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.16.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(l.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(l.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(l.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(l.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(l.b)("a",Object(r.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}s.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return d})),n.d(t,"b",(function(){return m}));var r=n(0),a=n.n(r);function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var b=a.a.createContext({}),s=function(e){var t=a.a.useContext(b),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},d=function(e){var t=s(e.components);return a.a.createElement(b.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},u=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,c=e.parentName,b=o(e,["components","mdxType","originalType","parentName"]),d=s(n),u=r,m=d["".concat(c,".").concat(u)]||d[u]||p[u]||l;return n?a.a.createElement(m,i(i({ref:t},b),{},{components:n})):a.a.createElement(m,i({ref:t},b))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,c=new Array(l);c[0]=u;var i={};for(var o in t)hasOwnProperty.call(t,o)&&(i[o]=t[o]);i.originalType=e,i.mdxType="string"==typeof e?e:r,c[1]=i;for(var b=2;bSql \u6a21\u677f",id:"9161-sql-\u6a21\u677f",children:[]},{value:"9.16.2 Sql \u6a21\u677f\u4f18\u7f3a\u70b9",id:"9162-sql-\u6a21\u677f\u4f18\u7f3a\u70b9",children:[{value:"9.16.2.1 \u4f18\u70b9",id:"91621-\u4f18\u70b9",children:[]},{value:"9.16.2.2 \u7f3a\u70b9",id:"91622-\u7f3a\u70b9",children:[]}]},{value:"9.16.3 \u5982\u4f55\u4f7f\u7528",id:"9163-\u5982\u4f55\u4f7f\u7528",children:[{value:"9.16.3.1 \u5e38\u89c4\u4f7f\u7528",id:"91631-\u5e38\u89c4\u4f7f\u7528",children:[]},{value:"9.16.3.2 \u9ad8\u7ea7\u5d4c\u5957",id:"91632-\u9ad8\u7ea7\u5d4c\u5957",children:[]}]},{value:"9.16.4 Sql \u6a21\u677f\u914d\u7f6e",id:"9164-sql-\u6a21\u677f\u914d\u7f6e",children:[{value:"9.16.4.1 \u666e\u901a\u6a21\u5f0f",id:"91641-\u666e\u901a\u6a21\u5f0f",children:[]},{value:"9.16.4.2 \u66f4\u591a\u914d\u7f6e",id:"91642-\u66f4\u591a\u914d\u7f6e",children:[]}]},{value:"9.16.5 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9165-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],b={rightToc:o};function s(e){var t=e.components,n=Object(a.a)(e,["components"]);return Object(l.b)("wrapper",Object(r.a)({},b,n,{components:t,mdxType:"MDXLayout"}),Object(l.b)("h2",{id:"9161-sql-\u6a21\u677f"},"9.16.1 ",Object(l.b)("inlineCode",{parentName:"h2"},"Sql")," \u6a21\u677f"),Object(l.b)("p",null,"\u901a\u5e38\u6211\u4eec\u7a0b\u5e8f\u4e2d\u6267\u884c\u6570\u636e\u5e93\u7684 ",Object(l.b)("inlineCode",{parentName:"p"},"sql")," \u8bed\u53e5\u90fd\u5199\u5728\u4e86\u7a0b\u5e8f\u96c6\u4e2d\uff0c\u968f\u7a0b\u5e8f\u4e00\u8d77\u7f16\u8bd1\uff0c\u540e\u7eed\u9700\u8981\u4fee\u6539\uff0c\u5219\u91cd\u65b0\u7f16\u8bd1\u4ee3\u7801\u3002"),Object(l.b)("p",null,"\u6240\u4ee5\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"Fur")," \u521b\u9020\u51fa\u4e00\u79cd ",Object(l.b)("inlineCode",{parentName:"p"},"Sql")," \u6a21\u677f\u7684\u65b9\u5f0f\uff0c\u7a0b\u5e8f\u6267\u884c ",Object(l.b)("inlineCode",{parentName:"p"},"Sql")," \u65f6\uff0c\u53ea\u9700\u8981\u4f7f\u7528\u7279\u6b8a\u6807\u8bb0\u5373\u53ef\uff1a",Object(l.b)("inlineCode",{parentName:"p"},"#(\u6a21\u677fKey)"),"\uff0c\u8fd9\u4e9b\u771f\u5b9e\u7684 ",Object(l.b)("inlineCode",{parentName:"p"},"Sql")," \u914d\u7f6e\u5728 ",Object(l.b)("inlineCode",{parentName:"p"},".json")," \u6216 ",Object(l.b)("inlineCode",{parentName:"p"},".xml")," \u914d\u7f6e\u6587\u4ef6\u4e2d\u3002"),Object(l.b)("p",null,"\u5982\uff1a"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"Json")," \u65b9\u5f0f")),Object(l.b)("pre",null,Object(l.b)("code",Object(r.a)({parentName:"pre"},{className:"language-json"}),'{\n "Select.User": "select * from User where id > @id"\n}\n')),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("strong",{parentName:"li"},"Xml")," \u65b9\u5f0f")),Object(l.b)("pre",null,Object(l.b)("code",Object(r.a)({parentName:"pre"},{className:"language-xml"}),'\n\n select * from User where id > @id\n\n')),Object(l.b)("h2",{id:"9162-sql-\u6a21\u677f\u4f18\u7f3a\u70b9"},"9.16.2 ",Object(l.b)("inlineCode",{parentName:"h2"},"Sql")," \u6a21\u677f\u4f18\u7f3a\u70b9"),Object(l.b)("h3",{id:"91621-\u4f18\u70b9"},"9.16.2.1 \u4f18\u70b9"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u652f\u6301 ",Object(l.b)("inlineCode",{parentName:"li"},"Sql")," \u52a8\u6001\u914d\u7f6e\uff0c\u53ef\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\u52a8\u6001\u8c03\u914d ",Object(l.b)("inlineCode",{parentName:"li"},"Sql")," \u8bed\u53e5"),Object(l.b)("li",{parentName:"ul"},"\u652f\u6301\u7a0b\u5e8f ",Object(l.b)("inlineCode",{parentName:"li"},"Sql")," \u8bed\u53e5\u52a0\u5bc6")),Object(l.b)("h3",{id:"91622-\u7f3a\u70b9"},"9.16.2.2 \u7f3a\u70b9"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u9700\u589e\u52a0\u5bf9\u5e94\u914d\u7f6e\u6587\u4ef6"),Object(l.b)("li",{parentName:"ul"},"\u4e0d\u5bb9\u6613\u8c03\u8bd5 ",Object(l.b)("inlineCode",{parentName:"li"},"Sql")," \u4ee3\u7801")),Object(l.b)("h2",{id:"9163-\u5982\u4f55\u4f7f\u7528"},"9.16.3 \u5982\u4f55\u4f7f\u7528"),Object(l.b)("p",null,"\u5728\u6267\u884c ",Object(l.b)("inlineCode",{parentName:"p"},"Sql")," \u7684\u65f6\u5019\uff0c\u53ea\u9700\u8981\u586b\u5199\u6307\u5b9a\u6a21\u677f\u5373\u53ef\u3002"),Object(l.b)("h3",{id:"91631-\u5e38\u89c4\u4f7f\u7528"},"9.16.3.1 \u5e38\u89c4\u4f7f\u7528"),Object(l.b)("pre",null,Object(l.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'// \u4ed3\u50a8\u65b9\u5f0f\nvar users = repository.SqlQuery("#(Select.User)", new { id = 1});\n\n// \u61d2\u4eba\u65b9\u5f0f\nvar users = "#(Select.User)".SqlQuery(new { id = 1});\n\n// Sql \u4ee3\u7406\u65b9\u5f0f\n[SqlExecute("#(Select.User)")]\nList GetUser(int id);\n')),Object(l.b)("h3",{id:"91632-\u9ad8\u7ea7\u5d4c\u5957"},"9.16.3.2 \u9ad8\u7ea7\u5d4c\u5957"),Object(l.b)("pre",null,Object(l.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),'var users = repository.SqlQuery(\n@"select * from user u\nleft join #(User.Detail) d on u.Id = d.UserId\nwhere id > @id");\n')),Object(l.b)("h2",{id:"9164-sql-\u6a21\u677f\u914d\u7f6e"},"9.16.4 ",Object(l.b)("inlineCode",{parentName:"h2"},"Sql")," \u6a21\u677f\u914d\u7f6e"),Object(l.b)("h3",{id:"91641-\u666e\u901a\u6a21\u5f0f"},"9.16.4.1 \u666e\u901a\u6a21\u5f0f"),Object(l.b)("pre",null,Object(l.b)("code",Object(r.a)({parentName:"pre"},{className:"language-json"}),'{\n "Select.User": "select * from User"\n}\n')),Object(l.b)("h3",{id:"91642-\u66f4\u591a\u914d\u7f6e"},"9.16.4.2 \u66f4\u591a\u914d\u7f6e"),Object(l.b)("pre",null,Object(l.b)("code",Object(r.a)({parentName:"pre"},{className:"language-json"}),'{\n "Select.User": {\n "Sql": "select * from User where id > @id and Name = @name",\n "Params": [\n {\n "Name": " Id",\n "Value": "1",\n "DbType": "Int16",\n "Size": 10\n },\n {\n "Name": " Name",\n "Value": "\u767e\u5c0f\u50e7",\n "DbType": "String",\n "Size": 10\n }\n ]\n }\n}\n')),Object(l.b)("h2",{id:"9165-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.16.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(l.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(l.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(l.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(l.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(l.b)("a",Object(r.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}s.isMDXComponent=!0},142:function(e,t,n){"use strict";n.d(t,"a",(function(){return d})),n.d(t,"b",(function(){return m}));var r=n(0),a=n.n(r);function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var b=a.a.createContext({}),s=function(e){var t=a.a.useContext(b),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},d=function(e){var t=s(e.components);return a.a.createElement(b.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},u=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,c=e.parentName,b=o(e,["components","mdxType","originalType","parentName"]),d=s(n),u=r,m=d["".concat(c,".").concat(u)]||d[u]||p[u]||l;return n?a.a.createElement(m,i(i({ref:t},b),{},{components:n})):a.a.createElement(m,i({ref:t},b))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,c=new Array(l);c[0]=u;var i={};for(var o in t)hasOwnProperty.call(t,o)&&(i[o]=t[o]);i.originalType=e,i.mdxType="string"==typeof e?e:r,c[1]=i;for(var b=2;bSql \u4ee3\u7406",id:"9171-\u5173\u4e8e-sql-\u4ee3\u7406",children:[]},{value:"9.17.2 \u4e86\u89e3 ISqlDispatchProxy",id:"9172-\u4e86\u89e3-isqldispatchproxy",children:[]},{value:"9.17.3 \u5f00\u59cb\u9886\u7565 Sql \u4ee3\u7406",id:"9173-\u5f00\u59cb\u9886\u7565-sql-\u4ee3\u7406",children:[{value:"9.17.3.1 \u6784\u9020\u51fd\u6570\u65b9\u5f0f",id:"91731-\u6784\u9020\u51fd\u6570\u65b9\u5f0f",children:[]},{value:"9.17.3.2 \u65b9\u6cd5\u53c2\u6570\u6ce8\u5165",id:"91732-\u65b9\u6cd5\u53c2\u6570\u6ce8\u5165",children:[]},{value:"9.17.3.3 App.GetSqlDispatchProxy<ISql>()",id:"91733-appgetsqldispatchproxyisql",children:[]}]},{value:"9.17.4 Sql \u64cd\u4f5c",id:"9174-sql-\u64cd\u4f5c",children:[{value:"9.17.4.1 \u8fd4\u56de DataTable",id:"91741-\u8fd4\u56de-datatable",children:[]},{value:"9.17.4.2 \u8fd4\u56de T \u6216 List<T>",id:"91742-\u8fd4\u56de-t-\u6216-listt",children:[]},{value:"9.17.4.3 \u8fd4\u56de DataSet",id:"91743-\u8fd4\u56de-dataset",children:[]},{value:"9.17.4.4 \u8fd4\u56de Tuple<T1,...T8>",id:"91744-\u8fd4\u56de-tuplet1t8",children:[]},{value:"9.17.4.5 \u8fd4\u56de \u5355\u884c\u5355\u5217",id:"91745-\u8fd4\u56de-\u5355\u884c\u5355\u5217",children:[]},{value:"9.17.4.6 \u65e0\u8fd4\u56de\u503c",id:"91746-\u65e0\u8fd4\u56de\u503c",children:[]}]},{value:"9.17.5 \u5b58\u50a8\u8fc7\u7a0b \u64cd\u4f5c",id:"9175-\u5b58\u50a8\u8fc7\u7a0b-\u64cd\u4f5c",children:[{value:"9.17.5.1 \u8fd4\u56de DataTable",id:"91751-\u8fd4\u56de-datatable",children:[]},{value:"9.17.5.2 \u8fd4\u56de T \u6216 List<T>",id:"91752-\u8fd4\u56de-t-\u6216-listt",children:[]},{value:"9.17.5.3 \u8fd4\u56de DataSet",id:"91753-\u8fd4\u56de-dataset",children:[]},{value:"9.17.5.4 \u8fd4\u56de Tuple(T1,...T8)",id:"91754-\u8fd4\u56de-tuplet1t8",children:[]},{value:"9.17.5.4 \u8fd4\u56de \u5355\u884c\u5355\u5217",id:"91754-\u8fd4\u56de-\u5355\u884c\u5355\u5217",children:[]},{value:"9.17.5.6 \u65e0\u8fd4\u56de\u503c",id:"91756-\u65e0\u8fd4\u56de\u503c",children:[]},{value:"9.17.5.7 \u5e26 OUTPUT/RETURN \u8fd4\u56de",id:"91757-\u5e26-outputreturn-\u8fd4\u56de",children:[]}]},{value:"9.17.5 \u51fd\u6570 \u64cd\u4f5c",id:"9175-\u51fd\u6570-\u64cd\u4f5c",children:[]},{value:"9.17.6 \u4e3a\u4ec0\u4e48\u7528\u5b83\uff1f",id:"9176-\u4e3a\u4ec0\u4e48\u7528\u5b83\uff1f",children:[]},{value:"9.17.7 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9177-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],s={rightToc:o};function b(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(c.b)("wrapper",Object(a.a)({},s,t,{components:n,mdxType:"MDXLayout"}),Object(c.b)("h2",{id:"9171-\u5173\u4e8e-sql-\u4ee3\u7406"},"9.17.1 \u5173\u4e8e ",Object(c.b)("inlineCode",{parentName:"h2"},"Sql")," \u4ee3\u7406"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u4ee3\u7406\u662f ",Object(c.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u5bf9 ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u64cd\u4f5c\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8 ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u4e66\u5199\u6548\u7387\uff0c\u800c\u4e14\u540e\u671f\u6781\u6613\u7ef4\u62a4\u3002"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u4ee3\u7406\u5c5e\u4e8e ",Object(c.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u4e00\u4e2a\u9ad8\u7ea7\u529f\u80fd\u3002"),Object(c.b)("h2",{id:"9172-\u4e86\u89e3-isqldispatchproxy"},"9.17.2 \u4e86\u89e3 ",Object(c.b)("inlineCode",{parentName:"h2"},"ISqlDispatchProxy")),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"ISqlDispatchProxy")," \u63a5\u53e3\u662f ",Object(c.b)("inlineCode",{parentName:"p"},"Fur")," \u5b9e\u73b0",Object(c.b)("strong",{parentName:"p"},"\u88ab\u4ee3\u7406\u63a5\u53e3"),"\u7684\u552f\u4e00\u4f9d\u8d56\uff0c\u4efb\u4f55\u516c\u5f00\u7684\u63a5\u53e3\u4e00\u65e6\u96c6\u6210\u4e86 ",Object(c.b)("inlineCode",{parentName:"p"},"ISqlDispatchProxy")," \u63a5\u53e3\uff0c\u90a3\u4e48\u8fd9\u4e2a\u63a5\u53e3\u5c31\u662f",Object(c.b)("strong",{parentName:"p"},"\u88ab\u6258\u7ba1\u62e6\u622a"),"\u7684 ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u64cd\u4f5c\u63a5\u53e3\u3002"),Object(c.b)("p",null,"\u7b80\u5355\u5b9a\u4e49\u4e00\u4e2a ",Object(c.b)("strong",{parentName:"p"},"Sql \u4ee3\u7406\u63a5\u53e3")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5}","{1,5}":!0}),"using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n }\n}\n")),Object(c.b)("p",null,"\u4e00\u65e6\u8fd9\u4e2a\u63a5\u53e3\u7ee7\u627f\u4e86 ",Object(c.b)("inlineCode",{parentName:"p"},"ISqlDispatchProxy"),"\uff0c\u90a3\u4e48\u5b83\u5c31\u4f1a",Object(c.b)("strong",{parentName:"p"},"\u52a8\u6001\u521b\u5efa\u63a5\u53e3\u5b9e\u4f8b\uff0c\u800c\u4e14\u652f\u6301\u4f9d\u8d56\u6ce8\u5165/\u63a7\u5236\u53cd\u8f6c\u83b7\u53d6\u5b9e\u4f8b"),"\u3002"),Object(c.b)("h2",{id:"9173-\u5f00\u59cb\u9886\u7565-sql-\u4ee3\u7406"},"9.17.3 \u5f00\u59cb\u9886\u7565 ",Object(c.b)("inlineCode",{parentName:"h2"},"Sql")," \u4ee3\u7406"),Object(c.b)("p",null,"\u4e0b\u9762\u6211\u8bb2\u901a\u8fc7\u591a\u4e2a\u4f8b\u5b50\u6765\u6f14\u793a ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u4ee3\u7406\u7684\u7528\u6cd5\uff0c\u4e3a\u4ec0\u4e48\u63a8\u8350\u8fd9\u79cd\u65b9\u5f0f\u64cd\u4f5c ",Object(c.b)("inlineCode",{parentName:"p"},"Sql"),"\u3002"),Object(c.b)("p",null,"\u652f\u6301\u5404\u79cd\u65b9\u5f0f\u83b7\u53d6\u5b9e\u4f8b\uff1a"),Object(c.b)("h3",{id:"91731-\u6784\u9020\u51fd\u6570\u65b9\u5f0f"},"9.17.3.1 \u6784\u9020\u51fd\u6570\u65b9\u5f0f"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1-2}","{1-2}":!0}),"private readonly Isql _sql;\npublic FurService(Isql sql)\n{\n _sql = sql;\n}\n")),Object(c.b)("h3",{id:"91732-\u65b9\u6cd5\u53c2\u6570\u6ce8\u5165"},"9.17.3.2 \u65b9\u6cd5\u53c2\u6570\u6ce8\u5165"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),"public async Task> GetAll([FromServices] Isql, string keyword)\n{\n}\n")),Object(c.b)("h3",{id:"91733-appgetsqldispatchproxyisql"},"9.17.3.3 ",Object(c.b)("inlineCode",{parentName:"h3"},"App.GetSqlDispatchProxy()")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var sql = App.GetSqlDispatchProxy();\n")),Object(c.b)("h2",{id:"9174-sql-\u64cd\u4f5c"},"9.17.4 ",Object(c.b)("inlineCode",{parentName:"h2"},"Sql")," \u64cd\u4f5c"),Object(c.b)("h3",{id:"91741-\u8fd4\u56de-datatable"},"9.17.4.1 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"DataTable")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8,12,16,20}","{8,12,16,20}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u57fa\u5143\u7c7b\u578b\n [SqlExecute("select * from person where id >@id and name like %@name%")]\n DataTable GetPerson(int id, string name);\n\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u5bf9\u8c61\u7c7b\u578b\n [SqlExecute("select * from person where id >@id and name like %@name%")]\n DataTable GetPerson(MyParam paras));\n\n // \u6267\u884c\u5b58\u50a8\u8fc7\u7a0b sql\uff0c\u652f\u6301\u8bbe\u7f6e\u53c2\u6570\u7c7b\u578b\n [SqlExecute("exec PROP_NAME @id", CommandType = CommandType.StoredProcedure)]\n DataTable GetPerson(int id));\n\n // \u652f\u6301\u591a\u6570\u636e\u5e93\u64cd\u4f5c\n [SqlExecute("select * from person", DbContextLocator = typeof(MySqlDbContextLocator))]\n DataTable GetPerson());\n\n // \u5f02\u6b65\u65b9\u5f0f\n [SqlExecute("select * from person", DbContextLocator = typeof(MySqlDbContextLocator))]\n Task GetPersonAsync());\n }\n}\n')),Object(c.b)("div",{className:"admonition admonition-important alert alert--info"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u5173\u4e8e\u53c2\u6570")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u4ee3\u7406\u53c2\u6570\u67e5\u627e\u89c4\u5219\uff1a"),Object(c.b)("p",{parentName:"div"},"\u5982\u679c\u65b9\u6cd5\u7684\u53c2\u6570\u662f ",Object(c.b)("inlineCode",{parentName:"p"},"\u57fa\u5143\u7c7b\u578b"),"\uff08\u6216 ",Object(c.b)("inlineCode",{parentName:"p"},"string"),"\u3001",Object(c.b)("inlineCode",{parentName:"p"},"\u503c\u7c7b\u578b"),"\uff09\uff0c\u5219\u81ea\u52a8\u5c06\u8fd9\u4e9b\u7c7b\u578b\u7ec4\u5408\u6210 ",Object(c.b)("inlineCode",{parentName:"p"},"Dictionary")," \u4f5c\u4e3a ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u53c2\u6570\u3002\u547d\u4ee4\u53c2\u6570\u53ef\u4f7f\u7528\u65b9\u6cd5\u540c\u540d\u53c2\u6570\u52a0 ",Object(c.b)("inlineCode",{parentName:"p"},"@")," \u7b26\u53f7\u3002"),Object(c.b)("p",{parentName:"div"},"\u5982\u679c\u65b9\u6cd5\u7684\u53c2\u6570\u662f ",Object(c.b)("inlineCode",{parentName:"p"},"\u7c7b\u7c7b\u578b"),"\uff0c\u90a3\u4e48\u81ea\u52a8\u904d\u5386\u8be5\u7c7b\u516c\u5f00\u5b9e\u4f8b\u5c5e\u6027\u751f\u6210 ",Object(c.b)("inlineCode",{parentName:"p"},"DbParameter[]")," \u6570\u7ec4\uff0c\u6bcf\u4e00\u4e2a\u5c5e\u6027\u540d\u90fd\u5c06\u662f\u547d\u4ee4\u53c2\u6570\uff0c\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff0c\u5982\uff1a"),Object(c.b)("pre",{parentName:"div"},Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"public class MyModel\n{\n public int Id {get;set;}\n public string Name {get; set;}\n}\n")),Object(c.b)("p",{parentName:"div"},"\u90a3\u4e48 ",Object(c.b)("inlineCode",{parentName:"p"},"sql")," \u8bed\u53e5\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u5c5e\u6027\u540d\u4f5c\u4e3a\u53c2\u6570\uff1a"),Object(c.b)("pre",{parentName:"div"},Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql"}),"select * from person where id > @id and name = @name;\n")))),Object(c.b)("h3",{id:"91742-\u8fd4\u56de-t-\u6216-listt"},"9.17.4.2 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"T \u6216 List")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8,12,16,20}","{8,12,16,20}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u57fa\u5143\u7c7b\u578b\n [SqlExecute("select * from person where id >@id and name like %@name%")]\n List GetPerson(int id, string name);\n\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u5bf9\u8c61\u7c7b\u578b\n [SqlExecute("select * from person where id >@id and name like %@name%")]\n List GetPerson(MyParam paras));\n\n // \u6267\u884c\u5b58\u50a8\u8fc7\u7a0b sql\uff0c\u652f\u6301\u8bbe\u7f6e\u53c2\u6570\u7c7b\u578b\n [SqlExecute("exec PROP_NAME @id", CommandType = CommandType.StoredProcedure)]\n Person GetPerson(int id));\n\n // \u652f\u6301\u591a\u6570\u636e\u5e93\u64cd\u4f5c\n [SqlExecute("select * from person", DbContextLocator = typeof(MySqlDbContextLocator))]\n List GetPerson());\n\n // \u5f02\u6b65\u65b9\u5f0f\n [SqlExecute("select * from person", DbContextLocator = typeof(MySqlDbContextLocator))]\n Task> GetPersonAsync());\n }\n}\n')),Object(c.b)("h3",{id:"91743-\u8fd4\u56de-dataset"},"9.17.4.3 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"DataSet")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8-10,14-16,20-22,26-28,32-35}","{8-10,14-16,20-22,26-28,32-35}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u57fa\u5143\u7c7b\u578b\n [SqlExecute(@"\n select * from person where id >@id and name like %@name%;\n select top 10 * from student where Id >@id;")]\n DataSet GetData(int id, string name);\n\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u5bf9\u8c61\u7c7b\u578b\n [SqlExecute(@"\n select * from person where id >@id and name like %@name%;\n select top 10 * from student where Id >@id;")]\n DataSet GetData(MyParam paras));\n\n // \u6267\u884c\u5b58\u50a8\u8fc7\u7a0b sql\uff0c\u652f\u6301\u8bbe\u7f6e\u53c2\u6570\u7c7b\u578b\n [SqlExecute(@"\n exec PROP_NAME @id;\n select * from person;", CommandType = CommandType.StoredProcedure)]\n DataSet GetData(int id));\n\n // \u652f\u6301\u591a\u6570\u636e\u5e93\u64cd\u4f5c\n [SqlExecute(@"\n select * from person;\n select * from student;", DbContextLocator = typeof(MySqlDbContextLocator))]\n DataSet GetData());\n\n // \u5f02\u6b65\u65b9\u5f0f\n [SqlExecute(@"\n select * from person;\n select * from student;\n select 1;", DbContextLocator = typeof(MySqlDbContextLocator))]\n Task GetDataAsync());\n }\n}\n')),Object(c.b)("h3",{id:"91744-\u8fd4\u56de-tuplet1t8"},"9.17.4.4 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"Tuple")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8-10,14-16,20-22,26-28,32-35}","{8-10,14-16,20-22,26-28,32-35}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u57fa\u5143\u7c7b\u578b\n [SqlExecute(@"\n select * from person where id >@id and name like %@name%;\n select top 10 * from student where Id >@id;")]\n (List,List) GetData(int id, string name);\n\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u5bf9\u8c61\u7c7b\u578b\n [SqlExecute(@"\n select * from person where id >@id and name like %@name%;\n select top 10 * from student where Id >@id;")]\n (List,List) GetData(MyParam paras));\n\n // \u6267\u884c\u5b58\u50a8\u8fc7\u7a0b sql\uff0c\u652f\u6301\u8bbe\u7f6e\u53c2\u6570\u7c7b\u578b\n [SqlExecute(@"\n exec PROP_NAME @id;\n select * from person;", CommandType = CommandType.StoredProcedure)]\n (List,List) GetData(int id));\n\n // \u652f\u6301\u591a\u6570\u636e\u5e93\u64cd\u4f5c\n [SqlExecute(@"\n select * from person;\n select * from student;", DbContextLocator = typeof(MySqlDbContextLocator))]\n (List,List) GetData());\n\n // \u5f02\u6b65\u65b9\u5f0f\n [SqlExecute(@"\n select * from person;\n select * from student;\n select 1;", DbContextLocator = typeof(MySqlDbContextLocator))]\n Task<(List,List,int)> GetDataAsync());\n }\n}\n')),Object(c.b)("h3",{id:"91745-\u8fd4\u56de-\u5355\u884c\u5355\u5217"},"9.17.4.5 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"\u5355\u884c\u5355\u5217")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlExecute("select Name from person where id = @id")]\n string GetValue(int id);\n\n [SqlExecute("select age from person where id = @id")]\n int GetValue(int id);\n\n [SqlExecute("select Name from person where id = @id")]\n Task GetValueAsync(int id);\n }\n}\n')),Object(c.b)("h3",{id:"91746-\u65e0\u8fd4\u56de\u503c"},"9.17.4.6 \u65e0\u8fd4\u56de\u503c"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlExecute("insert into person(Name,Age) values(@name,@age)")]\n void Insert(MyParam dto);\n\n [SqlExecute("delete from person where id = @id")]\n void Delete(int id);\n\n [SqlExecute("update person set name=@name where id=@id")]\n void Update(int id, string name);\n }\n}\n')),Object(c.b)("h2",{id:"9175-\u5b58\u50a8\u8fc7\u7a0b-\u64cd\u4f5c"},"9.17.5 ",Object(c.b)("inlineCode",{parentName:"h2"},"\u5b58\u50a8\u8fc7\u7a0b")," \u64cd\u4f5c"),Object(c.b)("h3",{id:"91751-\u8fd4\u56de-datatable"},"9.17.5.1 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"DataTable")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlProcedure("PROC_Name")]\n DataTable GetPersons(MyParam dto);\n\n [SqlProcedure("PROC_Name")]\n DataTable GetPersons(int id);\n\n [SqlProcedure("PROC_Name")]\n DataTable GetPersons(int id, string name);\n }\n}\n')),Object(c.b)("h3",{id:"91752-\u8fd4\u56de-t-\u6216-listt"},"9.17.5.2 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"T \u6216 List")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlProcedure("PROC_Name")]\n List GetPersons(MyParam dto);\n\n [SqlProcedure("PROC_Name")]\n List GetPersons(int id);\n\n [SqlProcedure("PROC_Name")]\n Person GetPersons(int id, string name);\n }\n}\n')),Object(c.b)("h3",{id:"91753-\u8fd4\u56de-dataset"},"9.17.5.3 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"DataSet")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlProcedure("PROC_Name")]\n DataSet GetData(MyParam dto);\n\n [SqlProcedure("PROC_Name")]\n DataSet GetData(int id);\n\n [SqlProcedure("PROC_Name")]\n DataSet GetData(int id, string name);\n }\n}\n')),Object(c.b)("h3",{id:"91754-\u8fd4\u56de-tuplet1t8"},"9.17.5.4 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"Tuple(T1,...T8)")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlProcedure("PROC_Name")]\n (List, List) GetData(MyParam dto);\n\n [SqlProcedure("PROC_Name")]\n (List, List) GetData(int id);\n\n [SqlProcedure("PROC_Name")]\n (List, List, Person, int) GetData(int id, string name);\n }\n}\n')),Object(c.b)("h3",{id:"91754-\u8fd4\u56de-\u5355\u884c\u5355\u5217"},"9.17.5.4 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"\u5355\u884c\u5355\u5217")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlProcedure("PROC_Name")]\n object GetValue(MyParam dto);\n\n [SqlProcedure("PROC_Name")]\n string GetValue(int id);\n\n [SqlProcedure("PROC_Name")]\n int GetValue(int id, string name);\n }\n}\n')),Object(c.b)("h3",{id:"91756-\u65e0\u8fd4\u56de\u503c"},"9.17.5.6 \u65e0\u8fd4\u56de\u503c"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlProcedure("PROC_Name")]\n void GetValue(MyParam dto);\n\n [SqlProcedure("PROC_Name")]\n void GetValue(int id);\n\n [SqlProcedure("PROC_Name")]\n void GetValue(int id, string name);\n }\n}\n')),Object(c.b)("h3",{id:"91757-\u5e26-outputreturn-\u8fd4\u56de"},"9.17.5.7 \u5e26 ",Object(c.b)("inlineCode",{parentName:"h3"},"OUTPUT/RETURN")," \u8fd4\u56de"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlProcedure("PROC_Name")]\n ProcedureOutputResult GetOutput(ProcOutputModel pams);\n\n [SqlProcedure("PROC_Name")]\n ProcedureOutputResult GetOutput(ProcOutputModel pams);\n\n [SqlProcedure("PROC_Name")]\n ProcedureOutputResult<(List, List)> GetOutput(ProcOutputModel pams);\n }\n}\n')),Object(c.b)("h2",{id:"9175-\u51fd\u6570-\u64cd\u4f5c"},"9.17.5 ",Object(c.b)("inlineCode",{parentName:"h2"},"\u51fd\u6570")," \u64cd\u4f5c"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10}","{7,10}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlFunction("FN_Name")] // \u6807\u91cf\u51fd\u6570\n string GetValue(MyParam dto);\n\n [SqlProcedure("FN_Name")] // \u8868\u503c\u51fd\u6570\n List GetPersons(int id);\n }\n}\n')),Object(c.b)("div",{className:"admonition admonition-important alert alert--info"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u8865\u5145\u8bf4\u660e")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u4ee3\u7406\u4f1a\u81ea\u52a8\u5224\u65ad\u8fd4\u56de\u503c\u7136\u540e\u81ea\u52a8\u6267\u884c\u7279\u5b9a\u51fd\u6570\u7c7b\u578b\u3002"))),Object(c.b)("h2",{id:"9176-\u4e3a\u4ec0\u4e48\u7528\u5b83\uff1f"},"9.17.6 \u4e3a\u4ec0\u4e48\u7528\u5b83\uff1f"),Object(c.b)("p",null,"\u901a\u8fc7\u4e0a\u9762\u7684\u4f8b\u5b50\u5927\u5bb6\u5c31\u53ef\u4ee5\u4e86\u89e3\uff0c\u8fd9\u79cd\u65b9\u5f0f\u64cd\u4f5c ",Object(c.b)("inlineCode",{parentName:"p"},"sql")," \u975e\u5e38\u7b80\u5355\uff0c\u800c\u4e14\u6781\u6613\u7ef4\u62a4\u3002\u5927\u5bb6\u4e0d\u7528\u53bb\u5173\u7cfb\u8fd4\u56de\u503c\uff0c\u5173\u5fc3\u7528\u54ea\u4e2a\u65b9\u6cd5\uff0c\u6240\u6709\u4e1c\u897f\u4f1a\u81ea\u52a8\u7ed9\u4f60\u5904\u7406\u597d\u3002"),Object(c.b)("p",null,"\u6240\u4ee5\uff0c\u5982\u679c\u9700\u8981\u7528 ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u64cd\u4f5c\uff0c\u63a8\u8350\u4f7f\u7528 ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u9ad8\u7ea7\u4ee3\u7406\u3002"),Object(c.b)("h2",{id:"9177-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.17.7 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}b.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return d})),t.d(n,"b",(function(){return u}));var a=t(0),r=t.n(a);function c(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function l(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var s=r.a.createContext({}),b=function(e){var n=r.a.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):l(l({},n),e)),t},d=function(e){var n=b(e.components);return r.a.createElement(s.Provider,{value:n},e.children)},p={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},m=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,c=e.originalType,i=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),d=b(t),m=a,u=d["".concat(i,".").concat(m)]||d[m]||p[m]||c;return t?r.a.createElement(u,l(l({ref:n},s),{},{components:t})):r.a.createElement(u,l({ref:n},s))}));function u(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var c=t.length,i=new Array(c);i[0]=m;var l={};for(var o in n)hasOwnProperty.call(n,o)&&(l[o]=n[o]);l.originalType=e,l.mdxType="string"==typeof e?e:a,i[1]=l;for(var s=2;sSql \u4ee3\u7406",id:"9171-\u5173\u4e8e-sql-\u4ee3\u7406",children:[]},{value:"9.17.2 \u4e86\u89e3 ISqlDispatchProxy",id:"9172-\u4e86\u89e3-isqldispatchproxy",children:[]},{value:"9.17.3 \u5f00\u59cb\u9886\u7565 Sql \u4ee3\u7406",id:"9173-\u5f00\u59cb\u9886\u7565-sql-\u4ee3\u7406",children:[{value:"9.17.3.1 \u6784\u9020\u51fd\u6570\u65b9\u5f0f",id:"91731-\u6784\u9020\u51fd\u6570\u65b9\u5f0f",children:[]},{value:"9.17.3.2 \u65b9\u6cd5\u53c2\u6570\u6ce8\u5165",id:"91732-\u65b9\u6cd5\u53c2\u6570\u6ce8\u5165",children:[]},{value:"9.17.3.3 App.GetSqlDispatchProxy<ISql>()",id:"91733-appgetsqldispatchproxyisql",children:[]}]},{value:"9.17.4 Sql \u64cd\u4f5c",id:"9174-sql-\u64cd\u4f5c",children:[{value:"9.17.4.1 \u8fd4\u56de DataTable",id:"91741-\u8fd4\u56de-datatable",children:[]},{value:"9.17.4.2 \u8fd4\u56de T \u6216 List<T>",id:"91742-\u8fd4\u56de-t-\u6216-listt",children:[]},{value:"9.17.4.3 \u8fd4\u56de DataSet",id:"91743-\u8fd4\u56de-dataset",children:[]},{value:"9.17.4.4 \u8fd4\u56de Tuple<T1,...T8>",id:"91744-\u8fd4\u56de-tuplet1t8",children:[]},{value:"9.17.4.5 \u8fd4\u56de \u5355\u884c\u5355\u5217",id:"91745-\u8fd4\u56de-\u5355\u884c\u5355\u5217",children:[]},{value:"9.17.4.6 \u65e0\u8fd4\u56de\u503c",id:"91746-\u65e0\u8fd4\u56de\u503c",children:[]}]},{value:"9.17.5 \u5b58\u50a8\u8fc7\u7a0b \u64cd\u4f5c",id:"9175-\u5b58\u50a8\u8fc7\u7a0b-\u64cd\u4f5c",children:[{value:"9.17.5.1 \u8fd4\u56de DataTable",id:"91751-\u8fd4\u56de-datatable",children:[]},{value:"9.17.5.2 \u8fd4\u56de T \u6216 List<T>",id:"91752-\u8fd4\u56de-t-\u6216-listt",children:[]},{value:"9.17.5.3 \u8fd4\u56de DataSet",id:"91753-\u8fd4\u56de-dataset",children:[]},{value:"9.17.5.4 \u8fd4\u56de Tuple(T1,...T8)",id:"91754-\u8fd4\u56de-tuplet1t8",children:[]},{value:"9.17.5.4 \u8fd4\u56de \u5355\u884c\u5355\u5217",id:"91754-\u8fd4\u56de-\u5355\u884c\u5355\u5217",children:[]},{value:"9.17.5.6 \u65e0\u8fd4\u56de\u503c",id:"91756-\u65e0\u8fd4\u56de\u503c",children:[]},{value:"9.17.5.7 \u5e26 OUTPUT/RETURN \u8fd4\u56de",id:"91757-\u5e26-outputreturn-\u8fd4\u56de",children:[]}]},{value:"9.17.5 \u51fd\u6570 \u64cd\u4f5c",id:"9175-\u51fd\u6570-\u64cd\u4f5c",children:[]},{value:"9.17.6 \u4e3a\u4ec0\u4e48\u7528\u5b83\uff1f",id:"9176-\u4e3a\u4ec0\u4e48\u7528\u5b83\uff1f",children:[]},{value:"9.17.7 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9177-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],s={rightToc:o};function b(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(c.b)("wrapper",Object(a.a)({},s,t,{components:n,mdxType:"MDXLayout"}),Object(c.b)("h2",{id:"9171-\u5173\u4e8e-sql-\u4ee3\u7406"},"9.17.1 \u5173\u4e8e ",Object(c.b)("inlineCode",{parentName:"h2"},"Sql")," \u4ee3\u7406"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u4ee3\u7406\u662f ",Object(c.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u5bf9 ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u64cd\u4f5c\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8 ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u4e66\u5199\u6548\u7387\uff0c\u800c\u4e14\u540e\u671f\u6781\u6613\u7ef4\u62a4\u3002"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u4ee3\u7406\u5c5e\u4e8e ",Object(c.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u4e00\u4e2a\u9ad8\u7ea7\u529f\u80fd\u3002"),Object(c.b)("h2",{id:"9172-\u4e86\u89e3-isqldispatchproxy"},"9.17.2 \u4e86\u89e3 ",Object(c.b)("inlineCode",{parentName:"h2"},"ISqlDispatchProxy")),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"ISqlDispatchProxy")," \u63a5\u53e3\u662f ",Object(c.b)("inlineCode",{parentName:"p"},"Fur")," \u5b9e\u73b0",Object(c.b)("strong",{parentName:"p"},"\u88ab\u4ee3\u7406\u63a5\u53e3"),"\u7684\u552f\u4e00\u4f9d\u8d56\uff0c\u4efb\u4f55\u516c\u5f00\u7684\u63a5\u53e3\u4e00\u65e6\u96c6\u6210\u4e86 ",Object(c.b)("inlineCode",{parentName:"p"},"ISqlDispatchProxy")," \u63a5\u53e3\uff0c\u90a3\u4e48\u8fd9\u4e2a\u63a5\u53e3\u5c31\u662f",Object(c.b)("strong",{parentName:"p"},"\u88ab\u6258\u7ba1\u62e6\u622a"),"\u7684 ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u64cd\u4f5c\u63a5\u53e3\u3002"),Object(c.b)("p",null,"\u7b80\u5355\u5b9a\u4e49\u4e00\u4e2a ",Object(c.b)("strong",{parentName:"p"},"Sql \u4ee3\u7406\u63a5\u53e3")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5}","{1,5}":!0}),"using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n }\n}\n")),Object(c.b)("p",null,"\u4e00\u65e6\u8fd9\u4e2a\u63a5\u53e3\u7ee7\u627f\u4e86 ",Object(c.b)("inlineCode",{parentName:"p"},"ISqlDispatchProxy"),"\uff0c\u90a3\u4e48\u5b83\u5c31\u4f1a",Object(c.b)("strong",{parentName:"p"},"\u52a8\u6001\u521b\u5efa\u63a5\u53e3\u5b9e\u4f8b\uff0c\u800c\u4e14\u652f\u6301\u4f9d\u8d56\u6ce8\u5165/\u63a7\u5236\u53cd\u8f6c\u83b7\u53d6\u5b9e\u4f8b"),"\u3002"),Object(c.b)("h2",{id:"9173-\u5f00\u59cb\u9886\u7565-sql-\u4ee3\u7406"},"9.17.3 \u5f00\u59cb\u9886\u7565 ",Object(c.b)("inlineCode",{parentName:"h2"},"Sql")," \u4ee3\u7406"),Object(c.b)("p",null,"\u4e0b\u9762\u6211\u8bb2\u901a\u8fc7\u591a\u4e2a\u4f8b\u5b50\u6765\u6f14\u793a ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u4ee3\u7406\u7684\u7528\u6cd5\uff0c\u4e3a\u4ec0\u4e48\u63a8\u8350\u8fd9\u79cd\u65b9\u5f0f\u64cd\u4f5c ",Object(c.b)("inlineCode",{parentName:"p"},"Sql"),"\u3002"),Object(c.b)("p",null,"\u652f\u6301\u5404\u79cd\u65b9\u5f0f\u83b7\u53d6\u5b9e\u4f8b\uff1a"),Object(c.b)("h3",{id:"91731-\u6784\u9020\u51fd\u6570\u65b9\u5f0f"},"9.17.3.1 \u6784\u9020\u51fd\u6570\u65b9\u5f0f"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1-2}","{1-2}":!0}),"private readonly Isql _sql;\npublic FurService(Isql sql)\n{\n _sql = sql;\n}\n")),Object(c.b)("h3",{id:"91732-\u65b9\u6cd5\u53c2\u6570\u6ce8\u5165"},"9.17.3.2 \u65b9\u6cd5\u53c2\u6570\u6ce8\u5165"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),"public async Task> GetAll([FromServices] Isql, string keyword)\n{\n}\n")),Object(c.b)("h3",{id:"91733-appgetsqldispatchproxyisql"},"9.17.3.3 ",Object(c.b)("inlineCode",{parentName:"h3"},"App.GetSqlDispatchProxy()")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"var sql = App.GetSqlDispatchProxy();\n")),Object(c.b)("h2",{id:"9174-sql-\u64cd\u4f5c"},"9.17.4 ",Object(c.b)("inlineCode",{parentName:"h2"},"Sql")," \u64cd\u4f5c"),Object(c.b)("h3",{id:"91741-\u8fd4\u56de-datatable"},"9.17.4.1 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"DataTable")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8,12,16,20}","{8,12,16,20}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u57fa\u5143\u7c7b\u578b\n [SqlExecute("select * from person where id >@id and name like %@name%")]\n DataTable GetPerson(int id, string name);\n\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u5bf9\u8c61\u7c7b\u578b\n [SqlExecute("select * from person where id >@id and name like %@name%")]\n DataTable GetPerson(MyParam paras));\n\n // \u6267\u884c\u5b58\u50a8\u8fc7\u7a0b sql\uff0c\u652f\u6301\u8bbe\u7f6e\u53c2\u6570\u7c7b\u578b\n [SqlExecute("exec PROP_NAME @id", CommandType = CommandType.StoredProcedure)]\n DataTable GetPerson(int id));\n\n // \u652f\u6301\u591a\u6570\u636e\u5e93\u64cd\u4f5c\n [SqlExecute("select * from person", DbContextLocator = typeof(MySqlDbContextLocator))]\n DataTable GetPerson());\n\n // \u5f02\u6b65\u65b9\u5f0f\n [SqlExecute("select * from person", DbContextLocator = typeof(MySqlDbContextLocator))]\n Task GetPersonAsync());\n }\n}\n')),Object(c.b)("div",{className:"admonition admonition-important alert alert--info"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u5173\u4e8e\u53c2\u6570")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u4ee3\u7406\u53c2\u6570\u67e5\u627e\u89c4\u5219\uff1a"),Object(c.b)("p",{parentName:"div"},"\u5982\u679c\u65b9\u6cd5\u7684\u53c2\u6570\u662f ",Object(c.b)("inlineCode",{parentName:"p"},"\u57fa\u5143\u7c7b\u578b"),"\uff08\u6216 ",Object(c.b)("inlineCode",{parentName:"p"},"string"),"\u3001",Object(c.b)("inlineCode",{parentName:"p"},"\u503c\u7c7b\u578b"),"\uff09\uff0c\u5219\u81ea\u52a8\u5c06\u8fd9\u4e9b\u7c7b\u578b\u7ec4\u5408\u6210 ",Object(c.b)("inlineCode",{parentName:"p"},"Dictionary")," \u4f5c\u4e3a ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u53c2\u6570\u3002\u547d\u4ee4\u53c2\u6570\u53ef\u4f7f\u7528\u65b9\u6cd5\u540c\u540d\u53c2\u6570\u52a0 ",Object(c.b)("inlineCode",{parentName:"p"},"@")," \u7b26\u53f7\u3002"),Object(c.b)("p",{parentName:"div"},"\u5982\u679c\u65b9\u6cd5\u7684\u53c2\u6570\u662f ",Object(c.b)("inlineCode",{parentName:"p"},"\u7c7b\u7c7b\u578b"),"\uff0c\u90a3\u4e48\u81ea\u52a8\u904d\u5386\u8be5\u7c7b\u516c\u5f00\u5b9e\u4f8b\u5c5e\u6027\u751f\u6210 ",Object(c.b)("inlineCode",{parentName:"p"},"DbParameter[]")," \u6570\u7ec4\uff0c\u6bcf\u4e00\u4e2a\u5c5e\u6027\u540d\u90fd\u5c06\u662f\u547d\u4ee4\u53c2\u6570\uff0c\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff0c\u5982\uff1a"),Object(c.b)("pre",{parentName:"div"},Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),"public class MyModel\n{\n public int Id {get;set;}\n public string Name {get; set;}\n}\n")),Object(c.b)("p",{parentName:"div"},"\u90a3\u4e48 ",Object(c.b)("inlineCode",{parentName:"p"},"sql")," \u8bed\u53e5\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u5c5e\u6027\u540d\u4f5c\u4e3a\u53c2\u6570\uff1a"),Object(c.b)("pre",{parentName:"div"},Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-sql"}),"select * from person where id > @id and name = @name;\n")))),Object(c.b)("h3",{id:"91742-\u8fd4\u56de-t-\u6216-listt"},"9.17.4.2 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"T \u6216 List")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8,12,16,20}","{8,12,16,20}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u57fa\u5143\u7c7b\u578b\n [SqlExecute("select * from person where id >@id and name like %@name%")]\n List GetPerson(int id, string name);\n\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u5bf9\u8c61\u7c7b\u578b\n [SqlExecute("select * from person where id >@id and name like %@name%")]\n List GetPerson(MyParam paras));\n\n // \u6267\u884c\u5b58\u50a8\u8fc7\u7a0b sql\uff0c\u652f\u6301\u8bbe\u7f6e\u53c2\u6570\u7c7b\u578b\n [SqlExecute("exec PROP_NAME @id", CommandType = CommandType.StoredProcedure)]\n Person GetPerson(int id));\n\n // \u652f\u6301\u591a\u6570\u636e\u5e93\u64cd\u4f5c\n [SqlExecute("select * from person", DbContextLocator = typeof(MySqlDbContextLocator))]\n List GetPerson());\n\n // \u5f02\u6b65\u65b9\u5f0f\n [SqlExecute("select * from person", DbContextLocator = typeof(MySqlDbContextLocator))]\n Task> GetPersonAsync());\n }\n}\n')),Object(c.b)("h3",{id:"91743-\u8fd4\u56de-dataset"},"9.17.4.3 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"DataSet")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8-10,14-16,20-22,26-28,32-35}","{8-10,14-16,20-22,26-28,32-35}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u57fa\u5143\u7c7b\u578b\n [SqlExecute(@"\n select * from person where id >@id and name like %@name%;\n select top 10 * from student where Id >@id;")]\n DataSet GetData(int id, string name);\n\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u5bf9\u8c61\u7c7b\u578b\n [SqlExecute(@"\n select * from person where id >@id and name like %@name%;\n select top 10 * from student where Id >@id;")]\n DataSet GetData(MyParam paras));\n\n // \u6267\u884c\u5b58\u50a8\u8fc7\u7a0b sql\uff0c\u652f\u6301\u8bbe\u7f6e\u53c2\u6570\u7c7b\u578b\n [SqlExecute(@"\n exec PROP_NAME @id;\n select * from person;", CommandType = CommandType.StoredProcedure)]\n DataSet GetData(int id));\n\n // \u652f\u6301\u591a\u6570\u636e\u5e93\u64cd\u4f5c\n [SqlExecute(@"\n select * from person;\n select * from student;", DbContextLocator = typeof(MySqlDbContextLocator))]\n DataSet GetData());\n\n // \u5f02\u6b65\u65b9\u5f0f\n [SqlExecute(@"\n select * from person;\n select * from student;\n select 1;", DbContextLocator = typeof(MySqlDbContextLocator))]\n Task GetDataAsync());\n }\n}\n')),Object(c.b)("h3",{id:"91744-\u8fd4\u56de-tuplet1t8"},"9.17.4.4 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"Tuple")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{8-10,14-16,20-22,26-28,32-35}","{8-10,14-16,20-22,26-28,32-35}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u57fa\u5143\u7c7b\u578b\n [SqlExecute(@"\n select * from person where id >@id and name like %@name%;\n select top 10 * from student where Id >@id;")]\n (List,List) GetData(int id, string name);\n\n // \u6267\u884csql\u5e76\u4f20\u5165\u53c2\u6570\uff0c\u5bf9\u8c61\u7c7b\u578b\n [SqlExecute(@"\n select * from person where id >@id and name like %@name%;\n select top 10 * from student where Id >@id;")]\n (List,List) GetData(MyParam paras));\n\n // \u6267\u884c\u5b58\u50a8\u8fc7\u7a0b sql\uff0c\u652f\u6301\u8bbe\u7f6e\u53c2\u6570\u7c7b\u578b\n [SqlExecute(@"\n exec PROP_NAME @id;\n select * from person;", CommandType = CommandType.StoredProcedure)]\n (List,List) GetData(int id));\n\n // \u652f\u6301\u591a\u6570\u636e\u5e93\u64cd\u4f5c\n [SqlExecute(@"\n select * from person;\n select * from student;", DbContextLocator = typeof(MySqlDbContextLocator))]\n (List,List) GetData());\n\n // \u5f02\u6b65\u65b9\u5f0f\n [SqlExecute(@"\n select * from person;\n select * from student;\n select 1;", DbContextLocator = typeof(MySqlDbContextLocator))]\n Task<(List,List,int)> GetDataAsync());\n }\n}\n')),Object(c.b)("h3",{id:"91745-\u8fd4\u56de-\u5355\u884c\u5355\u5217"},"9.17.4.5 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"\u5355\u884c\u5355\u5217")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlExecute("select Name from person where id = @id")]\n string GetValue(int id);\n\n [SqlExecute("select age from person where id = @id")]\n int GetValue(int id);\n\n [SqlExecute("select Name from person where id = @id")]\n Task GetValueAsync(int id);\n }\n}\n')),Object(c.b)("h3",{id:"91746-\u65e0\u8fd4\u56de\u503c"},"9.17.4.6 \u65e0\u8fd4\u56de\u503c"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlExecute("insert into person(Name,Age) values(@name,@age)")]\n void Insert(MyParam dto);\n\n [SqlExecute("delete from person where id = @id")]\n void Delete(int id);\n\n [SqlExecute("update person set name=@name where id=@id")]\n void Update(int id, string name);\n }\n}\n')),Object(c.b)("h2",{id:"9175-\u5b58\u50a8\u8fc7\u7a0b-\u64cd\u4f5c"},"9.17.5 ",Object(c.b)("inlineCode",{parentName:"h2"},"\u5b58\u50a8\u8fc7\u7a0b")," \u64cd\u4f5c"),Object(c.b)("h3",{id:"91751-\u8fd4\u56de-datatable"},"9.17.5.1 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"DataTable")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlProcedure("PROC_Name")]\n DataTable GetPersons(MyParam dto);\n\n [SqlProcedure("PROC_Name")]\n DataTable GetPersons(int id);\n\n [SqlProcedure("PROC_Name")]\n DataTable GetPersons(int id, string name);\n }\n}\n')),Object(c.b)("h3",{id:"91752-\u8fd4\u56de-t-\u6216-listt"},"9.17.5.2 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"T \u6216 List")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlProcedure("PROC_Name")]\n List GetPersons(MyParam dto);\n\n [SqlProcedure("PROC_Name")]\n List GetPersons(int id);\n\n [SqlProcedure("PROC_Name")]\n Person GetPersons(int id, string name);\n }\n}\n')),Object(c.b)("h3",{id:"91753-\u8fd4\u56de-dataset"},"9.17.5.3 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"DataSet")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlProcedure("PROC_Name")]\n DataSet GetData(MyParam dto);\n\n [SqlProcedure("PROC_Name")]\n DataSet GetData(int id);\n\n [SqlProcedure("PROC_Name")]\n DataSet GetData(int id, string name);\n }\n}\n')),Object(c.b)("h3",{id:"91754-\u8fd4\u56de-tuplet1t8"},"9.17.5.4 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"Tuple(T1,...T8)")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlProcedure("PROC_Name")]\n (List, List) GetData(MyParam dto);\n\n [SqlProcedure("PROC_Name")]\n (List, List) GetData(int id);\n\n [SqlProcedure("PROC_Name")]\n (List, List, Person, int) GetData(int id, string name);\n }\n}\n')),Object(c.b)("h3",{id:"91754-\u8fd4\u56de-\u5355\u884c\u5355\u5217"},"9.17.5.4 \u8fd4\u56de ",Object(c.b)("inlineCode",{parentName:"h3"},"\u5355\u884c\u5355\u5217")),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlProcedure("PROC_Name")]\n object GetValue(MyParam dto);\n\n [SqlProcedure("PROC_Name")]\n string GetValue(int id);\n\n [SqlProcedure("PROC_Name")]\n int GetValue(int id, string name);\n }\n}\n')),Object(c.b)("h3",{id:"91756-\u65e0\u8fd4\u56de\u503c"},"9.17.5.6 \u65e0\u8fd4\u56de\u503c"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlProcedure("PROC_Name")]\n void GetValue(MyParam dto);\n\n [SqlProcedure("PROC_Name")]\n void GetValue(int id);\n\n [SqlProcedure("PROC_Name")]\n void GetValue(int id, string name);\n }\n}\n')),Object(c.b)("h3",{id:"91757-\u5e26-outputreturn-\u8fd4\u56de"},"9.17.5.7 \u5e26 ",Object(c.b)("inlineCode",{parentName:"h3"},"OUTPUT/RETURN")," \u8fd4\u56de"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10,13}","{7,10,13}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlProcedure("PROC_Name")]\n ProcedureOutputResult GetOutput(ProcOutputModel pams);\n\n [SqlProcedure("PROC_Name")]\n ProcedureOutputResult GetOutput(ProcOutputModel pams);\n\n [SqlProcedure("PROC_Name")]\n ProcedureOutputResult<(List, List)> GetOutput(ProcOutputModel pams);\n }\n}\n')),Object(c.b)("h2",{id:"9175-\u51fd\u6570-\u64cd\u4f5c"},"9.17.5 ",Object(c.b)("inlineCode",{parentName:"h2"},"\u51fd\u6570")," \u64cd\u4f5c"),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{7,10}","{7,10}":!0}),'using Fur.DatabaseAccessor;\n\nnamespace Fur.Application\n{\n public interface ISql : ISqlDispatchProxy\n {\n [SqlFunction("FN_Name")] // \u6807\u91cf\u51fd\u6570\n string GetValue(MyParam dto);\n\n [SqlProcedure("FN_Name")] // \u8868\u503c\u51fd\u6570\n List GetPersons(int id);\n }\n}\n')),Object(c.b)("div",{className:"admonition admonition-important alert alert--info"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u8865\u5145\u8bf4\u660e")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u4ee3\u7406\u4f1a\u81ea\u52a8\u5224\u65ad\u8fd4\u56de\u503c\u7136\u540e\u81ea\u52a8\u6267\u884c\u7279\u5b9a\u51fd\u6570\u7c7b\u578b\u3002"))),Object(c.b)("h2",{id:"9176-\u4e3a\u4ec0\u4e48\u7528\u5b83\uff1f"},"9.17.6 \u4e3a\u4ec0\u4e48\u7528\u5b83\uff1f"),Object(c.b)("p",null,"\u901a\u8fc7\u4e0a\u9762\u7684\u4f8b\u5b50\u5927\u5bb6\u5c31\u53ef\u4ee5\u4e86\u89e3\uff0c\u8fd9\u79cd\u65b9\u5f0f\u64cd\u4f5c ",Object(c.b)("inlineCode",{parentName:"p"},"sql")," \u975e\u5e38\u7b80\u5355\uff0c\u800c\u4e14\u6781\u6613\u7ef4\u62a4\u3002\u5927\u5bb6\u4e0d\u7528\u53bb\u5173\u7cfb\u8fd4\u56de\u503c\uff0c\u5173\u5fc3\u7528\u54ea\u4e2a\u65b9\u6cd5\uff0c\u6240\u6709\u4e1c\u897f\u4f1a\u81ea\u52a8\u7ed9\u4f60\u5904\u7406\u597d\u3002"),Object(c.b)("p",null,"\u6240\u4ee5\uff0c\u5982\u679c\u9700\u8981\u7528 ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u64cd\u4f5c\uff0c\u63a8\u8350\u4f7f\u7528 ",Object(c.b)("inlineCode",{parentName:"p"},"Sql")," \u9ad8\u7ea7\u4ee3\u7406\u3002"),Object(c.b)("h2",{id:"9177-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.17.7 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(c.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(c.b)("h5",{parentName:"div"},Object(c.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(c.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(c.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(c.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(c.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}b.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return d})),t.d(n,"b",(function(){return u}));var a=t(0),r=t.n(a);function c(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function l(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var s=r.a.createContext({}),b=function(e){var n=r.a.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):l(l({},n),e)),t},d=function(e){var n=b(e.components);return r.a.createElement(s.Provider,{value:n},e.children)},p={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},m=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,c=e.originalType,i=e.parentName,s=o(e,["components","mdxType","originalType","parentName"]),d=b(t),m=a,u=d["".concat(i,".").concat(m)]||d[m]||p[m]||c;return t?r.a.createElement(u,l(l({ref:n},s),{},{components:t})):r.a.createElement(u,l({ref:n},s))}));function u(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var c=t.length,i=new Array(c);i[0]=m;var l={};for(var o in n)hasOwnProperty.call(n,o)&&(l[o]=n[o]);l.originalType=e,l.mdxType="string"==typeof e?e:a,i[1]=l;for(var s=2;sSql",id:"9151-\u5173\u4e8e-sql",children:[]},{value:"9.15.2 \u61d2\u4eba\u65e0\u654c Sql \ud83d\udc2e",id:"9152-\u61d2\u4eba\u65e0\u654c-sql-",children:[{value:"9.15.2.1 \u8fd4\u56de DataTable",id:"91521-\u8fd4\u56de-datatable",children:[]},{value:"9.15.2.2 \u8fd4\u56de List<T>",id:"91522-\u8fd4\u56de-listt",children:[]},{value:"9.15.2.3 \u8fd4\u56de DataSet",id:"91523-\u8fd4\u56de-dataset",children:[]},{value:"9.15.2.4 \u8fd4\u56de Tuple<T1,...T8>",id:"91524-\u8fd4\u56de-tuplet1t8",children:[]},{value:"9.15.2.5 \u8fd4\u56de \u5355\u884c\u5355\u5217",id:"91525-\u8fd4\u56de-\u5355\u884c\u5355\u5217",children:[]},{value:"9.15.2.6 \u8fd4\u56de \u53d7\u5f71\u54cd\u884c\u6570",id:"91526-\u8fd4\u56de-\u53d7\u5f71\u54cd\u884c\u6570",children:[]}]},{value:"9.15.3 \u61d2\u4eba\u65e0\u654c \u5b58\u50a8\u8fc7\u7a0b \ud83d\udc2e",id:"9153-\u61d2\u4eba\u65e0\u654c-\u5b58\u50a8\u8fc7\u7a0b-",children:[{value:"9.15.3.1 \u8fd4\u56de DataTable",id:"91531-\u8fd4\u56de-datatable",children:[]},{value:"9.15.3.2 \u8fd4\u56de List<T>",id:"91532-\u8fd4\u56de-listt",children:[]},{value:"9.15.3.3 \u8fd4\u56de DataSet",id:"91533-\u8fd4\u56de-dataset",children:[]},{value:"9.15.3.4 \u8fd4\u56de Tuple<T1,...T8>",id:"91534-\u8fd4\u56de-tuplet1t8",children:[]},{value:"9.15.3.5 \u8fd4\u56de \u5355\u884c\u5355\u5217",id:"91535-\u8fd4\u56de-\u5355\u884c\u5355\u5217",children:[]},{value:"9.15.3.6 \u8fd4\u56de \u53d7\u5f71\u54cd\u884c\u6570",id:"91536-\u8fd4\u56de-\u53d7\u5f71\u54cd\u884c\u6570",children:[]},{value:"9.15.3.7 \u5e26 OUTPUT/RETURN \u8fd4\u56de",id:"91537-\u5e26-outputreturn-\u8fd4\u56de",children:[]}]},{value:"9.15.4 \u61d2\u4eba\u65e0\u654c \u51fd\u6570 \ud83d\udc2e",id:"9154-\u61d2\u4eba\u65e0\u654c-\u51fd\u6570-",children:[{value:"9.15.4.1 \u6807\u91cf\u51fd\u6570",id:"91541-\u6807\u91cf\u51fd\u6570",children:[]},{value:"9.15.4.2 \u8868\u503c\u51fd\u6570",id:"91542-\u8868\u503c\u51fd\u6570",children:[]}]},{value:"9.15.5 ISqlRepository \u64cd\u4f5c",id:"9155-isqlrepository-\u64cd\u4f5c",children:[]},{value:"9.15.6 IRepository \u64cd\u4f5c",id:"9156-irepository-\u64cd\u4f5c",children:[]},{value:"9.15.7 IRepository<TEntity> \u64cd\u4f5c",id:"9157-irepositorytentity-\u64cd\u4f5c",children:[]},{value:"9.15.8 \u5173\u4e8e Sql \u53c2\u6570",id:"9158-\u5173\u4e8e-sql-\u53c2\u6570",children:[]},{value:"9.15.9 \u591a\u6570\u636e\u5e93 Sql \u64cd\u4f5c \ud83d\udcaf \ud83d\udc9b",id:"9159-\u591a\u6570\u636e\u5e93-sql-\u64cd\u4f5c--",children:[{value:"9.15.9.1 \u61d2\u4eba\u65e0\u654c \ud83d\udc2e \u65b9\u5f0f",id:"91591-\u61d2\u4eba\u65e0\u654c--\u65b9\u5f0f",children:[]},{value:"9.15.9.2 ISqlRepository \u65b9\u5f0f",id:"91592-isqlrepository-\u65b9\u5f0f",children:[]},{value:"9.15.9.3 IRepository \u65b9\u5f0f",id:"91593-irepository-\u65b9\u5f0f",children:[]},{value:"9.15.9.4 IRepository<TEntity> \u65b9\u5f0f",id:"91594-irepositorytentity-\u65b9\u5f0f",children:[]}]},{value:"9.15.10 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"91510-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],s={rightToc:l};function d(e){var n=e.components,a=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(t.a)({},s,a,{components:n,mdxType:"MDXLayout"}),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u6e29\u99a8\u63d0\u793a")),Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u63a8\u8350\u4f7f\u7528 \u300a",Object(i.b)("a",Object(t.a)({parentName:"p"},{href:"/docs/dbcontext-sql-proxy"}),"9.15 Sql \u9ad8\u7ea7\u4ee3\u7406"),"\u300b\u4ee3\u66ff\u672c\u7ae0\u8282\u529f\u80fd\u3002",Object(i.b)("inlineCode",{parentName:"p"},"Sql \u9ad8\u7ea7\u4ee3\u7406")," \u80fd\u591f\u63d0\u4f9b\u66f4\u5bb9\u6613\u4e14\u66f4\u6613\u7ef4\u62a4\u7684\u65b9\u5f0f\u3002"))),Object(i.b)("h2",{id:"9151-\u5173\u4e8e-sql"},"9.15.1 \u5173\u4e8e ",Object(i.b)("inlineCode",{parentName:"h2"},"Sql")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u975e\u5e38\u591a\u4e14\u7075\u6d3b\u7684 ",Object(i.b)("inlineCode",{parentName:"p"},"sql")," \u64cd\u4f5c\u65b9\u6cd5\uff0c\u4e14\u6027\u80fd\u4e0d\u8f93\u4e8e ",Object(i.b)("inlineCode",{parentName:"p"},"dapper"),"\uff0c\u540c\u65f6\u903c\u8fd1 ",Object(i.b)("inlineCode",{parentName:"p"},"ADO.NET")," \u539f\u751f\u64cd\u4f5c\u3002"),Object(i.b)("h2",{id:"9152-\u61d2\u4eba\u65e0\u654c-sql-"},"9.15.2 \u61d2\u4eba\u65e0\u654c ",Object(i.b)("inlineCode",{parentName:"h2"},"Sql")," \ud83d\udc2e"),Object(i.b)("h3",{id:"91521-\u8fd4\u56de-datatable"},"9.15.2.1 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"DataTable")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataTable = "select * from person".SqlQuery();\n\n// \u793a\u4f8b\u4e8c\nvar dataTable = "select top 10 * from person where id > @id".SqlQuery(new {id = 10});\n\n// \u793a\u4f8b\u4e09\nvar dataTable = "select Id, Name, Age from person where name like %@name%".SqlQuery(new Dictionary{ {"name", "Fur"} });\n\n// \u793a\u4f8b\u56db\nvar dataTable = "select * from person where name=@name limit 1,10".SqlQuery(new []{ new MySqlParameter("name","Fur") });\n\n// \u793a\u4f8b\u4e94\nvar dataTable = "select * from person where id>@id and name like %@name%".SqlQuery(new YourModel { Id = 1, Name = "Fur" });\n\n// \u793a\u4f8b\u516d\nvar dataTable = "exec PROC_GetPerson @id".SqlQuery(new {id = 10});\n\n// \u793a\u4f8b\u4e03\nvar dataTable = "select * from FN_GetPersons(@id)".SqlQuery(new {id = 10});\n\n// \u793a\u4f8b\u516b\nvar dataTable = @"\nselect * from person p\nleft join personDetail pd on p.Id == pd.pid\nwhere p.Id > @id;".SqlQuery(new {id = 10});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataTable = await "select * from person".SqlQueryAsync();\n\n// \u793a\u4f8b\u4e8c\nvar dataTable = await "select top 10 * from person where id > @id".SqlQueryAsync(new {id = 10});\n\n// \u793a\u4f8b\u4e09\nvar dataTable = await "select Id, Name, Age from person where name like %@name%".SqlQueryAsync(new Dictionary{ {"name", "Fur"} });\n\n// \u793a\u4f8b\u56db\nvar dataTable = await "select * from person where name=@name limit 1,10".SqlQueryAsync(new []{ new MySqlParameter("name","Fur") });\n\n// \u793a\u4f8b\u4e94\nvar dataTable = await "select * from person where id>@id and name like %@name%".SqlQueryAsync(new YourModel { Id = 1, Name = "Fur" });\n\n// \u793a\u4f8b\u516d\nvar dataTable = await "exec PROC_GetPerson @id".SqlQueryAsync(new {id = 10});\n\n// \u793a\u4f8b\u4e03\nvar dataTable = await "select * from FN_GetPersons(@id)".SqlQueryAsync(new {id = 10});\n\n// \u793a\u4f8b\u516b\nvar dataTable = await @"\nselect * from person p\nleft join personDetail pd on p.Id == pd.pid\nwhere p.Id > @id;".SqlQueryAsync(new {id = 10});\n')),Object(i.b)("h3",{id:"91522-\u8fd4\u56de-listt"},"9.15.2.2 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"List")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = "select * from person".SqlQuery();\n\n// \u793a\u4f8b\u4e8c\nvar persons = "select top 10 * from person where id > @id".SqlQuery(new {id = 10});\n\n// \u793a\u4f8b\u4e09\nvar persons = "select Id, Name, Age from person where name like %@name%".SqlQuery(new Dictionary{ {"name", "Fur"} });\n\n// \u793a\u4f8b\u56db\nvar persons = "select * from person where name=@name limit 1,10".SqlQuery(new []{ new MySqlParameter("name","Fur") });\n\n// \u793a\u4f8b\u4e94\nvar persons = "select * from person where id>@id and name like %@name%".SqlQuery(new YourModel { Id = 1, Name = "Fur" });\n\n// \u793a\u4f8b\u516d\nvar persons = "exec PROC_GetPerson @id".SqlQuery(new {id = 10});\n\n// \u793a\u4f8b\u4e03\nvar persons = "select * from FN_GetPersons(@id)".SqlQuery(new {id = 10});\n\n// \u793a\u4f8b\u516b\nvar persons = @"\nselect * from person p\nleft join personDetail pd on p.Id == pd.pid\nwhere p.Id > @id;".SqlQuery(new {id = 10});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = await "select * from person".SqlQueryAsync();\n\n// \u793a\u4f8b\u4e8c\nvar persons = await "select top 10 * from person where id > @id".SqlQueryAsync(new {id = 10});\n\n// \u793a\u4f8b\u4e09\nvar persons = await "select Id, Name, Age from person where name like %@name%".SqlQueryAsync(new Dictionary{ {"name", "Fur"} });\n\n// \u793a\u4f8b\u56db\nvar persons = await "select * from person where name=@name limit 1,10".SqlQueryAsync(new []{ new MySqlParameter("name","Fur") });\n\n// \u793a\u4f8b\u4e94\nvar persons = await "select * from person where id>@id and name like %@name%".SqlQueryAsync(new YourModel { Id = 1, Name = "Fur" });\n\n// \u793a\u4f8b\u516d\nvar persons = await "exec PROC_GetPerson @id".SqlQueryAsync(new {id = 10});\n\n// \u793a\u4f8b\u4e03\nvar persons = await "select * from FN_GetPersons(@id)".SqlQueryAsync(new {id = 10});\n\n// \u793a\u4f8b\u516b\nvar persons = await @"\nselect * from person p\nleft join personDetail pd on p.Id == pd.pid\nwhere p.Id > @id;".SqlQueryAsync(new {id = 10});\n')),Object(i.b)("h3",{id:"91523-\u8fd4\u56de-dataset"},"9.15.2.3 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"DataSet")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataSet = @"\nselect * from person;\nselect * from student;".SqlQueries();\n\n// \u793a\u4f8b\u4e8c\nvar dataSet = @"\nselect * from person where Id > @id;\nselect * from student where Name like %@name%;".SqlQueries(new {id = 1, name = "fur"});\n\n// \u793a\u4f8b\u4e09\nvar dataSet = @"\nselect * from person;\nexec PROC_GetStudents(@id);\nselect \'Fur\';\nselect * from FN_GetPerson(@id);".SqlQueries(new {id = 1});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataSet = await @"\nselect * from person;\nselect * from student;".SqlQueriesAsync();\n\n// \u793a\u4f8b\u4e8c\nvar dataSet = await @"\nselect * from person where Id > @id;\nselect * from student where Name like %@name%;".SqlQueriesAsync(new {id = 1, name = "fur"});\n\n// \u793a\u4f8b\u4e09\nvar dataSet = await @"\nselect * from person;\nexec PROC_GetStudents(@id);\nselect \'Fur\';\nselect * from FN_GetPerson(@id);".SqlQueriesAsync(new {id = 1});\n')),Object(i.b)("h3",{id:"91524-\u8fd4\u56de-tuplet1t8"},"9.15.2.4 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"Tuple")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar (persons, students) = @"\nselect * from person;\nselect * from student;".SqlQueries();\n\n// \u793a\u4f8b\u4e8c\nvar (persons, students) = @"\nselect * from person where Id > @id;\nselect * from student where Name like %@name%;".SqlQueries(new {id = 1, name = "fur"});\n\n// \u793a\u4f8b\u4e09\nvar (persons, students, string, PersonDto) = @"\nselect * from person;\nexec PROC_GetStudents(@id);\nselect \'Fur\';\nselect * from FN_GetPerson(@id);".SqlQueries(new {id = 1});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar (persons, students) = await @"\nselect * from person;\nselect * from student;".SqlQueriesAsync();\n\n// \u793a\u4f8b\u4e8c\nvar (persons, students) = await @"\nselect * from person where Id > @id;\nselect * from student where Name like %@name%;".SqlQueriesAsync(new {id = 1, name = "fur"});\n\n// \u793a\u4f8b\u4e09\nvar (persons, students, string, PersonDto) = await @"\nselect * from person;\nexec PROC_GetStudents(@id);\nselect \'Fur\';\nselect * from FN_GetPerson(@id);".SqlQueriesAsync(new {id = 1});\n')),Object(i.b)("h3",{id:"91525-\u8fd4\u56de-\u5355\u884c\u5355\u5217"},"9.15.2.5 \u8fd4\u56de \u5355\u884c\u5355\u5217"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar value = "select Name from person where id = @id".SqlScalar(new {id = 1});\n\n// \u793a\u4f8b\u4e8c\nvar value = "select Name from person where id = @id".SqlScalar(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar value = "select Age from person where id = @id".SqlScalar(new {id = 1});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar value = await "select Name from person where id = @id".SqlScalarAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e8c\nvar value = await "select Name from person where id = @id".SqlScalarAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar value = await "select Age from person where id = @id".SqlScalarAsync(new {id = 1});\n')),Object(i.b)("h3",{id:"91526-\u8fd4\u56de-\u53d7\u5f71\u54cd\u884c\u6570"},"9.15.2.6 \u8fd4\u56de \u53d7\u5f71\u54cd\u884c\u6570"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar rowEffects = "insert into person(Name,Age,Address) values(@name,@age,@address)".SqlNonQuery(person);\n\n// \u793a\u4f8b\u4e8c\nvar rowEffects = @"\ninsert into person(Name,Age,Address) values(@name,@age,@address);\ninsert into person(Name,Age,Address) values(@name,@age,@address);".SqlNonQuery(persons);\n\n// \u793a\u4f8b\u4e09\nvar rowEffects = "update person set name=@name where id=@id".SqlNonQuery(new {id=1, name="\u767e\u5c0f\u50e7"});\n\n// \u793a\u4f8b\u56db\nvar rowEffects = "delete from person where @id > 10".SqlNonQuery(new {id=1});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar rowEffects = await "insert into person(Name,Age,Address) values(@name,@age,@address)".SqlNonQueryAsync(person);\n\n// \u793a\u4f8b\u4e8c\nvar rowEffects = @"\ninsert into person(Name,Age,Address) values(@name,@age,@address);\ninsert into person(Name,Age,Address) values(@name,@age,@address);".SqlNonQueryAsync(persons);\n\n// \u793a\u4f8b\u4e09\nvar rowEffects = await "update person set name=@name where id=@id".SqlNonQueryAsync(new {id=1, name="\u767e\u5c0f\u50e7"});\n\n// \u793a\u4f8b\u56db\nvar rowEffects = await "delete from person where @id > 10".SqlNonQueryAsync(new {id=1});\n')),Object(i.b)("h2",{id:"9153-\u61d2\u4eba\u65e0\u654c-\u5b58\u50a8\u8fc7\u7a0b-"},"9.15.3 \u61d2\u4eba\u65e0\u654c ",Object(i.b)("inlineCode",{parentName:"h2"},"\u5b58\u50a8\u8fc7\u7a0b")," \ud83d\udc2e"),Object(i.b)("h3",{id:"91531-\u8fd4\u56de-datatable"},"9.15.3.1 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"DataTable")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataTable = "PROC_Name".SqlProcedureQuery();\n\n// \u793a\u4f8b\u4e8c\nvar dataTable = "PROC_Name".SqlProcedureQuery(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar dataTable = "PROC_Name".SqlProcedureQuery(new {id = 1, age = 27});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataTable = await "PROC_Name".SqlProcedureQueryAsync();\n\n// \u793a\u4f8b\u4e8c\nvar dataTable = await "PROC_Name".SqlProcedureQueryAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar dataTable = await "PROC_Name".SqlProcedureQueryAsync(new {id = 1, age = 27});\n')),Object(i.b)("h3",{id:"91532-\u8fd4\u56de-listt"},"9.15.3.2 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"List")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = "PROC_Name".SqlProcedureQuery();\n\n// \u793a\u4f8b\u4e8c\nvar persons = "PROC_Name".SqlProcedureQuery(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar persons = "PROC_Name".SqlProcedureQuery(new {id = 1, age = 27});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = await "PROC_Name".SqlProcedureQueryAsync();\n\n// \u793a\u4f8b\u4e8c\nvar persons = await "PROC_Name".SqlProcedureQueryAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar persons = await "PROC_Name".SqlProcedureQueryAsync(new {id = 1, age = 27});\n')),Object(i.b)("h3",{id:"91533-\u8fd4\u56de-dataset"},"9.15.3.3 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"DataSet")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataSet = "PROC_Name".SqlProcedureQueries();\n\n// \u793a\u4f8b\u4e8c\nvar dataSet = "PROC_Name".SqlProcedureQueries(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar dataSet = "PROC_Name".SqlProcedureQueries(new {id = 1, age = 27});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataSet = await "PROC_Name".SqlProcedureQueriesAsync();\n\n// \u793a\u4f8b\u4e8c\nvar dataSet = await "PROC_Name".SqlProcedureQueriesAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar dataSet = await "PROC_Name".SqlProcedureQueriesAsync(new {id = 1, age = 27});\n')),Object(i.b)("h3",{id:"91534-\u8fd4\u56de-tuplet1t8"},"9.15.3.4 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"Tuple")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = "PROC_Name".SqlProcedureQueries();\n\n// \u793a\u4f8b\u4e8c\nvar (persons,students) = "PROC_Name".SqlProcedureQueries(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar (persons,students,string) = "PROC_Name".SqlProcedureQueries(new {id = 1, age = 27});\n\n// \u793a\u4f8b\u56db\nvar (persons,students,personDetail,string) = "PROC_Name".SqlProcedureQueries(new {id = 1, age = 27});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = await "PROC_Name".SqlProcedureQueriesAsync();\n\n// \u793a\u4f8b\u4e8c\nvar (persons,students) = await "PROC_Name".SqlProcedureQueriesAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar (persons,students,string) = await "PROC_Name".SqlProcedureQueriesAsync(new {id = 1, age = 27});\n\n// \u793a\u4f8b\u56db\nvar (persons,students,personDetail,string) = await "PROC_Name".SqlProcedureQueriesAsync(new {id = 1, age = 27});\n')),Object(i.b)("h3",{id:"91535-\u8fd4\u56de-\u5355\u884c\u5355\u5217"},"9.15.3.5 \u8fd4\u56de \u5355\u884c\u5355\u5217"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar value = "PROC_Name".SqlProcedureScalar(new {id = 1});\n\n// \u793a\u4f8b\u4e8c\nvar value = "PROC_Name".SqlProcedureScalar(new {id = 1, name = "\u65b0\u751f\u5e1d", address ="\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02"});\n\n// \u793a\u4f8b\u4e09\nvar value = "PROC_Name".SqlProcedureScalar(new {id = 1, address ="\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar value = await "PROC_Name".SqlProcedureScalarAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e8c\nvar value = await "PROC_Name".SqlProcedureScalarAsync(new {id = 1, name = "\u65b0\u751f\u5e1d", address ="\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02"});\n\n// \u793a\u4f8b\u4e09\nvar value = await "PROC_Name".SqlProcedureScalarAsync(new {id = 1, address ="\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02"});\n')),Object(i.b)("h3",{id:"91536-\u8fd4\u56de-\u53d7\u5f71\u54cd\u884c\u6570"},"9.15.3.6 \u8fd4\u56de \u53d7\u5f71\u54cd\u884c\u6570"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar rowEffects = "PROC_Name".SqlProcedureNonQuery(person);\n\n// \u793a\u4f8b\u4e8c\nvar rowEffects = "PROC_Name".SqlProcedureNonQuery(new {id = 1, name = "\u65b0\u751f\u5e1d", address ="\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02"});\n\n// \u793a\u4f8b\u4e09\nvar rowEffects = "PROC_Name".SqlProcedureNonQuery(new {id=1, name="\u767e\u5c0f\u50e7"});\n\n// \u793a\u4f8b\u56db\nvar rowEffects = "PROC_Name".SqlProcedureNonQuery(new {id=1});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar rowEffects = await "PROC_Name".SqlProcedureNonQueryAsync(person);\n\n// \u793a\u4f8b\u4e8c\nvar rowEffects = await "PROC_Name".SqlProcedureNonQueryAsync(new {id = 1, name = "\u65b0\u751f\u5e1d", address ="\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02"});\n\n// \u793a\u4f8b\u4e09\nvar rowEffects = await "PROC_Name".SqlProcedureNonQueryAsync(new {id=1, name="\u767e\u5c0f\u50e7"});\n\n// \u793a\u4f8b\u56db\nvar rowEffects = await "PROC_Name".SqlProcedureNonQueryAsync(new {id=1});\n')),Object(i.b)("h3",{id:"91537-\u5e26-outputreturn-\u8fd4\u56de"},"9.15.3.7 \u5e26 ",Object(i.b)("inlineCode",{parentName:"h3"},"OUTPUT/RETURN")," \u8fd4\u56de"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-sql",metastring:"{3,4,10-12,15-17,22}","{3,4,10-12,15-17,22}":!0}),"CREATE PROC PROC_Output\n @Id INT, // \u8f93\u5165\u53c2\u6570\n @Name NVARCHAR(32) OUTPUT, // \u8f93\u51fa\u53c2\u6570\uff0c\u8fd8\u5e26\u957f\u5ea6\n @Age INT OUTPUT // \u8f93\u51fa\u53c2\u6570\nAS\nBEGIN\n SET @Name = 'Fur Output';\n\n // \u8f93\u51fa\u7ed3\u679c\u96c6\n SELECT *\n FROM dbo.Test\n WHERE Id > @Id;\n\n // \u8f93\u51fa\u7ed3\u679c\u96c6\n SELECT TOP 10\n *\n FROM dbo.Test;\n\n SET @Age = 27;\n\n // \u5e26 RETURN \u8fd4\u56de\n RETURN 10;\nEND;\n")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,10,13,16}","{1,10,13,16}":!0}),"using Fur.DatabaseAccessor;\nusing System.Data;\n\nnamespace Fur.Application\n{\n public class ProcOutputModel\n {\n public int Id { get; set; } // \u8f93\u5165\u53c2\u6570\n\n [DbParameter(ParameterDirection.Output, Size = 32)]\n public string Name { get; set; } // \u8f93\u51fa\u53c2\u6570\n\n [DbParameter(ParameterDirection.Output)]\n public int Age { get; set; } // \u8f93\u51fa\u53c2\u6570\n\n [DbParameter(ParameterDirection.ReturnValue)]\n public int ReturnValue { get; set; } // \u8fd4\u56de\u503c\n }\n}\n")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nProcedureOutputResult result = "PROC_Name".SqlProcedureOutput(new {id=1, name="\u767e\u5c0f\u50e7"});\n\n// \u793a\u4f8b\u4e8c\nProcedureOutputResult result = "PROC_Name".SqlProcedureOutput();\n\n// \u793a\u4f8b\u4e09\nProcedureOutputResult<(List, List)> result = "PROC_Name".SqlProcedureOutput<(List, List)>();\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n// \u793a\u4f8b\u4e00\nProcedureOutputResult result = await "PROC_Name".SqlProcedureOutputAsync(new {id=1, name="\u767e\u5c0f\u50e7"});\n\n// \u793a\u4f8b\u4e8c\nProcedureOutputResult result = await "PROC_Name".SqlProcedureOutputAsync();\n\n// \u793a\u4f8b\u4e09\nProcedureOutputResult<(List, List)> result = await "PROC_Name".SqlProcedureOutputAsync<(List, List)>();\n')),Object(i.b)("h2",{id:"9154-\u61d2\u4eba\u65e0\u654c-\u51fd\u6570-"},"9.15.4 \u61d2\u4eba\u65e0\u654c ",Object(i.b)("inlineCode",{parentName:"h2"},"\u51fd\u6570")," \ud83d\udc2e"),Object(i.b)("h3",{id:"91541-\u6807\u91cf\u51fd\u6570"},"9.15.4.1 ",Object(i.b)("inlineCode",{parentName:"h3"},"\u6807\u91cf\u51fd\u6570")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar value = "FN_Name".SqlFunctionScalar();\n\n// \u793a\u4f8b\u4e8c\nvar value = "FN_Name".SqlFunctionScalar(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar value = "FN_Name".SqlFunctionScalar();\n\n// \u793a\u4f8b\u56db\nvar value = "FN_Name".SqlFunctionScalar(new {id = 1});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar value = await "FN_Name".SqlFunctionScalarAsync();\n\n// \u793a\u4f8b\u4e8c\nvar value = await "FN_Name".SqlFunctionScalarAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar value = await "FN_Name".SqlFunctionScalarAsync();\n\n// \u793a\u4f8b\u56db\nvar value = await "FN_Name".SqlFunctionScalarAsync(new {id = 1});\n')),Object(i.b)("h3",{id:"91542-\u8868\u503c\u51fd\u6570"},"9.15.4.2 ",Object(i.b)("inlineCode",{parentName:"h3"},"\u8868\u503c\u51fd\u6570")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataTable = "FN_Name".SqlFunctionQuery();\n\n// \u793a\u4f8b\u4e8c\nvar dataTable = "FN_Name".SqlFunctionQuery(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar persons = "FN_Name".SqlFunctionQuery();\n\n// \u793a\u4f8b\u56db\nvar persons = "FN_Name".SqlFunctionQuery(new {id = 1});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataTable = await "FN_Name".SqlFunctionQueryAsync();\n\n// \u793a\u4f8b\u4e8c\nvar dataTable = await "FN_Name".SqlFunctionQueryAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar persons = await "FN_Name".SqlFunctionQueryAsync();\n\n// \u793a\u4f8b\u56db\nvar persons = await "FN_Name".SqlFunctionQueryAsync(new {id = 1});\n')),Object(i.b)("h2",{id:"9155-isqlrepository-\u64cd\u4f5c"},"9.15.5 ",Object(i.b)("inlineCode",{parentName:"h2"},"ISqlRepository")," \u64cd\u4f5c"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"ISqlRepository")," \u4ed3\u50a8\u662f\u4e13\u95e8\u5904\u7406 ",Object(i.b)("inlineCode",{parentName:"p"},"Sql")," \u64cd\u4f5c\u7684\uff0c\u65e0\u9700\u5b9e\u4f53\u65b9\u5f0f\uff0c\u6240\u6709\u63a5\u53e3\u548c ",Object(i.b)("inlineCode",{parentName:"p"},"\u61d2\u4eba\u65e0\u654c")," \u65b9\u5f0f\u4e00\u6837\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// \u793a\u4f8b\u4e00\nvar dataTable = sqlRepository.SqlQuery("select * from person");\n\n// \u793a\u4f8b\u4e8c\nvar dataTable = sqlRepository.SqlQuery("select * from person where id > @id", new { id = 10});\n\n// \u793a\u4f8b\u56db\nvar persons = sqlRepository.SqlQuery("select * from person");\n\n// \u793a\u4f8b\u4e94\nvar persons = sqlRepository.SqlQuery("select * from person where id > @id", new { id = 10});\n\n// \u4e0d\u518d\u4e3e\u4f8b\u5b50\u3002\u3002\u3002\u3002\u3002\u3002\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u8865\u5145\u8bf4\u660e")),Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u4e0d\u7ba1\u662f\u90a3\u79cd\u65b9\u5f0f\u64cd\u4f5c ",Object(i.b)("inlineCode",{parentName:"p"},"Sql")," \uff0c\u65b9\u6cd5\u540d\u53c2\u6570\u90fd\u662f\u4e00\u81f4\u7684\uff0c\u5982\uff1a"),Object(i.b)("ul",{parentName:"div"},Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlQuery")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlQueryAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlQueries")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlQueriesAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlNonQuery")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlNonQueryAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlScalar")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlScalarAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureQuery")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureQueryAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureQueries")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureQueriesAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureScalar")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureScalarAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureNonQuery")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureNonQueryAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureOutput")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureOutputAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlFunctionScalar")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlFunctionScalarAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlFunctionQuery")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlFunctionQuery"))))),Object(i.b)("h2",{id:"9156-irepository-\u64cd\u4f5c"},"9.15.6 ",Object(i.b)("inlineCode",{parentName:"h2"},"IRepository")," \u64cd\u4f5c"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"IRepository")," \u4e5f\u80fd\u64cd\u4f5c ",Object(i.b)("inlineCode",{parentName:"p"},"sql"),"\uff0c\u8c03\u7528\u65b9\u6cd5\u4e5f\u662f\u548c\u4e0a\u9762\u4e00\u81f4\u7684\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'var dataTable = repository.Sql().SqlQuery("select * from person");\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u4e0d\u518d\u5217\u4e3e\u6240\u6709\u4f8b\u5b50\u3002"))),Object(i.b)("h2",{id:"9157-irepositorytentity-\u64cd\u4f5c"},"9.15.7 ",Object(i.b)("inlineCode",{parentName:"h2"},"IRepository")," \u64cd\u4f5c"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"IRepository")," \u4e5f\u80fd\u64cd\u4f5c ",Object(i.b)("inlineCode",{parentName:"p"},"sql"),"\uff0c\u8c03\u7528\u65b9\u6cd5\u4e5f\u662f\u548c\u4e0a\u9762\u4e00\u81f4\u7684\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'var dataTable = personRepository.SqlQuery("select * from person");\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u4e0d\u518d\u5217\u4e3e\u6240\u6709\u4f8b\u5b50\u3002"))),Object(i.b)("h2",{id:"9158-\u5173\u4e8e-sql-\u53c2\u6570"},"9.15.8 \u5173\u4e8e ",Object(i.b)("inlineCode",{parentName:"h2"},"Sql")," \u53c2\u6570"),Object(i.b)("p",null,"\u6240\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"sql"),"\u3001",Object(i.b)("inlineCode",{parentName:"p"},"\u5b58\u50a8\u8fc7\u7a0b"),"\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"\u51fd\u6570")," \u53c2\u6570\u90fd\u652f\u6301\u56db\u79cd\u65b9\u5f0f\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"DbParameter[]"),"\uff1a\u6570\u7ec4\u7c7b\u578b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"new {}"),"\uff1a\u533f\u540d\u7c7b\u578b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"new Class{}"),"\uff1a\u5f3a\u7c7b\u578b\u7c7b\u578b\uff08\u652f\u6301\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570\uff09"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Dictionary")," \u7c7b\u578b")),Object(i.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(i.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u5efa\u8bae\u9664\u4e86\u590d\u6742\u7684\u5b58\u50a8\u8fc7\u7a0b\uff08\u5e26 ",Object(i.b)("inlineCode",{parentName:"p"},"OUTPUT/RETURN"),"\uff09\u7684\u4ee5\u5916\uff0c\u6240\u6709\u53c2\u6570\u5efa\u8bae\u4f7f\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"new {}")," \u533f\u540d\u7c7b\u578b\uff0c\u5982\u679c\u9700\u8981\u52a8\u6001\u53c2\u6570\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"Dictionary")," \u7c7b\u578b\u3002"))),Object(i.b)("h2",{id:"9159-\u591a\u6570\u636e\u5e93-sql-\u64cd\u4f5c--"},"9.15.9 \u591a\u6570\u636e\u5e93 ",Object(i.b)("inlineCode",{parentName:"h2"},"Sql")," \u64cd\u4f5c \ud83d\udcaf \ud83d\udc9b"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u62e5\u6709\u975e\u5e38\u7075\u6d3b\u7684\u591a\u6570\u636e\u5e93\u64cd\u4f5c\u65b9\u5f0f\uff0c\u53ea\u9700\u901a\u8fc7\u591a",Object(i.b)("strong",{parentName:"p"},"\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668"),"\u5373\u53ef\u52a8\u6001\u5207\u6362\u6570\u636e\u5e93\u3002"),Object(i.b)("h3",{id:"91591-\u61d2\u4eba\u65e0\u654c--\u65b9\u5f0f"},"9.15.9.1 \u61d2\u4eba\u65e0\u654c \ud83d\udc2e \u65b9\u5f0f"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'var dataTable = "select * from person".Change().SqlQuery();\n\nvar persons = "select * from person whre id > @id".Change().SqlQuery();\n')),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u8865\u5145\u8bf4\u660e")),Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u61d2\u4eba\u65b9\u5f0f \u53ea\u9700\u8981\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"Change")," \u65b9\u5f0f\u5373\u53ef\u52a8\u6001\u5207\u6362\u6570\u636e\u5e93\u3002"))),Object(i.b)("h3",{id:"91592-isqlrepository-\u65b9\u5f0f"},"9.15.9.2 ",Object(i.b)("inlineCode",{parentName:"h3"},"ISqlRepository")," \u65b9\u5f0f"),Object(i.b)("p",null,"\u53ea\u9700\u8981\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"ISqlRepository")," \u6ce8\u5165\u6216\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"sqlRepository.Change()")," \u5207\u6362\u3002"),Object(i.b)("h3",{id:"91593-irepository-\u65b9\u5f0f"},"9.15.9.3 ",Object(i.b)("inlineCode",{parentName:"h3"},"IRepository")," \u65b9\u5f0f"),Object(i.b)("p",null,"\u53ea\u9700\u8981\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"repository.Change()")," \u83b7\u53d6\u5373\u53ef\u3002"),Object(i.b)("h3",{id:"91594-irepositorytentity-\u65b9\u5f0f"},"9.15.9.4 ",Object(i.b)("inlineCode",{parentName:"h3"},"IRepository")," \u65b9\u5f0f"),Object(i.b)("p",null,"\u53ea\u9700\u8981\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"IRepository")," \u6ce8\u5165\u6216\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"personRepository.Change()")," \u5207\u6362\u3002"),Object(i.b)("h2",{id:"91510-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.15.10 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(t.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}d.isMDXComponent=!0},142:function(e,n,a){"use strict";a.d(n,"a",(function(){return b})),a.d(n,"b",(function(){return m}));var t=a(0),r=a.n(t);function i(e,n,a){return n in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}function c(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),a.push.apply(a,t)}return a}function o(e){for(var n=1;n=0||(r[a]=e[a]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}var s=r.a.createContext({}),d=function(e){var n=r.a.useContext(s),a=n;return e&&(a="function"==typeof e?e(n):o(o({},n),e)),a},b=function(e){var n=d(e.components);return r.a.createElement(s.Provider,{value:n},e.children)},p={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},u=r.a.forwardRef((function(e,n){var a=e.components,t=e.mdxType,i=e.originalType,c=e.parentName,s=l(e,["components","mdxType","originalType","parentName"]),b=d(a),u=t,m=b["".concat(c,".").concat(u)]||b[u]||p[u]||i;return a?r.a.createElement(m,o(o({ref:n},s),{},{components:a})):r.a.createElement(m,o({ref:n},s))}));function m(e,n){var a=arguments,t=n&&n.mdxType;if("string"==typeof e||t){var i=a.length,c=new Array(i);c[0]=u;var o={};for(var l in n)hasOwnProperty.call(n,l)&&(o[l]=n[l]);o.originalType=e,o.mdxType="string"==typeof e?e:t,c[1]=o;for(var s=2;sSql",id:"9151-\u5173\u4e8e-sql",children:[]},{value:"9.15.2 \u61d2\u4eba\u65e0\u654c Sql \ud83d\udc2e",id:"9152-\u61d2\u4eba\u65e0\u654c-sql-",children:[{value:"9.15.2.1 \u8fd4\u56de DataTable",id:"91521-\u8fd4\u56de-datatable",children:[]},{value:"9.15.2.2 \u8fd4\u56de List<T>",id:"91522-\u8fd4\u56de-listt",children:[]},{value:"9.15.2.3 \u8fd4\u56de DataSet",id:"91523-\u8fd4\u56de-dataset",children:[]},{value:"9.15.2.4 \u8fd4\u56de Tuple<T1,...T8>",id:"91524-\u8fd4\u56de-tuplet1t8",children:[]},{value:"9.15.2.5 \u8fd4\u56de \u5355\u884c\u5355\u5217",id:"91525-\u8fd4\u56de-\u5355\u884c\u5355\u5217",children:[]},{value:"9.15.2.6 \u8fd4\u56de \u53d7\u5f71\u54cd\u884c\u6570",id:"91526-\u8fd4\u56de-\u53d7\u5f71\u54cd\u884c\u6570",children:[]}]},{value:"9.15.3 \u61d2\u4eba\u65e0\u654c \u5b58\u50a8\u8fc7\u7a0b \ud83d\udc2e",id:"9153-\u61d2\u4eba\u65e0\u654c-\u5b58\u50a8\u8fc7\u7a0b-",children:[{value:"9.15.3.1 \u8fd4\u56de DataTable",id:"91531-\u8fd4\u56de-datatable",children:[]},{value:"9.15.3.2 \u8fd4\u56de List<T>",id:"91532-\u8fd4\u56de-listt",children:[]},{value:"9.15.3.3 \u8fd4\u56de DataSet",id:"91533-\u8fd4\u56de-dataset",children:[]},{value:"9.15.3.4 \u8fd4\u56de Tuple<T1,...T8>",id:"91534-\u8fd4\u56de-tuplet1t8",children:[]},{value:"9.15.3.5 \u8fd4\u56de \u5355\u884c\u5355\u5217",id:"91535-\u8fd4\u56de-\u5355\u884c\u5355\u5217",children:[]},{value:"9.15.3.6 \u8fd4\u56de \u53d7\u5f71\u54cd\u884c\u6570",id:"91536-\u8fd4\u56de-\u53d7\u5f71\u54cd\u884c\u6570",children:[]},{value:"9.15.3.7 \u5e26 OUTPUT/RETURN \u8fd4\u56de",id:"91537-\u5e26-outputreturn-\u8fd4\u56de",children:[]}]},{value:"9.15.4 \u61d2\u4eba\u65e0\u654c \u51fd\u6570 \ud83d\udc2e",id:"9154-\u61d2\u4eba\u65e0\u654c-\u51fd\u6570-",children:[{value:"9.15.4.1 \u6807\u91cf\u51fd\u6570",id:"91541-\u6807\u91cf\u51fd\u6570",children:[]},{value:"9.15.4.2 \u8868\u503c\u51fd\u6570",id:"91542-\u8868\u503c\u51fd\u6570",children:[]}]},{value:"9.15.5 ISqlRepository \u64cd\u4f5c",id:"9155-isqlrepository-\u64cd\u4f5c",children:[]},{value:"9.15.6 IRepository \u64cd\u4f5c",id:"9156-irepository-\u64cd\u4f5c",children:[]},{value:"9.15.7 IRepository<TEntity> \u64cd\u4f5c",id:"9157-irepositorytentity-\u64cd\u4f5c",children:[]},{value:"9.15.8 \u5173\u4e8e Sql \u53c2\u6570",id:"9158-\u5173\u4e8e-sql-\u53c2\u6570",children:[]},{value:"9.15.9 \u591a\u6570\u636e\u5e93 Sql \u64cd\u4f5c \ud83d\udcaf \ud83d\udc9b",id:"9159-\u591a\u6570\u636e\u5e93-sql-\u64cd\u4f5c--",children:[{value:"9.15.9.1 \u61d2\u4eba\u65e0\u654c \ud83d\udc2e \u65b9\u5f0f",id:"91591-\u61d2\u4eba\u65e0\u654c--\u65b9\u5f0f",children:[]},{value:"9.15.9.2 ISqlRepository \u65b9\u5f0f",id:"91592-isqlrepository-\u65b9\u5f0f",children:[]},{value:"9.15.9.3 IRepository \u65b9\u5f0f",id:"91593-irepository-\u65b9\u5f0f",children:[]},{value:"9.15.9.4 IRepository<TEntity> \u65b9\u5f0f",id:"91594-irepositorytentity-\u65b9\u5f0f",children:[]}]},{value:"9.15.10 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"91510-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],s={rightToc:l};function d(e){var n=e.components,a=Object(r.a)(e,["components"]);return Object(i.b)("wrapper",Object(t.a)({},s,a,{components:n,mdxType:"MDXLayout"}),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u6e29\u99a8\u63d0\u793a")),Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u63a8\u8350\u4f7f\u7528 \u300a",Object(i.b)("a",Object(t.a)({parentName:"p"},{href:"/fur/docs/dbcontext-sql-proxy"}),"9.15 Sql \u9ad8\u7ea7\u4ee3\u7406"),"\u300b\u4ee3\u66ff\u672c\u7ae0\u8282\u529f\u80fd\u3002",Object(i.b)("inlineCode",{parentName:"p"},"Sql \u9ad8\u7ea7\u4ee3\u7406")," \u80fd\u591f\u63d0\u4f9b\u66f4\u5bb9\u6613\u4e14\u66f4\u6613\u7ef4\u62a4\u7684\u65b9\u5f0f\u3002"))),Object(i.b)("h2",{id:"9151-\u5173\u4e8e-sql"},"9.15.1 \u5173\u4e8e ",Object(i.b)("inlineCode",{parentName:"h2"},"Sql")),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u975e\u5e38\u591a\u4e14\u7075\u6d3b\u7684 ",Object(i.b)("inlineCode",{parentName:"p"},"sql")," \u64cd\u4f5c\u65b9\u6cd5\uff0c\u4e14\u6027\u80fd\u4e0d\u8f93\u4e8e ",Object(i.b)("inlineCode",{parentName:"p"},"dapper"),"\uff0c\u540c\u65f6\u903c\u8fd1 ",Object(i.b)("inlineCode",{parentName:"p"},"ADO.NET")," \u539f\u751f\u64cd\u4f5c\u3002"),Object(i.b)("h2",{id:"9152-\u61d2\u4eba\u65e0\u654c-sql-"},"9.15.2 \u61d2\u4eba\u65e0\u654c ",Object(i.b)("inlineCode",{parentName:"h2"},"Sql")," \ud83d\udc2e"),Object(i.b)("h3",{id:"91521-\u8fd4\u56de-datatable"},"9.15.2.1 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"DataTable")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataTable = "select * from person".SqlQuery();\n\n// \u793a\u4f8b\u4e8c\nvar dataTable = "select top 10 * from person where id > @id".SqlQuery(new {id = 10});\n\n// \u793a\u4f8b\u4e09\nvar dataTable = "select Id, Name, Age from person where name like %@name%".SqlQuery(new Dictionary{ {"name", "Fur"} });\n\n// \u793a\u4f8b\u56db\nvar dataTable = "select * from person where name=@name limit 1,10".SqlQuery(new []{ new MySqlParameter("name","Fur") });\n\n// \u793a\u4f8b\u4e94\nvar dataTable = "select * from person where id>@id and name like %@name%".SqlQuery(new YourModel { Id = 1, Name = "Fur" });\n\n// \u793a\u4f8b\u516d\nvar dataTable = "exec PROC_GetPerson @id".SqlQuery(new {id = 10});\n\n// \u793a\u4f8b\u4e03\nvar dataTable = "select * from FN_GetPersons(@id)".SqlQuery(new {id = 10});\n\n// \u793a\u4f8b\u516b\nvar dataTable = @"\nselect * from person p\nleft join personDetail pd on p.Id == pd.pid\nwhere p.Id > @id;".SqlQuery(new {id = 10});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataTable = await "select * from person".SqlQueryAsync();\n\n// \u793a\u4f8b\u4e8c\nvar dataTable = await "select top 10 * from person where id > @id".SqlQueryAsync(new {id = 10});\n\n// \u793a\u4f8b\u4e09\nvar dataTable = await "select Id, Name, Age from person where name like %@name%".SqlQueryAsync(new Dictionary{ {"name", "Fur"} });\n\n// \u793a\u4f8b\u56db\nvar dataTable = await "select * from person where name=@name limit 1,10".SqlQueryAsync(new []{ new MySqlParameter("name","Fur") });\n\n// \u793a\u4f8b\u4e94\nvar dataTable = await "select * from person where id>@id and name like %@name%".SqlQueryAsync(new YourModel { Id = 1, Name = "Fur" });\n\n// \u793a\u4f8b\u516d\nvar dataTable = await "exec PROC_GetPerson @id".SqlQueryAsync(new {id = 10});\n\n// \u793a\u4f8b\u4e03\nvar dataTable = await "select * from FN_GetPersons(@id)".SqlQueryAsync(new {id = 10});\n\n// \u793a\u4f8b\u516b\nvar dataTable = await @"\nselect * from person p\nleft join personDetail pd on p.Id == pd.pid\nwhere p.Id > @id;".SqlQueryAsync(new {id = 10});\n')),Object(i.b)("h3",{id:"91522-\u8fd4\u56de-listt"},"9.15.2.2 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"List")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = "select * from person".SqlQuery();\n\n// \u793a\u4f8b\u4e8c\nvar persons = "select top 10 * from person where id > @id".SqlQuery(new {id = 10});\n\n// \u793a\u4f8b\u4e09\nvar persons = "select Id, Name, Age from person where name like %@name%".SqlQuery(new Dictionary{ {"name", "Fur"} });\n\n// \u793a\u4f8b\u56db\nvar persons = "select * from person where name=@name limit 1,10".SqlQuery(new []{ new MySqlParameter("name","Fur") });\n\n// \u793a\u4f8b\u4e94\nvar persons = "select * from person where id>@id and name like %@name%".SqlQuery(new YourModel { Id = 1, Name = "Fur" });\n\n// \u793a\u4f8b\u516d\nvar persons = "exec PROC_GetPerson @id".SqlQuery(new {id = 10});\n\n// \u793a\u4f8b\u4e03\nvar persons = "select * from FN_GetPersons(@id)".SqlQuery(new {id = 10});\n\n// \u793a\u4f8b\u516b\nvar persons = @"\nselect * from person p\nleft join personDetail pd on p.Id == pd.pid\nwhere p.Id > @id;".SqlQuery(new {id = 10});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = await "select * from person".SqlQueryAsync();\n\n// \u793a\u4f8b\u4e8c\nvar persons = await "select top 10 * from person where id > @id".SqlQueryAsync(new {id = 10});\n\n// \u793a\u4f8b\u4e09\nvar persons = await "select Id, Name, Age from person where name like %@name%".SqlQueryAsync(new Dictionary{ {"name", "Fur"} });\n\n// \u793a\u4f8b\u56db\nvar persons = await "select * from person where name=@name limit 1,10".SqlQueryAsync(new []{ new MySqlParameter("name","Fur") });\n\n// \u793a\u4f8b\u4e94\nvar persons = await "select * from person where id>@id and name like %@name%".SqlQueryAsync(new YourModel { Id = 1, Name = "Fur" });\n\n// \u793a\u4f8b\u516d\nvar persons = await "exec PROC_GetPerson @id".SqlQueryAsync(new {id = 10});\n\n// \u793a\u4f8b\u4e03\nvar persons = await "select * from FN_GetPersons(@id)".SqlQueryAsync(new {id = 10});\n\n// \u793a\u4f8b\u516b\nvar persons = await @"\nselect * from person p\nleft join personDetail pd on p.Id == pd.pid\nwhere p.Id > @id;".SqlQueryAsync(new {id = 10});\n')),Object(i.b)("h3",{id:"91523-\u8fd4\u56de-dataset"},"9.15.2.3 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"DataSet")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataSet = @"\nselect * from person;\nselect * from student;".SqlQueries();\n\n// \u793a\u4f8b\u4e8c\nvar dataSet = @"\nselect * from person where Id > @id;\nselect * from student where Name like %@name%;".SqlQueries(new {id = 1, name = "fur"});\n\n// \u793a\u4f8b\u4e09\nvar dataSet = @"\nselect * from person;\nexec PROC_GetStudents(@id);\nselect \'Fur\';\nselect * from FN_GetPerson(@id);".SqlQueries(new {id = 1});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataSet = await @"\nselect * from person;\nselect * from student;".SqlQueriesAsync();\n\n// \u793a\u4f8b\u4e8c\nvar dataSet = await @"\nselect * from person where Id > @id;\nselect * from student where Name like %@name%;".SqlQueriesAsync(new {id = 1, name = "fur"});\n\n// \u793a\u4f8b\u4e09\nvar dataSet = await @"\nselect * from person;\nexec PROC_GetStudents(@id);\nselect \'Fur\';\nselect * from FN_GetPerson(@id);".SqlQueriesAsync(new {id = 1});\n')),Object(i.b)("h3",{id:"91524-\u8fd4\u56de-tuplet1t8"},"9.15.2.4 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"Tuple")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar (persons, students) = @"\nselect * from person;\nselect * from student;".SqlQueries();\n\n// \u793a\u4f8b\u4e8c\nvar (persons, students) = @"\nselect * from person where Id > @id;\nselect * from student where Name like %@name%;".SqlQueries(new {id = 1, name = "fur"});\n\n// \u793a\u4f8b\u4e09\nvar (persons, students, string, PersonDto) = @"\nselect * from person;\nexec PROC_GetStudents(@id);\nselect \'Fur\';\nselect * from FN_GetPerson(@id);".SqlQueries(new {id = 1});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar (persons, students) = await @"\nselect * from person;\nselect * from student;".SqlQueriesAsync();\n\n// \u793a\u4f8b\u4e8c\nvar (persons, students) = await @"\nselect * from person where Id > @id;\nselect * from student where Name like %@name%;".SqlQueriesAsync(new {id = 1, name = "fur"});\n\n// \u793a\u4f8b\u4e09\nvar (persons, students, string, PersonDto) = await @"\nselect * from person;\nexec PROC_GetStudents(@id);\nselect \'Fur\';\nselect * from FN_GetPerson(@id);".SqlQueriesAsync(new {id = 1});\n')),Object(i.b)("h3",{id:"91525-\u8fd4\u56de-\u5355\u884c\u5355\u5217"},"9.15.2.5 \u8fd4\u56de \u5355\u884c\u5355\u5217"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar value = "select Name from person where id = @id".SqlScalar(new {id = 1});\n\n// \u793a\u4f8b\u4e8c\nvar value = "select Name from person where id = @id".SqlScalar(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar value = "select Age from person where id = @id".SqlScalar(new {id = 1});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar value = await "select Name from person where id = @id".SqlScalarAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e8c\nvar value = await "select Name from person where id = @id".SqlScalarAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar value = await "select Age from person where id = @id".SqlScalarAsync(new {id = 1});\n')),Object(i.b)("h3",{id:"91526-\u8fd4\u56de-\u53d7\u5f71\u54cd\u884c\u6570"},"9.15.2.6 \u8fd4\u56de \u53d7\u5f71\u54cd\u884c\u6570"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar rowEffects = "insert into person(Name,Age,Address) values(@name,@age,@address)".SqlNonQuery(person);\n\n// \u793a\u4f8b\u4e8c\nvar rowEffects = @"\ninsert into person(Name,Age,Address) values(@name,@age,@address);\ninsert into person(Name,Age,Address) values(@name,@age,@address);".SqlNonQuery(persons);\n\n// \u793a\u4f8b\u4e09\nvar rowEffects = "update person set name=@name where id=@id".SqlNonQuery(new {id=1, name="\u767e\u5c0f\u50e7"});\n\n// \u793a\u4f8b\u56db\nvar rowEffects = "delete from person where @id > 10".SqlNonQuery(new {id=1});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar rowEffects = await "insert into person(Name,Age,Address) values(@name,@age,@address)".SqlNonQueryAsync(person);\n\n// \u793a\u4f8b\u4e8c\nvar rowEffects = @"\ninsert into person(Name,Age,Address) values(@name,@age,@address);\ninsert into person(Name,Age,Address) values(@name,@age,@address);".SqlNonQueryAsync(persons);\n\n// \u793a\u4f8b\u4e09\nvar rowEffects = await "update person set name=@name where id=@id".SqlNonQueryAsync(new {id=1, name="\u767e\u5c0f\u50e7"});\n\n// \u793a\u4f8b\u56db\nvar rowEffects = await "delete from person where @id > 10".SqlNonQueryAsync(new {id=1});\n')),Object(i.b)("h2",{id:"9153-\u61d2\u4eba\u65e0\u654c-\u5b58\u50a8\u8fc7\u7a0b-"},"9.15.3 \u61d2\u4eba\u65e0\u654c ",Object(i.b)("inlineCode",{parentName:"h2"},"\u5b58\u50a8\u8fc7\u7a0b")," \ud83d\udc2e"),Object(i.b)("h3",{id:"91531-\u8fd4\u56de-datatable"},"9.15.3.1 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"DataTable")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataTable = "PROC_Name".SqlProcedureQuery();\n\n// \u793a\u4f8b\u4e8c\nvar dataTable = "PROC_Name".SqlProcedureQuery(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar dataTable = "PROC_Name".SqlProcedureQuery(new {id = 1, age = 27});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataTable = await "PROC_Name".SqlProcedureQueryAsync();\n\n// \u793a\u4f8b\u4e8c\nvar dataTable = await "PROC_Name".SqlProcedureQueryAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar dataTable = await "PROC_Name".SqlProcedureQueryAsync(new {id = 1, age = 27});\n')),Object(i.b)("h3",{id:"91532-\u8fd4\u56de-listt"},"9.15.3.2 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"List")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = "PROC_Name".SqlProcedureQuery();\n\n// \u793a\u4f8b\u4e8c\nvar persons = "PROC_Name".SqlProcedureQuery(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar persons = "PROC_Name".SqlProcedureQuery(new {id = 1, age = 27});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = await "PROC_Name".SqlProcedureQueryAsync();\n\n// \u793a\u4f8b\u4e8c\nvar persons = await "PROC_Name".SqlProcedureQueryAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar persons = await "PROC_Name".SqlProcedureQueryAsync(new {id = 1, age = 27});\n')),Object(i.b)("h3",{id:"91533-\u8fd4\u56de-dataset"},"9.15.3.3 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"DataSet")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataSet = "PROC_Name".SqlProcedureQueries();\n\n// \u793a\u4f8b\u4e8c\nvar dataSet = "PROC_Name".SqlProcedureQueries(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar dataSet = "PROC_Name".SqlProcedureQueries(new {id = 1, age = 27});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataSet = await "PROC_Name".SqlProcedureQueriesAsync();\n\n// \u793a\u4f8b\u4e8c\nvar dataSet = await "PROC_Name".SqlProcedureQueriesAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar dataSet = await "PROC_Name".SqlProcedureQueriesAsync(new {id = 1, age = 27});\n')),Object(i.b)("h3",{id:"91534-\u8fd4\u56de-tuplet1t8"},"9.15.3.4 \u8fd4\u56de ",Object(i.b)("inlineCode",{parentName:"h3"},"Tuple")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = "PROC_Name".SqlProcedureQueries();\n\n// \u793a\u4f8b\u4e8c\nvar (persons,students) = "PROC_Name".SqlProcedureQueries(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar (persons,students,string) = "PROC_Name".SqlProcedureQueries(new {id = 1, age = 27});\n\n// \u793a\u4f8b\u56db\nvar (persons,students,personDetail,string) = "PROC_Name".SqlProcedureQueries(new {id = 1, age = 27});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar persons = await "PROC_Name".SqlProcedureQueriesAsync();\n\n// \u793a\u4f8b\u4e8c\nvar (persons,students) = await "PROC_Name".SqlProcedureQueriesAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar (persons,students,string) = await "PROC_Name".SqlProcedureQueriesAsync(new {id = 1, age = 27});\n\n// \u793a\u4f8b\u56db\nvar (persons,students,personDetail,string) = await "PROC_Name".SqlProcedureQueriesAsync(new {id = 1, age = 27});\n')),Object(i.b)("h3",{id:"91535-\u8fd4\u56de-\u5355\u884c\u5355\u5217"},"9.15.3.5 \u8fd4\u56de \u5355\u884c\u5355\u5217"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar value = "PROC_Name".SqlProcedureScalar(new {id = 1});\n\n// \u793a\u4f8b\u4e8c\nvar value = "PROC_Name".SqlProcedureScalar(new {id = 1, name = "\u65b0\u751f\u5e1d", address ="\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02"});\n\n// \u793a\u4f8b\u4e09\nvar value = "PROC_Name".SqlProcedureScalar(new {id = 1, address ="\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02"});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar value = await "PROC_Name".SqlProcedureScalarAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e8c\nvar value = await "PROC_Name".SqlProcedureScalarAsync(new {id = 1, name = "\u65b0\u751f\u5e1d", address ="\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02"});\n\n// \u793a\u4f8b\u4e09\nvar value = await "PROC_Name".SqlProcedureScalarAsync(new {id = 1, address ="\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02"});\n')),Object(i.b)("h3",{id:"91536-\u8fd4\u56de-\u53d7\u5f71\u54cd\u884c\u6570"},"9.15.3.6 \u8fd4\u56de \u53d7\u5f71\u54cd\u884c\u6570"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar rowEffects = "PROC_Name".SqlProcedureNonQuery(person);\n\n// \u793a\u4f8b\u4e8c\nvar rowEffects = "PROC_Name".SqlProcedureNonQuery(new {id = 1, name = "\u65b0\u751f\u5e1d", address ="\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02"});\n\n// \u793a\u4f8b\u4e09\nvar rowEffects = "PROC_Name".SqlProcedureNonQuery(new {id=1, name="\u767e\u5c0f\u50e7"});\n\n// \u793a\u4f8b\u56db\nvar rowEffects = "PROC_Name".SqlProcedureNonQuery(new {id=1});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar rowEffects = await "PROC_Name".SqlProcedureNonQueryAsync(person);\n\n// \u793a\u4f8b\u4e8c\nvar rowEffects = await "PROC_Name".SqlProcedureNonQueryAsync(new {id = 1, name = "\u65b0\u751f\u5e1d", address ="\u5e7f\u4e1c\u7701\u4e2d\u5c71\u5e02"});\n\n// \u793a\u4f8b\u4e09\nvar rowEffects = await "PROC_Name".SqlProcedureNonQueryAsync(new {id=1, name="\u767e\u5c0f\u50e7"});\n\n// \u793a\u4f8b\u56db\nvar rowEffects = await "PROC_Name".SqlProcedureNonQueryAsync(new {id=1});\n')),Object(i.b)("h3",{id:"91537-\u5e26-outputreturn-\u8fd4\u56de"},"9.15.3.7 \u5e26 ",Object(i.b)("inlineCode",{parentName:"h3"},"OUTPUT/RETURN")," \u8fd4\u56de"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-sql",metastring:"{3,4,10-12,15-17,22}","{3,4,10-12,15-17,22}":!0}),"CREATE PROC PROC_Output\n @Id INT, // \u8f93\u5165\u53c2\u6570\n @Name NVARCHAR(32) OUTPUT, // \u8f93\u51fa\u53c2\u6570\uff0c\u8fd8\u5e26\u957f\u5ea6\n @Age INT OUTPUT // \u8f93\u51fa\u53c2\u6570\nAS\nBEGIN\n SET @Name = 'Fur Output';\n\n // \u8f93\u51fa\u7ed3\u679c\u96c6\n SELECT *\n FROM dbo.Test\n WHERE Id > @Id;\n\n // \u8f93\u51fa\u7ed3\u679c\u96c6\n SELECT TOP 10\n *\n FROM dbo.Test;\n\n SET @Age = 27;\n\n // \u5e26 RETURN \u8fd4\u56de\n RETURN 10;\nEND;\n")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,10,13,16}","{1,10,13,16}":!0}),"using Fur.DatabaseAccessor;\nusing System.Data;\n\nnamespace Fur.Application\n{\n public class ProcOutputModel\n {\n public int Id { get; set; } // \u8f93\u5165\u53c2\u6570\n\n [DbParameter(ParameterDirection.Output, Size = 32)]\n public string Name { get; set; } // \u8f93\u51fa\u53c2\u6570\n\n [DbParameter(ParameterDirection.Output)]\n public int Age { get; set; } // \u8f93\u51fa\u53c2\u6570\n\n [DbParameter(ParameterDirection.ReturnValue)]\n public int ReturnValue { get; set; } // \u8fd4\u56de\u503c\n }\n}\n")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nProcedureOutputResult result = "PROC_Name".SqlProcedureOutput(new {id=1, name="\u767e\u5c0f\u50e7"});\n\n// \u793a\u4f8b\u4e8c\nProcedureOutputResult result = "PROC_Name".SqlProcedureOutput();\n\n// \u793a\u4f8b\u4e09\nProcedureOutputResult<(List, List)> result = "PROC_Name".SqlProcedureOutput<(List, List)>();\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n// \u793a\u4f8b\u4e00\nProcedureOutputResult result = await "PROC_Name".SqlProcedureOutputAsync(new {id=1, name="\u767e\u5c0f\u50e7"});\n\n// \u793a\u4f8b\u4e8c\nProcedureOutputResult result = await "PROC_Name".SqlProcedureOutputAsync();\n\n// \u793a\u4f8b\u4e09\nProcedureOutputResult<(List, List)> result = await "PROC_Name".SqlProcedureOutputAsync<(List, List)>();\n')),Object(i.b)("h2",{id:"9154-\u61d2\u4eba\u65e0\u654c-\u51fd\u6570-"},"9.15.4 \u61d2\u4eba\u65e0\u654c ",Object(i.b)("inlineCode",{parentName:"h2"},"\u51fd\u6570")," \ud83d\udc2e"),Object(i.b)("h3",{id:"91541-\u6807\u91cf\u51fd\u6570"},"9.15.4.1 ",Object(i.b)("inlineCode",{parentName:"h3"},"\u6807\u91cf\u51fd\u6570")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar value = "FN_Name".SqlFunctionScalar();\n\n// \u793a\u4f8b\u4e8c\nvar value = "FN_Name".SqlFunctionScalar(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar value = "FN_Name".SqlFunctionScalar();\n\n// \u793a\u4f8b\u56db\nvar value = "FN_Name".SqlFunctionScalar(new {id = 1});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar value = await "FN_Name".SqlFunctionScalarAsync();\n\n// \u793a\u4f8b\u4e8c\nvar value = await "FN_Name".SqlFunctionScalarAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar value = await "FN_Name".SqlFunctionScalarAsync();\n\n// \u793a\u4f8b\u56db\nvar value = await "FN_Name".SqlFunctionScalarAsync(new {id = 1});\n')),Object(i.b)("h3",{id:"91542-\u8868\u503c\u51fd\u6570"},"9.15.4.2 ",Object(i.b)("inlineCode",{parentName:"h3"},"\u8868\u503c\u51fd\u6570")),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataTable = "FN_Name".SqlFunctionQuery();\n\n// \u793a\u4f8b\u4e8c\nvar dataTable = "FN_Name".SqlFunctionQuery(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar persons = "FN_Name".SqlFunctionQuery();\n\n// \u793a\u4f8b\u56db\nvar persons = "FN_Name".SqlFunctionQuery(new {id = 1});\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nvar dataTable = await "FN_Name".SqlFunctionQueryAsync();\n\n// \u793a\u4f8b\u4e8c\nvar dataTable = await "FN_Name".SqlFunctionQueryAsync(new {id = 1});\n\n// \u793a\u4f8b\u4e09\nvar persons = await "FN_Name".SqlFunctionQueryAsync();\n\n// \u793a\u4f8b\u56db\nvar persons = await "FN_Name".SqlFunctionQueryAsync(new {id = 1});\n')),Object(i.b)("h2",{id:"9155-isqlrepository-\u64cd\u4f5c"},"9.15.5 ",Object(i.b)("inlineCode",{parentName:"h2"},"ISqlRepository")," \u64cd\u4f5c"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"ISqlRepository")," \u4ed3\u50a8\u662f\u4e13\u95e8\u5904\u7406 ",Object(i.b)("inlineCode",{parentName:"p"},"Sql")," \u64cd\u4f5c\u7684\uff0c\u65e0\u9700\u5b9e\u4f53\u65b9\u5f0f\uff0c\u6240\u6709\u63a5\u53e3\u548c ",Object(i.b)("inlineCode",{parentName:"p"},"\u61d2\u4eba\u65e0\u654c")," \u65b9\u5f0f\u4e00\u6837\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'// \u793a\u4f8b\u4e00\nvar dataTable = sqlRepository.SqlQuery("select * from person");\n\n// \u793a\u4f8b\u4e8c\nvar dataTable = sqlRepository.SqlQuery("select * from person where id > @id", new { id = 10});\n\n// \u793a\u4f8b\u56db\nvar persons = sqlRepository.SqlQuery("select * from person");\n\n// \u793a\u4f8b\u4e94\nvar persons = sqlRepository.SqlQuery("select * from person where id > @id", new { id = 10});\n\n// \u4e0d\u518d\u4e3e\u4f8b\u5b50\u3002\u3002\u3002\u3002\u3002\u3002\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u8865\u5145\u8bf4\u660e")),Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u4e0d\u7ba1\u662f\u90a3\u79cd\u65b9\u5f0f\u64cd\u4f5c ",Object(i.b)("inlineCode",{parentName:"p"},"Sql")," \uff0c\u65b9\u6cd5\u540d\u53c2\u6570\u90fd\u662f\u4e00\u81f4\u7684\uff0c\u5982\uff1a"),Object(i.b)("ul",{parentName:"div"},Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlQuery")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlQueryAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlQueries")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlQueriesAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlNonQuery")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlNonQueryAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlScalar")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlScalarAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureQuery")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureQueryAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureQueries")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureQueriesAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureScalar")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureScalarAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureNonQuery")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureNonQueryAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureOutput")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlProcedureOutputAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlFunctionScalar")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlFunctionScalarAsync")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlFunctionQuery")),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"SqlFunctionQuery"))))),Object(i.b)("h2",{id:"9156-irepository-\u64cd\u4f5c"},"9.15.6 ",Object(i.b)("inlineCode",{parentName:"h2"},"IRepository")," \u64cd\u4f5c"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"IRepository")," \u4e5f\u80fd\u64cd\u4f5c ",Object(i.b)("inlineCode",{parentName:"p"},"sql"),"\uff0c\u8c03\u7528\u65b9\u6cd5\u4e5f\u662f\u548c\u4e0a\u9762\u4e00\u81f4\u7684\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'var dataTable = repository.Sql().SqlQuery("select * from person");\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u4e0d\u518d\u5217\u4e3e\u6240\u6709\u4f8b\u5b50\u3002"))),Object(i.b)("h2",{id:"9157-irepositorytentity-\u64cd\u4f5c"},"9.15.7 ",Object(i.b)("inlineCode",{parentName:"h2"},"IRepository")," \u64cd\u4f5c"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"IRepository")," \u4e5f\u80fd\u64cd\u4f5c ",Object(i.b)("inlineCode",{parentName:"p"},"sql"),"\uff0c\u8c03\u7528\u65b9\u6cd5\u4e5f\u662f\u548c\u4e0a\u9762\u4e00\u81f4\u7684\uff0c\u5982\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'var dataTable = personRepository.SqlQuery("select * from person");\n')),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7531\u4e8e\u7bc7\u5e45\u6709\u9650\uff0c\u4e0d\u518d\u5217\u4e3e\u6240\u6709\u4f8b\u5b50\u3002"))),Object(i.b)("h2",{id:"9158-\u5173\u4e8e-sql-\u53c2\u6570"},"9.15.8 \u5173\u4e8e ",Object(i.b)("inlineCode",{parentName:"h2"},"Sql")," \u53c2\u6570"),Object(i.b)("p",null,"\u6240\u6709 ",Object(i.b)("inlineCode",{parentName:"p"},"sql"),"\u3001",Object(i.b)("inlineCode",{parentName:"p"},"\u5b58\u50a8\u8fc7\u7a0b"),"\uff0c",Object(i.b)("inlineCode",{parentName:"p"},"\u51fd\u6570")," \u53c2\u6570\u90fd\u652f\u6301\u56db\u79cd\u65b9\u5f0f\uff1a"),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"DbParameter[]"),"\uff1a\u6570\u7ec4\u7c7b\u578b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"new {}"),"\uff1a\u533f\u540d\u7c7b\u578b"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"new Class{}"),"\uff1a\u5f3a\u7c7b\u578b\u7c7b\u578b\uff08\u652f\u6301\u590d\u6742\u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570\uff09"),Object(i.b)("li",{parentName:"ul"},Object(i.b)("inlineCode",{parentName:"li"},"Dictionary")," \u7c7b\u578b")),Object(i.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(i.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u5efa\u8bae\u9664\u4e86\u590d\u6742\u7684\u5b58\u50a8\u8fc7\u7a0b\uff08\u5e26 ",Object(i.b)("inlineCode",{parentName:"p"},"OUTPUT/RETURN"),"\uff09\u7684\u4ee5\u5916\uff0c\u6240\u6709\u53c2\u6570\u5efa\u8bae\u4f7f\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"new {}")," \u533f\u540d\u7c7b\u578b\uff0c\u5982\u679c\u9700\u8981\u52a8\u6001\u53c2\u6570\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528 ",Object(i.b)("inlineCode",{parentName:"p"},"Dictionary")," \u7c7b\u578b\u3002"))),Object(i.b)("h2",{id:"9159-\u591a\u6570\u636e\u5e93-sql-\u64cd\u4f5c--"},"9.15.9 \u591a\u6570\u636e\u5e93 ",Object(i.b)("inlineCode",{parentName:"h2"},"Sql")," \u64cd\u4f5c \ud83d\udcaf \ud83d\udc9b"),Object(i.b)("p",null,Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u62e5\u6709\u975e\u5e38\u7075\u6d3b\u7684\u591a\u6570\u636e\u5e93\u64cd\u4f5c\u65b9\u5f0f\uff0c\u53ea\u9700\u901a\u8fc7\u591a",Object(i.b)("strong",{parentName:"p"},"\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\u5b9a\u4f4d\u5668"),"\u5373\u53ef\u52a8\u6001\u5207\u6362\u6570\u636e\u5e93\u3002"),Object(i.b)("h3",{id:"91591-\u61d2\u4eba\u65e0\u654c--\u65b9\u5f0f"},"9.15.9.1 \u61d2\u4eba\u65e0\u654c \ud83d\udc2e \u65b9\u5f0f"),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-cs"}),'var dataTable = "select * from person".Change().SqlQuery();\n\nvar persons = "select * from person whre id > @id".Change().SqlQuery();\n')),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u8865\u5145\u8bf4\u660e")),Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u61d2\u4eba\u65b9\u5f0f \u53ea\u9700\u8981\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"Change")," \u65b9\u5f0f\u5373\u53ef\u52a8\u6001\u5207\u6362\u6570\u636e\u5e93\u3002"))),Object(i.b)("h3",{id:"91592-isqlrepository-\u65b9\u5f0f"},"9.15.9.2 ",Object(i.b)("inlineCode",{parentName:"h3"},"ISqlRepository")," \u65b9\u5f0f"),Object(i.b)("p",null,"\u53ea\u9700\u8981\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"ISqlRepository")," \u6ce8\u5165\u6216\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"sqlRepository.Change()")," \u5207\u6362\u3002"),Object(i.b)("h3",{id:"91593-irepository-\u65b9\u5f0f"},"9.15.9.3 ",Object(i.b)("inlineCode",{parentName:"h3"},"IRepository")," \u65b9\u5f0f"),Object(i.b)("p",null,"\u53ea\u9700\u8981\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"repository.Change()")," \u83b7\u53d6\u5373\u53ef\u3002"),Object(i.b)("h3",{id:"91594-irepositorytentity-\u65b9\u5f0f"},"9.15.9.4 ",Object(i.b)("inlineCode",{parentName:"h3"},"IRepository")," \u65b9\u5f0f"),Object(i.b)("p",null,"\u53ea\u9700\u8981\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"IRepository")," \u6ce8\u5165\u6216\u901a\u8fc7 ",Object(i.b)("inlineCode",{parentName:"p"},"personRepository.Change()")," \u5207\u6362\u3002"),Object(i.b)("h2",{id:"91510-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.15.10 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(i.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(t.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(t.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(t.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(i.b)("div",Object(t.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(i.b)("a",Object(t.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}d.isMDXComponent=!0},142:function(e,n,a){"use strict";a.d(n,"a",(function(){return b})),a.d(n,"b",(function(){return m}));var t=a(0),r=a.n(t);function i(e,n,a){return n in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}function c(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),a.push.apply(a,t)}return a}function o(e){for(var n=1;n=0||(r[a]=e[a]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}var s=r.a.createContext({}),d=function(e){var n=r.a.useContext(s),a=n;return e&&(a="function"==typeof e?e(n):o(o({},n),e)),a},b=function(e){var n=d(e.components);return r.a.createElement(s.Provider,{value:n},e.children)},p={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},u=r.a.forwardRef((function(e,n){var a=e.components,t=e.mdxType,i=e.originalType,c=e.parentName,s=l(e,["components","mdxType","originalType","parentName"]),b=d(a),u=t,m=b["".concat(c,".").concat(u)]||b[u]||p[u]||i;return a?r.a.createElement(m,o(o({ref:n},s),{},{components:a})):r.a.createElement(m,o({ref:n},s))}));function m(e,n){var a=arguments,t=n&&n.mdxType;if("string"==typeof e||t){var i=a.length,c=new Array(i);c[0]=u;var o={};for(var l in n)hasOwnProperty.call(n,l)&&(o[l]=n[l]);o.originalType=e,o.mdxType="string"==typeof e?e:t,c[1]=o;for(var s=2;s[UnitOfWork]",id:"92541-unitofwork",children:[]},{value:"9.25.4.2 [NonTransact]",id:"92542-nontransact",children:[]}]},{value:"9.25.5 \u5e38\u89c1\u9519\u8bef",id:"9255-\u5e38\u89c1\u9519\u8bef",children:[]},{value:"9.25.6 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9256-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],u={rightToc:b};function d(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(o.b)("wrapper",Object(a.a)({},u,t,{components:n,mdxType:"MDXLayout"}),Object(o.b)("h2",{id:"9251-\u4e8b\u52a1"},"9.25.1 \u4e8b\u52a1"),Object(o.b)("p",null,"\u4e8b\u52a1\u6307\u4f5c\u4e3a\u5355\u4e2a\u903b\u8f91\u5de5\u4f5c\u5355\u5143\u6267\u884c\u7684\u4e00\u7cfb\u5217\u64cd\u4f5c\uff0c\u8981\u4e48",Object(o.b)("strong",{parentName:"p"},"\u5b8c\u5168\u5730\u6267\u884c\uff0c\u8981\u4e48\u5b8c\u5168\u5730\u4e0d\u6267\u884c"),"\u3002"),Object(o.b)("p",null,"\u7b80\u5355\u7684\u8bf4\uff0c\u4e8b\u52a1\u5c31\u662f\u5e76\u53d1\u63a7\u5236\u7684\u5355\u4f4d\uff0c\u662f\u7528\u6237\u5b9a\u4e49\u7684\u4e00\u4e2a\u64cd\u4f5c\u5e8f\u5217\u3002 \u800c\u4e00\u4e2a\u903b\u8f91\u5de5\u4f5c\u5355\u5143\u8981\u6210\u4e3a\u4e8b\u52a1\uff0c\u5c31\u5fc5\u987b\u6ee1\u8db3 ",Object(o.b)("inlineCode",{parentName:"p"},"ACID")," \u5c5e\u6027\u3002"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"A"),"\uff1a\u539f\u5b50\u6027\uff08Atomicity\uff09\uff1a\u4e8b\u52a1\u4e2d\u7684\u64cd\u4f5c\u8981\u4e48\u90fd\u4e0d\u505a\uff0c\u8981\u4e48\u5c31\u5168\u505a"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"C"),"\uff1a\u4e00\u81f4\u6027\uff08Consistency\uff09\uff1a\u4e8b\u52a1\u6267\u884c\u7684\u7ed3\u679c\u5fc5\u987b\u662f\u4ece\u6570\u636e\u5e93\u4ece\u4e00\u4e2a\u4e00\u81f4\u6027\u72b6\u6001\u8f6c\u6362\u5230\u53e6\u4e00\u4e2a\u4e00\u81f4\u6027\u72b6\u6001"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"I"),"\uff1a\u9694\u79bb\u6027\uff08Isolation\uff09\uff1a\u4e00\u4e2a\u4e8b\u52a1\u7684\u6267\u884c\u4e0d\u80fd\u88ab\u5176\u4ed6\u4e8b\u52a1\u5e72\u6270"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"D"),"\uff1a\u6301\u4e45\u6027\uff08Durability\uff09\uff1a\u4e00\u4e2a\u4e8b\u52a1\u4e00\u65e6\u63d0\u4ea4\uff0c\u5b83\u5bf9\u6570\u636e\u5e93\u4e2d\u6570\u636e\u7684\u6539\u53d8\u5c31\u5e94\u8be5\u662f\u6c38\u4e45\u6027\u7684")),Object(o.b)("p",null,Object(o.b)("strong",{parentName:"p"},"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(o.b)("inlineCode",{parentName:"strong"},"Fur")," \u6846\u67b6\u4e3a\u6bcf\u4e00\u6b21\u8bf7\u6c42\u90fd\u5f00\u542f\u4e86\u5206\u5e03\u5f0f\u4e8b\u52a1\uff0c\u4fdd\u8bc1\u4e86\u6bcf\u4e00\u6b21\u8bf7\u6c42\u90fd\u662f\u4e00\u4e2a\u5b8c\u6574\u7684 ",Object(o.b)("inlineCode",{parentName:"strong"},"\u5de5\u4f5c\u5355\u5143")),"\u3002\u5f53\u7136\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u624b\u52a8\u7ba1\u7406\u4e8b\u52a1\u3002"),Object(o.b)("h2",{id:"9252-\u5de5\u4f5c\u5355\u5143"},"9.25.2 \u5de5\u4f5c\u5355\u5143"),Object(o.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u5c31\u662f\u4e3a\u4e86\u4fdd\u8bc1\u4e00\u6b21\u5b8c\u6574\u7684\u529f\u80fd\u64cd\u4f5c\u6240\u4ea7\u751f\u7684\u4e00\u4e9b\u5217\u63d0\u4ea4\u6570\u636e\u7684\u5b8c\u6574\u6027\uff0c\u8d77\u7740\u4e8b\u52a1\u7684\u4f5c\u7528\u3002\u5728\u8ba1\u7b97\u673a\u9886\u57df\u4e2d\uff0c\u5de5\u4f5c\u5355\u5143\u901a\u5e38\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"UnitOfWork")," \u540d\u79f0\u8868\u793a\u3002"),Object(o.b)("p",null,"\u901a\u5e38\u6211\u4eec\u4fdd\u8bc1\u7528\u6237\u7684\u6bcf\u4e00\u6b21\u8bf7\u6c42\u90fd\u662f\u5904\u4e8e\u5728\u4e00\u4e2a\u529f\u80fd\u5355\u5143\u4e2d\uff0c\u4e5f\u5c31\u662f\u5de5\u4f5c\u5355\u5143\u3002"),Object(o.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u5de5\u4f5c\u5355\u5143\u65e0\u9700\u6211\u4eec\u624b\u52a8\u7ef4\u62a4\uff0c\u6846\u67b6\u4f1a\u81ea\u52a8\u4fdd\u8bc1\u4e86\u6bcf\u4e00\u6b21\u8bf7\u6c42\u90fd\u662f\u4e00\u4e2a ",Object(o.b)("inlineCode",{parentName:"p"},"\u5de5\u4f5c\u5355\u5143"),"\uff0c\u8981\u4e48\u540c\u65f6\u6210\u529f\uff0c\u8981\u4e48\u540c\u65f6\u5931\u8d25\u3002"),Object(o.b)("h2",{id:"9253-\u5982\u4f55\u4f7f\u7528"},"9.25.3 \u5982\u4f55\u4f7f\u7528"),Object(o.b)("h3",{id:"92531-\u81ea\u52a8\u7ba1\u7406"},"9.25.3.1 \u81ea\u52a8\u7ba1\u7406"),Object(o.b)("p",null,"\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u5de5\u4f5c\u5355\u5143\u65e0\u9700\u6211\u4eec\u624b\u52a8\u7ef4\u62a4\uff0c\u6846\u67b6\u4f1a\u81ea\u52a8\u4fdd\u8bc1\u4e86\u6bcf\u4e00\u6b21\u8bf7\u6c42\u90fd\u662f\u4e00\u4e2a ",Object(o.b)("inlineCode",{parentName:"p"},"\u5de5\u4f5c\u5355\u5143"),"\uff0c\u8981\u4e48\u540c\u65f6\u6210\u529f\uff0c\u8981\u4e48\u540c\u65f6\u5931\u8d25\u3002\u6240\u4ee5\u65e0\u9700\u64cd\u4f5c\u3002"),Object(o.b)("h3",{id:"92532-\u624b\u52a8\u7ba1\u7406"},"9.25.3.2 \u624b\u52a8\u7ba1\u7406"),Object(o.b)(i.a,{defaultValue:"one",values:[{label:"\u793a\u4f8b\u4e00",value:"one"},{label:"\u793a\u4f8b\u4e8c",value:"two"},{label:"\u793a\u4f8b\u4e09",value:"three"}],mdxType:"Tabs"},Object(o.b)(c.a,{value:"one",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// \u5f00\u542f\u4e8b\u52a1\nusing (var transaction = _testRepository.Database.BeginTransaction())\n{\n try\n {\n _testRepository.Insert(new Blog { Url = "http://blogs.msdn.com/dotnet" });\n _testRepository.SaveChanges();\n\n _testRepository.Insert(new Blog { Url = "http://blogs.msdn.com/visualstudio" });\n _testRepository.SaveChanges();\n\n var blogs = _testRepository.Entity\n .OrderBy(b => b.Url)\n .ToList();\n\n // \u63d0\u4ea4\u4e8b\u52a1\n transaction.Commit();\n }\n catch (Exception)\n {\n // \u56de\u6eda\u4e8b\u52a1\n transaction.RollBack();\n }\n}\n'))),Object(o.b)(c.a,{value:"two",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'var options = new DbContextOptionsBuilder()\n .UseSqlServer(new SqlConnection(connectionString))\n .Options;\n\n// \u521b\u5efa\u8fde\u63a5\u5b57\u7b26\u4e32\nusing (var context1 = new HoaDbContext(options))\n{\n // \u5f00\u542f\u4e8b\u52a1\n using (var transaction = context1.Database.BeginTransaction())\n {\n try\n {\n _testRepository.Insert(new Blog { Url = "http://blogs.msdn.com/dotnet" });\n _testRepository.SaveChanges();\n\n context1.Blogs.Add(new Blog { Url = "http://blogs.msdn.com/dotnet" });\n context1.SaveChanges();\n\n // \u521b\u5efa\u65b0\u7684\u8fde\u63a5\u5bf9\u8c61\n using (var context2 = new HoaDbContext(options))\n {\n // \u5171\u4eab\u8fde\u63a5\u4e8b\u52a1\n context2.Database.UseTransaction(transaction.GetDbTransaction());\n\n var blogs = context2.Blogs\n .OrderBy(b => b.Url)\n .ToList();\n }\n\n // \u63d0\u4ea4\u4e8b\u52a1\n transaction.Commit();\n }\n catch (Exception)\n {\n // \u56de\u6eda\u4e8b\u52a1\n transaction.RollBack();\n }\n }\n}\n'))),Object(o.b)(c.a,{value:"three",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// \u5f00\u542f\u5206\u5e03\u5f0f\u4e8b\u52a1\nusing (var scope = new TransactionScope(\n TransactionScopeOption.Required,\n new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }))\n{\n using (var connection = new SqlConnection(connectionString))\n {\n connection.Open();\n\n try\n {\n // \u8fd9\u91cc\u662f Ado.NET \u64cd\u4f5c\n var command = connection.CreateCommand();\n command.CommandText = "DELETE FROM dbo.Blogs";\n command.ExecuteNonQuery();\n\n // \u521b\u5efaEF Core \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\n var options = new DbContextOptionsBuilder()\n .UseSqlServer(connection)\n .Options;\n using (var context = new BloggingContext(options))\n {\n context.Blogs.Add(new Blog { Url = "http://blogs.msdn.com/dotnet" });\n context.SaveChanges();\n }\n\n // \u6846\u67b6\u5c01\u88c5\u7684\u4ed3\u50a8\n _testRepository.Insert(new Blog { Url = "http://blogs.msdn.com/dotnet" });\n _testRepository.SaveChanges();\n\n // \u63d0\u4ea4\u4e8b\u52a1\n scope.Complete();\n }\n catch (System.Exception)\n {\n // \u81ea\u52a8\u56de\u6eda\n }\n }\n}\n')))),Object(o.b)("h2",{id:"9254-\u5de5\u4f5c\u5355\u5143\u7279\u6027\u8bf4\u660e"},"9.25.4 \u5de5\u4f5c\u5355\u5143\u7279\u6027\u8bf4\u660e"),Object(o.b)("h3",{id:"92541-unitofwork"},"9.25.4.1 ",Object(o.b)("inlineCode",{parentName:"h3"},"[UnitOfWork]")),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"[UnitOfWork]")," \u7279\u6027\u7528\u6765\u6807\u8bb0\u4e8b\u52a1\u4fe1\u606f\uff0c\u5982\u4f5c\u7528\u8303\u56f4\uff0c\u9694\u79bb\u7ea7\u522b\u7b49\u3002"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Enabled"),"\uff1a\u662f\u5426\u542f\u52a8\u5de5\u4f5c\u5355\u5143\uff0c\u9ed8\u8ba4 ",Object(o.b)("inlineCode",{parentName:"li"},"true")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"ScopeOption"),"\uff1a\u5b9a\u4e49\u4e8b\u52a1\u8303\u56f4\u884c\u4e3a\uff0c\u9ed8\u8ba4 ",Object(o.b)("inlineCode",{parentName:"li"},"TransactionScopeOption.Required")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IsolationLevel"),"\uff1a\u8bbe\u7f6e\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\uff0c\u9ed8\u8ba4 ",Object(o.b)("inlineCode",{parentName:"li"},"IsolationLevel.ReadCommitted"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AsyncFlowOption"),"\uff1a\u5141\u8bb8\u8de8\u7ebf\u7a0b\u8fde\u7eed\u4efb\u52a1\u7684\u4e8b\u52a1\u6d41\uff0c\u5982\u6709\u5f02\u6b65\u64cd\u4f5c\u9700\u5f00\u542f\u8be5\u9009\u9879\uff0c\u9ed8\u8ba4\u5f00\u542f")),Object(o.b)("div",{className:"admonition admonition-important alert alert--info"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u4e00\u65e6\u65b9\u6cd5\u8d34\u4e86 ",Object(o.b)("inlineCode",{parentName:"p"},"[UnitOfWork(false)]")," \u7279\u6027\u540e\uff0c\u90a3\u4e48\u8be5\u65b9\u6cd5\u4e0d\u518d\u542f\u7528\u5de5\u4f5c\u5355\u5143\u6a21\u5f0f\uff0c\u4e5f\u5c31\u662f\u4e0d\u5305\u542b\u4e8b\u52a1\uff0c\u4e5f\u4e0d\u4f1a\u81ea\u52a8\u63d0\u4ea4\u6570\u636e\u5e93\u3002\u614e\u7528!"))),Object(o.b)("h3",{id:"92542-nontransact"},"9.25.4.2 ",Object(o.b)("inlineCode",{parentName:"h3"},"[NonTransact]")),Object(o.b)("p",null,"\u4e00\u4f46\u65b9\u6cd5\u6216\u7c7b\u8d34\u4e86 ",Object(o.b)("inlineCode",{parentName:"p"},"[NonTransact]")," \u7279\u6027\uff0c\u90a3\u4e48",Object(o.b)("strong",{parentName:"p"},"\u5c06\u5173\u95ed\u4e8b\u52a1\u64cd\u4f5c\uff0c\u4f46\u662f\u8fd8\u662f\u4f1a\u81ea\u52a8\u4fdd\u5b58\u6570\u636e\u5e93\u5230\u6570\u636e\u3002")),Object(o.b)("h2",{id:"9255-\u5e38\u89c1\u9519\u8bef"},"9.25.5 \u5e38\u89c1\u9519\u8bef"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"A TransactionScope must be disposed on the same thread that it was created."))),Object(o.b)("p",null,"\u53ea\u9700\u8981\u5728\u5f53\u524d\u64cd\u4f5c\u65b9\u6cd5\u4e0a\u8d34 ",Object(o.b)("inlineCode",{parentName:"p"},"[NonTransact]")," \u7279\u6027\u5373\u53ef\u3002"),Object(o.b)("h2",{id:"9256-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.25.6 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))),Object(o.b)("hr",null),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(o.b)("inlineCode",{parentName:"p"},"\u4e8b\u52a1")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/ef/core/saving/transactions"}),"EF Core - \u4f7f\u7528\u4e8b\u52a1")," \u7ae0\u8282\u3002"))))}d.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return u})),t.d(n,"b",(function(){return m}));var a=t(0),r=t.n(a);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function c(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var s=r.a.createContext({}),b=function(e){var n=r.a.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},u=function(e){var n=b(e.components);return r.a.createElement(s.Provider,{value:n},e.children)},d={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},p=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,o=e.originalType,i=e.parentName,s=l(e,["components","mdxType","originalType","parentName"]),u=b(t),p=a,m=u["".concat(i,".").concat(p)]||u[p]||d[p]||o;return t?r.a.createElement(m,c(c({ref:n},s),{},{components:t})):r.a.createElement(m,c({ref:n},s))}));function m(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var o=t.length,i=new Array(o);i[0]=p;var c={};for(var l in n)hasOwnProperty.call(n,l)&&(c[l]=n[l]);c.originalType=e,c.mdxType="string"==typeof e?e:a,i[1]=c;for(var s=2;s[UnitOfWork]",id:"92541-unitofwork",children:[]},{value:"9.25.4.2 [NonTransact]",id:"92542-nontransact",children:[]}]},{value:"9.25.5 \u5e38\u89c1\u9519\u8bef",id:"9255-\u5e38\u89c1\u9519\u8bef",children:[]},{value:"9.25.6 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"9256-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],u={rightToc:b};function d(e){var n=e.components,t=Object(r.a)(e,["components"]);return Object(o.b)("wrapper",Object(a.a)({},u,t,{components:n,mdxType:"MDXLayout"}),Object(o.b)("h2",{id:"9251-\u4e8b\u52a1"},"9.25.1 \u4e8b\u52a1"),Object(o.b)("p",null,"\u4e8b\u52a1\u6307\u4f5c\u4e3a\u5355\u4e2a\u903b\u8f91\u5de5\u4f5c\u5355\u5143\u6267\u884c\u7684\u4e00\u7cfb\u5217\u64cd\u4f5c\uff0c\u8981\u4e48",Object(o.b)("strong",{parentName:"p"},"\u5b8c\u5168\u5730\u6267\u884c\uff0c\u8981\u4e48\u5b8c\u5168\u5730\u4e0d\u6267\u884c"),"\u3002"),Object(o.b)("p",null,"\u7b80\u5355\u7684\u8bf4\uff0c\u4e8b\u52a1\u5c31\u662f\u5e76\u53d1\u63a7\u5236\u7684\u5355\u4f4d\uff0c\u662f\u7528\u6237\u5b9a\u4e49\u7684\u4e00\u4e2a\u64cd\u4f5c\u5e8f\u5217\u3002 \u800c\u4e00\u4e2a\u903b\u8f91\u5de5\u4f5c\u5355\u5143\u8981\u6210\u4e3a\u4e8b\u52a1\uff0c\u5c31\u5fc5\u987b\u6ee1\u8db3 ",Object(o.b)("inlineCode",{parentName:"p"},"ACID")," \u5c5e\u6027\u3002"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"A"),"\uff1a\u539f\u5b50\u6027\uff08Atomicity\uff09\uff1a\u4e8b\u52a1\u4e2d\u7684\u64cd\u4f5c\u8981\u4e48\u90fd\u4e0d\u505a\uff0c\u8981\u4e48\u5c31\u5168\u505a"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"C"),"\uff1a\u4e00\u81f4\u6027\uff08Consistency\uff09\uff1a\u4e8b\u52a1\u6267\u884c\u7684\u7ed3\u679c\u5fc5\u987b\u662f\u4ece\u6570\u636e\u5e93\u4ece\u4e00\u4e2a\u4e00\u81f4\u6027\u72b6\u6001\u8f6c\u6362\u5230\u53e6\u4e00\u4e2a\u4e00\u81f4\u6027\u72b6\u6001"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"I"),"\uff1a\u9694\u79bb\u6027\uff08Isolation\uff09\uff1a\u4e00\u4e2a\u4e8b\u52a1\u7684\u6267\u884c\u4e0d\u80fd\u88ab\u5176\u4ed6\u4e8b\u52a1\u5e72\u6270"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"D"),"\uff1a\u6301\u4e45\u6027\uff08Durability\uff09\uff1a\u4e00\u4e2a\u4e8b\u52a1\u4e00\u65e6\u63d0\u4ea4\uff0c\u5b83\u5bf9\u6570\u636e\u5e93\u4e2d\u6570\u636e\u7684\u6539\u53d8\u5c31\u5e94\u8be5\u662f\u6c38\u4e45\u6027\u7684")),Object(o.b)("p",null,Object(o.b)("strong",{parentName:"p"},"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c",Object(o.b)("inlineCode",{parentName:"strong"},"Fur")," \u6846\u67b6\u4e3a\u6bcf\u4e00\u6b21\u8bf7\u6c42\u90fd\u5f00\u542f\u4e86\u5206\u5e03\u5f0f\u4e8b\u52a1\uff0c\u4fdd\u8bc1\u4e86\u6bcf\u4e00\u6b21\u8bf7\u6c42\u90fd\u662f\u4e00\u4e2a\u5b8c\u6574\u7684 ",Object(o.b)("inlineCode",{parentName:"strong"},"\u5de5\u4f5c\u5355\u5143")),"\u3002\u5f53\u7136\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u624b\u52a8\u7ba1\u7406\u4e8b\u52a1\u3002"),Object(o.b)("h2",{id:"9252-\u5de5\u4f5c\u5355\u5143"},"9.25.2 \u5de5\u4f5c\u5355\u5143"),Object(o.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u5c31\u662f\u4e3a\u4e86\u4fdd\u8bc1\u4e00\u6b21\u5b8c\u6574\u7684\u529f\u80fd\u64cd\u4f5c\u6240\u4ea7\u751f\u7684\u4e00\u4e9b\u5217\u63d0\u4ea4\u6570\u636e\u7684\u5b8c\u6574\u6027\uff0c\u8d77\u7740\u4e8b\u52a1\u7684\u4f5c\u7528\u3002\u5728\u8ba1\u7b97\u673a\u9886\u57df\u4e2d\uff0c\u5de5\u4f5c\u5355\u5143\u901a\u5e38\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"UnitOfWork")," \u540d\u79f0\u8868\u793a\u3002"),Object(o.b)("p",null,"\u901a\u5e38\u6211\u4eec\u4fdd\u8bc1\u7528\u6237\u7684\u6bcf\u4e00\u6b21\u8bf7\u6c42\u90fd\u662f\u5904\u4e8e\u5728\u4e00\u4e2a\u529f\u80fd\u5355\u5143\u4e2d\uff0c\u4e5f\u5c31\u662f\u5de5\u4f5c\u5355\u5143\u3002"),Object(o.b)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u5de5\u4f5c\u5355\u5143\u65e0\u9700\u6211\u4eec\u624b\u52a8\u7ef4\u62a4\uff0c\u6846\u67b6\u4f1a\u81ea\u52a8\u4fdd\u8bc1\u4e86\u6bcf\u4e00\u6b21\u8bf7\u6c42\u90fd\u662f\u4e00\u4e2a ",Object(o.b)("inlineCode",{parentName:"p"},"\u5de5\u4f5c\u5355\u5143"),"\uff0c\u8981\u4e48\u540c\u65f6\u6210\u529f\uff0c\u8981\u4e48\u540c\u65f6\u5931\u8d25\u3002"),Object(o.b)("h2",{id:"9253-\u5982\u4f55\u4f7f\u7528"},"9.25.3 \u5982\u4f55\u4f7f\u7528"),Object(o.b)("h3",{id:"92531-\u81ea\u52a8\u7ba1\u7406"},"9.25.3.1 \u81ea\u52a8\u7ba1\u7406"),Object(o.b)("p",null,"\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u5de5\u4f5c\u5355\u5143\u65e0\u9700\u6211\u4eec\u624b\u52a8\u7ef4\u62a4\uff0c\u6846\u67b6\u4f1a\u81ea\u52a8\u4fdd\u8bc1\u4e86\u6bcf\u4e00\u6b21\u8bf7\u6c42\u90fd\u662f\u4e00\u4e2a ",Object(o.b)("inlineCode",{parentName:"p"},"\u5de5\u4f5c\u5355\u5143"),"\uff0c\u8981\u4e48\u540c\u65f6\u6210\u529f\uff0c\u8981\u4e48\u540c\u65f6\u5931\u8d25\u3002\u6240\u4ee5\u65e0\u9700\u64cd\u4f5c\u3002"),Object(o.b)("h3",{id:"92532-\u624b\u52a8\u7ba1\u7406"},"9.25.3.2 \u624b\u52a8\u7ba1\u7406"),Object(o.b)(i.a,{defaultValue:"one",values:[{label:"\u793a\u4f8b\u4e00",value:"one"},{label:"\u793a\u4f8b\u4e8c",value:"two"},{label:"\u793a\u4f8b\u4e09",value:"three"}],mdxType:"Tabs"},Object(o.b)(c.a,{value:"one",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// \u5f00\u542f\u4e8b\u52a1\nusing (var transaction = _testRepository.Database.BeginTransaction())\n{\n try\n {\n _testRepository.Insert(new Blog { Url = "http://blogs.msdn.com/dotnet" });\n _testRepository.SaveChanges();\n\n _testRepository.Insert(new Blog { Url = "http://blogs.msdn.com/visualstudio" });\n _testRepository.SaveChanges();\n\n var blogs = _testRepository.Entity\n .OrderBy(b => b.Url)\n .ToList();\n\n // \u63d0\u4ea4\u4e8b\u52a1\n transaction.Commit();\n }\n catch (Exception)\n {\n // \u56de\u6eda\u4e8b\u52a1\n transaction.RollBack();\n }\n}\n'))),Object(o.b)(c.a,{value:"two",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'var options = new DbContextOptionsBuilder()\n .UseSqlServer(new SqlConnection(connectionString))\n .Options;\n\n// \u521b\u5efa\u8fde\u63a5\u5b57\u7b26\u4e32\nusing (var context1 = new HoaDbContext(options))\n{\n // \u5f00\u542f\u4e8b\u52a1\n using (var transaction = context1.Database.BeginTransaction())\n {\n try\n {\n _testRepository.Insert(new Blog { Url = "http://blogs.msdn.com/dotnet" });\n _testRepository.SaveChanges();\n\n context1.Blogs.Add(new Blog { Url = "http://blogs.msdn.com/dotnet" });\n context1.SaveChanges();\n\n // \u521b\u5efa\u65b0\u7684\u8fde\u63a5\u5bf9\u8c61\n using (var context2 = new HoaDbContext(options))\n {\n // \u5171\u4eab\u8fde\u63a5\u4e8b\u52a1\n context2.Database.UseTransaction(transaction.GetDbTransaction());\n\n var blogs = context2.Blogs\n .OrderBy(b => b.Url)\n .ToList();\n }\n\n // \u63d0\u4ea4\u4e8b\u52a1\n transaction.Commit();\n }\n catch (Exception)\n {\n // \u56de\u6eda\u4e8b\u52a1\n transaction.RollBack();\n }\n }\n}\n'))),Object(o.b)(c.a,{value:"three",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'// \u5f00\u542f\u5206\u5e03\u5f0f\u4e8b\u52a1\nusing (var scope = new TransactionScope(\n TransactionScopeOption.Required,\n new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }))\n{\n using (var connection = new SqlConnection(connectionString))\n {\n connection.Open();\n\n try\n {\n // \u8fd9\u91cc\u662f Ado.NET \u64cd\u4f5c\n var command = connection.CreateCommand();\n command.CommandText = "DELETE FROM dbo.Blogs";\n command.ExecuteNonQuery();\n\n // \u521b\u5efaEF Core \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\n var options = new DbContextOptionsBuilder()\n .UseSqlServer(connection)\n .Options;\n using (var context = new BloggingContext(options))\n {\n context.Blogs.Add(new Blog { Url = "http://blogs.msdn.com/dotnet" });\n context.SaveChanges();\n }\n\n // \u6846\u67b6\u5c01\u88c5\u7684\u4ed3\u50a8\n _testRepository.Insert(new Blog { Url = "http://blogs.msdn.com/dotnet" });\n _testRepository.SaveChanges();\n\n // \u63d0\u4ea4\u4e8b\u52a1\n scope.Complete();\n }\n catch (System.Exception)\n {\n // \u81ea\u52a8\u56de\u6eda\n }\n }\n}\n')))),Object(o.b)("h2",{id:"9254-\u5de5\u4f5c\u5355\u5143\u7279\u6027\u8bf4\u660e"},"9.25.4 \u5de5\u4f5c\u5355\u5143\u7279\u6027\u8bf4\u660e"),Object(o.b)("h3",{id:"92541-unitofwork"},"9.25.4.1 ",Object(o.b)("inlineCode",{parentName:"h3"},"[UnitOfWork]")),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"[UnitOfWork]")," \u7279\u6027\u7528\u6765\u6807\u8bb0\u4e8b\u52a1\u4fe1\u606f\uff0c\u5982\u4f5c\u7528\u8303\u56f4\uff0c\u9694\u79bb\u7ea7\u522b\u7b49\u3002"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"Enabled"),"\uff1a\u662f\u5426\u542f\u52a8\u5de5\u4f5c\u5355\u5143\uff0c\u9ed8\u8ba4 ",Object(o.b)("inlineCode",{parentName:"li"},"true")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"ScopeOption"),"\uff1a\u5b9a\u4e49\u4e8b\u52a1\u8303\u56f4\u884c\u4e3a\uff0c\u9ed8\u8ba4 ",Object(o.b)("inlineCode",{parentName:"li"},"TransactionScopeOption.Required")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IsolationLevel"),"\uff1a\u8bbe\u7f6e\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\uff0c\u9ed8\u8ba4 ",Object(o.b)("inlineCode",{parentName:"li"},"IsolationLevel.ReadCommitted"),";"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"AsyncFlowOption"),"\uff1a\u5141\u8bb8\u8de8\u7ebf\u7a0b\u8fde\u7eed\u4efb\u52a1\u7684\u4e8b\u52a1\u6d41\uff0c\u5982\u6709\u5f02\u6b65\u64cd\u4f5c\u9700\u5f00\u542f\u8be5\u9009\u9879\uff0c\u9ed8\u8ba4\u5f00\u542f")),Object(o.b)("div",{className:"admonition admonition-important alert alert--info"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u6ce8\u610f")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u4e00\u65e6\u65b9\u6cd5\u8d34\u4e86 ",Object(o.b)("inlineCode",{parentName:"p"},"[UnitOfWork(false)]")," \u7279\u6027\u540e\uff0c\u90a3\u4e48\u8be5\u65b9\u6cd5\u4e0d\u518d\u542f\u7528\u5de5\u4f5c\u5355\u5143\u6a21\u5f0f\uff0c\u4e5f\u5c31\u662f\u4e0d\u5305\u542b\u4e8b\u52a1\uff0c\u4e5f\u4e0d\u4f1a\u81ea\u52a8\u63d0\u4ea4\u6570\u636e\u5e93\u3002\u614e\u7528!"))),Object(o.b)("h3",{id:"92542-nontransact"},"9.25.4.2 ",Object(o.b)("inlineCode",{parentName:"h3"},"[NonTransact]")),Object(o.b)("p",null,"\u4e00\u4f46\u65b9\u6cd5\u6216\u7c7b\u8d34\u4e86 ",Object(o.b)("inlineCode",{parentName:"p"},"[NonTransact]")," \u7279\u6027\uff0c\u90a3\u4e48",Object(o.b)("strong",{parentName:"p"},"\u5c06\u5173\u95ed\u4e8b\u52a1\u64cd\u4f5c\uff0c\u4f46\u662f\u8fd8\u662f\u4f1a\u81ea\u52a8\u4fdd\u5b58\u6570\u636e\u5e93\u5230\u6570\u636e\u3002")),Object(o.b)("h2",{id:"9255-\u5e38\u89c1\u9519\u8bef"},"9.25.5 \u5e38\u89c1\u9519\u8bef"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"A TransactionScope must be disposed on the same thread that it was created."))),Object(o.b)("p",null,"\u53ea\u9700\u8981\u5728\u5f53\u524d\u64cd\u4f5c\u65b9\u6cd5\u4e0a\u8d34 ",Object(o.b)("inlineCode",{parentName:"p"},"[NonTransact]")," \u7279\u6027\u5373\u53ef\u3002"),Object(o.b)("h2",{id:"9256-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.25.6 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))),Object(o.b)("hr",null),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(o.b)("inlineCode",{parentName:"p"},"\u4e8b\u52a1")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/ef/core/saving/transactions"}),"EF Core - \u4f7f\u7528\u4e8b\u52a1")," \u7ae0\u8282\u3002"))))}d.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return u})),t.d(n,"b",(function(){return m}));var a=t(0),r=t.n(a);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function c(e){for(var n=1;n=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var s=r.a.createContext({}),b=function(e){var n=r.a.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},u=function(e){var n=b(e.components);return r.a.createElement(s.Provider,{value:n},e.children)},d={inlineCode:"code",wrapper:function(e){var n=e.children;return r.a.createElement(r.a.Fragment,{},n)}},p=r.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,o=e.originalType,i=e.parentName,s=l(e,["components","mdxType","originalType","parentName"]),u=b(t),p=a,m=u["".concat(i,".").concat(p)]||u[p]||d[p]||o;return t?r.a.createElement(m,c(c({ref:n},s),{},{components:t})):r.a.createElement(m,c({ref:n},s))}));function m(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var o=t.length,i=new Array(o);i[0]=p;var c={};for(var l in n)hasOwnProperty.call(n,l)&&(c[l]=n[l]);c.originalType=e,c.mdxType="string"==typeof e?e:a,i[1]=c;for(var s=2;s -29.1 常见问题 | Fur - - - - - - - - - - - +29.1 常见问题 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/appstartup/index.html b/handbook/build/docs/appstartup/index.html index 5f3d6bdfdc3..0b608014ba2 100644 --- a/handbook/build/docs/appstartup/index.html +++ b/handbook/build/docs/appstartup/index.html @@ -4,22 +4,22 @@ -3. 应用启动 | Fur - - - - - - - - - - - +3. 应用启动 | Fur + + + + + + + + + + +
-

3. 应用启动

3.1 Startup

Startup 类是 ASP.NET Core 应用程序启动默认调用的类,该类是在 Program.cs 中配置:

Fur.Web.Entry\Program.cs
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
+

3. 应用启动

3.1 Startup

Startup 类是 ASP.NET Core 应用程序启动默认调用的类,该类是在 Program.cs 中配置:

Fur.Web.Entry\Program.cs
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace Fur.Web.Entry
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.Inject()
.UseStartup<Startup>();
});
}
}
}

3.1.1 Startup 两个重要方法

Startup 默认有两个重要的方法:

  • ConfigureServices:配置应用所需服务,在该方法中可以添加应用所需要的功能或服务
  • Configure:配置应用请求处理管道

默认代码如下:

Fur.Web.Entry\Startup.cs
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace Fur.Web.Entry
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
}
@@ -46,17 +46,17 @@
namespace Fur.Web.Entry
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.Inject()
.UseStartup<Startup>();
});
}
}
}
Fur.Web.Entry\Startup.cs
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace Fur.Web.Entry
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
}
-
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
}
}
}
Startup.cs 代码迁移

只需要将 ConfigureServicesConfigure 方法代码迁移到 FurWebCoreStartup.cs 中即可,而 Startup.cs 中两个方法留空即可。

非常简单吧。我们后续创建任何 MVCRazorPagesBlazor 项目只需要添加 Fur.Web.Core 引用和调用 Inject() 即可。

3.7 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
}
}
}
Startup.cs 代码迁移

只需要将 ConfigureServicesConfigure 方法代码迁移到 FurWebCoreStartup.cs 中即可,而 Startup.cs 中两个方法留空即可。

非常简单吧。我们后续创建任何 MVCRazorPagesBlazor 项目只需要添加 Fur.Web.Core 引用和调用 Inject() 即可。

3.7 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/auth-control/index.html b/handbook/build/docs/auth-control/index.html index 6060178485b..33cec1868d3 100644 --- a/handbook/build/docs/auth-control/index.html +++ b/handbook/build/docs/auth-control/index.html @@ -4,32 +4,32 @@ -14. 安全鉴权 | Fur - - - - - - - - - - - +14. 安全鉴权 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/author/index.html b/handbook/build/docs/author/index.html index 8f9e0f290f1..d9e237af7c5 100644 --- a/handbook/build/docs/author/index.html +++ b/handbook/build/docs/author/index.html @@ -4,32 +4,32 @@ -1.2 关于作者 | Fur - - - - - - - - - - - +1.2 关于作者 | Fur + + + + + + + + + + +
-

1.2 关于作者

互联网账号

  • 百小僧
  • Monk/MonkSoul

技术能力

自 2008 年 接触 IT 这个行业也有十余年了,在 后端(.NET/.NET Core/Java/PHP)、移动端(Xamarin/小程序/Java/Objective-C)、桌面端(WinForm/WPF/Electron)、前端(React/Vue/Angular/Node)等主流领域略知一二。

同时在技术培训领域也多有涉足。

职业情况

目前经营一家自己创办的软件科技公司,主要销售自主研发的 ERP 产品。

吃不起饭的时候也会接外包项目。

兴趣爱好

是个吃货,喜欢看抖音,看动漫,看美剧,看博客园、看开源中国。

对新技术颇感兴趣,喜欢开源事业,喜欢分享技术。

个人主页

https://gitee.com/monksoul

https://github.com/monksoul

- - - - - - - - - - - +

1.2 关于作者

互联网账号

  • 百小僧
  • Monk/MonkSoul

技术能力

自 2008 年 接触 IT 这个行业也有十余年了,在 后端(.NET/.NET Core/Java/PHP)、移动端(Xamarin/小程序/Java/Objective-C)、桌面端(WinForm/WPF/Electron)、前端(React/Vue/Angular/Node)等主流领域略知一二。

同时在技术培训领域也多有涉足。

职业情况

目前经营一家自己创办的软件科技公司,主要销售自主研发的 ERP 产品。

吃不起饭的时候也会接外包项目。

兴趣爱好

是个吃货,喜欢看抖音,看动漫,看美剧,看博客园、看开源中国。

对新技术颇感兴趣,喜欢开源事业,喜欢分享技术。

个人主页

https://gitee.com/monksoul

https://github.com/monksoul

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/cache/index.html b/handbook/build/docs/cache/index.html index 9c70402c87f..20e684204b4 100644 --- a/handbook/build/docs/cache/index.html +++ b/handbook/build/docs/cache/index.html @@ -4,32 +4,32 @@ -13. 分布式缓存 | Fur - - - - - - - - - - - +13. 分布式缓存 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/configuration/index.html b/handbook/build/docs/configuration/index.html index ce432912f15..1c56f1021cc 100644 --- a/handbook/build/docs/configuration/index.html +++ b/handbook/build/docs/configuration/index.html @@ -4,33 +4,33 @@ -4.1 配置 | Fur - - - - - - - - - - - +4.1 配置 | Fur + + + + + + + + + + +
-

4.1 配置

温馨提示

推荐使用 《4.2 选项》代替本章节功能。(为什么)?

4.1.1 什么是配置

简单来说,配置将系统应用可动态调配的选项放在统一地方管理,通过不同的配置让系统做出动态调整。

ASP.NET Core 应用程序启动时默认加载 启动项目 下的 appsettings.json 作为应用配置。同时还支持不同的运行环境加载对应的配置文件,如:

  • Development:加载 appsettings.Development.json
  • Staging:加载 appsettings.Staging.json
  • {Environment}appsettings.{Environment}.json

4.1.2 配置的使用

假设我们需要在系统运行时获取系统名称、版本号及版权信息,这些信息可能随时变化而且需要在多个地方使用。这时就需要将这些信息配置起来。具体步骤如下:

4.1.2.1 配置 appsettings.json 信息

{
"AppInfo": {
"Name": "Fur",
"Version": "1.0.0",
"Company": "Baiqian"
}
}

4.1.2.2 读取 appsettings.json 信息

Fur 框架中,提供了两种读取方式:

  • 依赖注入 IConfiguration 对象读取
  • 通过 App.Configuration[jsonKey] 读取
using Microsoft.AspNetCore.Mvc;
-
namespace Fur.Web.Entry.Controllers
{
[Route("api/[controller]")]
public class DefaultController : ControllerBase
{
[HttpGet]
public string Get()
{
return $@"名称:{App.Configuration["AppInfo:Name"]},
版本:{App.Configuration["AppInfo:Version"]},
公司:{App.Configuration["AppInfo:Company"]}";
}
}
}
依赖注入的方式

通过依赖注入注入实例有几种方式:

  • 构造函数注入方式
private readonly IConfiguration _configuration;
public DefaultController(IConfiguration configuration)
{
_configuration = configuration;
}
  • 参数注入方式 [FromServices]
public string Get([FromServices] IConfiguration configuration)
{
}
  • 属性注入方式
public IConfiguration Configuration { get; set; }

想了解更多关于《ASP.NET Core - 依赖注入》 知识

4.1.2.3 如何选择读取方式

  • 在可依赖注入类中,依赖注入 IConfiguration 读取
  • 在静态类/非依赖注入类中,选择 App.Configuration[jsonKey] 读取

4.1.3 路径符 查找节点

ASP.NET Core 中,配置采用 : 分隔符来读取分层配置数据。如上述例子中的 AppInfo:Name。如有更多层级数据则只需要通过 : 进入下一层节点即可。

假设我们有以下配置信息:

{
"AppInfo": {
"Name": "Fur",
"Version": "1.0.0",
"Company": {
"Name": "Baiqian",
"Address": {
"City": "中国",
"Province": "广东省",
"Detail": "中山市东区紫马公园西门"
}
}
}
}
var companyName = App.Configuration["AppInfo:Name"]; // => Fur

4.1.4 自定义配置文件

大多情况下,我们的配置只需要在 appsettings.json 中配置即可,但一些特殊情况下,我们希望某些组件或功能拥有独立的配置,这个时候就需要用到自定义配置,Fur 目前支持 .json.xml 两种方式配置,如:

Fur.Web.Entry/emailsetting.json
{
"outlook": {
"smtp": {
"server": "smtp.office365.com",
"port": "587",
"ssl": "STARTTLS"
},
"pop": {
"server": "outlook.office365.com",
"port": "995",
"ssl": "TLS"
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<MyKey>MyXMLFile Value</MyKey>
<Position>
<Title>Title from MyXMLFile</Title>
<Name>Name from MyXMLFile</Name>
</Position>
<Logging>
<LogLevel>
<Default>Information</Default>
<Microsoft>Warning</Microsoft>
</LogLevel>
</Logging>
</configuration>
xml 配置事项

如果采用 xml 配置,那么文件名必须以 .config.xml 结尾(不区分大小写)。

同时 Fur 提供了非常灵活的方式支持自定义配置文件读取,如:

4.1.4.1 读取 emailsetting.json 配置

读取自定义配置文件和读取 appsettings.json 一致,系统会自动从多个配置文件中读取输入,如:

var smtpServer = App.Configuration["outlook:smtp:server"]; // => smtp.office365.com
特别说明

Fur 框架会在启动时自动扫描每一个项目层根目录下的 *.json*.xml 文件加入配置中。所以无需手工配置。

4.1.5 不同环境读取

在实际应用开发中,我们可能会根据不同的环境加载不同的配置文件,如 数据库连接字符串

这时我们只需要遵循特定命名规范 {name}.{Environment}.json 即可。如:

  • appsettings.Development.json
  • appsettings.Staging.json
  • appsettings.Production.json
  • emailsetting.Development.json
  • emailsetting.Staging.json
  • emailsetting.Production.json

这时,ASP.NET Core 会在应用启动时自动加载不同环境的配置文件。

4.1.6 配置更改通知(热更新

.NET Core 应用程序中,配置支持更改通知,也就是热更新操作。一旦监听到 appsetting.json 或自定义配置文件发生变动,就会触发 OnChange 方法。代码如下:

var appInfoConfiguration = App.Configuration["AppInfo"];
ChangeToken.OnChange(() => appInfoConfiguration.GetReloadToken(), () =>
{
var name = appInfoConfiguration["Name"]; // 实时的最新值
var version = appInfoConfiguration["Version"]; // 实时的最新值
});

4.1.7 配置的优缺点

  • 优点

    • 能够在系统运行时快速读取
    • 无需额外配置
  • 缺点

    • 存在重复读取
    • 通过硬编码字符串读取,容易出错
    • 不能设置默认值
    • 不能在运行环境中动态配置
    • 不能验证配置有效性
    • 不支持更改通知

4.1.8 配置使用场景

如果只需要一次性读取配置信息,则使用配置,否则应该使用 《4.2 选项》代替。

4.1.9 反馈与建议

与我们交流

给 Fur 提 Issue


了解更多

想了解更多 配置 知识可查阅 ASP.NET Core - 配置 章节。

- - - - - - - - - - - +

4.1 配置

温馨提示

推荐使用 《4.2 选项》代替本章节功能。(为什么)?

4.1.1 什么是配置

简单来说,配置将系统应用可动态调配的选项放在统一地方管理,通过不同的配置让系统做出动态调整。

ASP.NET Core 应用程序启动时默认加载 启动项目 下的 appsettings.json 作为应用配置。同时还支持不同的运行环境加载对应的配置文件,如:

  • Development:加载 appsettings.Development.json
  • Staging:加载 appsettings.Staging.json
  • {Environment}appsettings.{Environment}.json

4.1.2 配置的使用

假设我们需要在系统运行时获取系统名称、版本号及版权信息,这些信息可能随时变化而且需要在多个地方使用。这时就需要将这些信息配置起来。具体步骤如下:

4.1.2.1 配置 appsettings.json 信息

{
"AppInfo": {
"Name": "Fur",
"Version": "1.0.0",
"Company": "Baiqian"
}
}

4.1.2.2 读取 appsettings.json 信息

Fur 框架中,提供了两种读取方式:

  • 依赖注入 IConfiguration 对象读取
  • 通过 App.Configuration[jsonKey] 读取
using Microsoft.AspNetCore.Mvc;
+
namespace Fur.Web.Entry.Controllers
{
[Route("api/[controller]")]
public class DefaultController : ControllerBase
{
[HttpGet]
public string Get()
{
return $@"名称:{App.Configuration["AppInfo:Name"]},
版本:{App.Configuration["AppInfo:Version"]},
公司:{App.Configuration["AppInfo:Company"]}";
}
}
}
依赖注入的方式

通过依赖注入注入实例有几种方式:

  • 构造函数注入方式
private readonly IConfiguration _configuration;
public DefaultController(IConfiguration configuration)
{
_configuration = configuration;
}
  • 参数注入方式 [FromServices]
public string Get([FromServices] IConfiguration configuration)
{
}
  • 属性注入方式
public IConfiguration Configuration { get; set; }

想了解更多关于《ASP.NET Core - 依赖注入》 知识

4.1.2.3 如何选择读取方式

  • 在可依赖注入类中,依赖注入 IConfiguration 读取
  • 在静态类/非依赖注入类中,选择 App.Configuration[jsonKey] 读取

4.1.3 路径符 查找节点

ASP.NET Core 中,配置采用 : 分隔符来读取分层配置数据。如上述例子中的 AppInfo:Name。如有更多层级数据则只需要通过 : 进入下一层节点即可。

假设我们有以下配置信息:

{
"AppInfo": {
"Name": "Fur",
"Version": "1.0.0",
"Company": {
"Name": "Baiqian",
"Address": {
"City": "中国",
"Province": "广东省",
"Detail": "中山市东区紫马公园西门"
}
}
}
}
var companyName = App.Configuration["AppInfo:Name"]; // => Fur

4.1.4 自定义配置文件

大多情况下,我们的配置只需要在 appsettings.json 中配置即可,但一些特殊情况下,我们希望某些组件或功能拥有独立的配置,这个时候就需要用到自定义配置,Fur 目前支持 .json.xml 两种方式配置,如:

Fur.Web.Entry/emailsetting.json
{
"outlook": {
"smtp": {
"server": "smtp.office365.com",
"port": "587",
"ssl": "STARTTLS"
},
"pop": {
"server": "outlook.office365.com",
"port": "995",
"ssl": "TLS"
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<MyKey>MyXMLFile Value</MyKey>
<Position>
<Title>Title from MyXMLFile</Title>
<Name>Name from MyXMLFile</Name>
</Position>
<Logging>
<LogLevel>
<Default>Information</Default>
<Microsoft>Warning</Microsoft>
</LogLevel>
</Logging>
</configuration>
xml 配置事项

如果采用 xml 配置,那么文件名必须以 .config.xml 结尾(不区分大小写)。

同时 Fur 提供了非常灵活的方式支持自定义配置文件读取,如:

4.1.4.1 读取 emailsetting.json 配置

读取自定义配置文件和读取 appsettings.json 一致,系统会自动从多个配置文件中读取输入,如:

var smtpServer = App.Configuration["outlook:smtp:server"]; // => smtp.office365.com
特别说明

Fur 框架会在启动时自动扫描每一个项目层根目录下的 *.json*.xml 文件加入配置中。所以无需手工配置。

4.1.5 不同环境读取

在实际应用开发中,我们可能会根据不同的环境加载不同的配置文件,如 数据库连接字符串

这时我们只需要遵循特定命名规范 {name}.{Environment}.json 即可。如:

  • appsettings.Development.json
  • appsettings.Staging.json
  • appsettings.Production.json
  • emailsetting.Development.json
  • emailsetting.Staging.json
  • emailsetting.Production.json

这时,ASP.NET Core 会在应用启动时自动加载不同环境的配置文件。

4.1.6 配置更改通知(热更新

.NET Core 应用程序中,配置支持更改通知,也就是热更新操作。一旦监听到 appsetting.json 或自定义配置文件发生变动,就会触发 OnChange 方法。代码如下:

var appInfoConfiguration = App.Configuration["AppInfo"];
ChangeToken.OnChange(() => appInfoConfiguration.GetReloadToken(), () =>
{
var name = appInfoConfiguration["Name"]; // 实时的最新值
var version = appInfoConfiguration["Version"]; // 实时的最新值
});

4.1.7 配置的优缺点

  • 优点

    • 能够在系统运行时快速读取
    • 无需额外配置
  • 缺点

    • 存在重复读取
    • 通过硬编码字符串读取,容易出错
    • 不能设置默认值
    • 不能在运行环境中动态配置
    • 不能验证配置有效性
    • 不支持更改通知

4.1.8 配置使用场景

如果只需要一次性读取配置信息,则使用配置,否则应该使用 《4.2 选项》代替。

4.1.9 反馈与建议

与我们交流

给 Fur 提 Issue


了解更多

想了解更多 配置 知识可查阅 ASP.NET Core - 配置 章节。

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/contribute/index.html b/handbook/build/docs/contribute/index.html index f9a4670364f..ee664ec20e6 100644 --- a/handbook/build/docs/contribute/index.html +++ b/handbook/build/docs/contribute/index.html @@ -4,32 +4,32 @@ -28. 贡献指南 | Fur - - - - - - - - - - - +28. 贡献指南 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/cors/index.html b/handbook/build/docs/cors/index.html index dfced11f485..a5a598e242f 100644 --- a/handbook/build/docs/cors/index.html +++ b/handbook/build/docs/cors/index.html @@ -4,32 +4,32 @@ -15. CORS 跨域 | Fur - - - - - - - - - - - +15. CORS 跨域 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/data-validation/index.html b/handbook/build/docs/data-validation/index.html index 62b524d149c..320f97dbf57 100644 --- a/handbook/build/docs/data-validation/index.html +++ b/handbook/build/docs/data-validation/index.html @@ -4,22 +4,22 @@ -8. 数据校验 | Fur - - - - - - - - - - - +8. 数据校验 | Fur + + + + + + + + + + +
-

8. 数据校验

8.1 关于数据校验

数据校验字面上的意思就是对使用者提交过来的数据进行合法性验证。在一套完善的应用系统中,数据有效性校验是必不可少的业务处理第一道关卡。

8.2 数据校验的好处

  • 过滤不安全数据,提高系统的安全性
  • 减少不必要的业务异常处理,提高系统的响应速度
  • 大大提高系统稳定性
  • 大数据并发时起着一定的缓冲作用

8.3 数据校验方式

  • 传统方式,在业务代码之前手动验证
  • Mvc 特性方式,Mvc 内置的 DataAnnotations 方式
  • 推荐方式Fur 框架内置的 DataValidation 验证
  • 其他方式,使用第三方验证库,如 FluentValidation

8.3.1 传统方式

在很多老项目中,我们经常看到这样的代码:

public bool Insert(Person person)
{
// 验证参数
if(string.IsNullOrEmty(person.Name))
{
throw new System.Exception("名字不能为空");
}
+

8. 数据校验

8.1 关于数据校验

数据校验字面上的意思就是对使用者提交过来的数据进行合法性验证。在一套完善的应用系统中,数据有效性校验是必不可少的业务处理第一道关卡。

8.2 数据校验的好处

  • 过滤不安全数据,提高系统的安全性
  • 减少不必要的业务异常处理,提高系统的响应速度
  • 大大提高系统稳定性
  • 大数据并发时起着一定的缓冲作用

8.3 数据校验方式

  • 传统方式,在业务代码之前手动验证
  • Mvc 特性方式,Mvc 内置的 DataAnnotations 方式
  • 推荐方式Fur 框架内置的 DataValidation 验证
  • 其他方式,使用第三方验证库,如 FluentValidation

8.3.1 传统方式

在很多老项目中,我们经常看到这样的代码:

public bool Insert(Person person)
{
// 验证参数
if(string.IsNullOrEmty(person.Name))
{
throw new System.Exception("名字不能为空");
}
if(person.Age < 18)
{
throw new System.Exception("年龄不能小于 18 岁");
}
if(!person.Password.Equals(person.ConfirmPassword)
{
throw new System.Exception("两次密码不一致");
}
// 业务代码
_repository.Insert(person.Adapt<PersonEntity>());
@@ -38,11 +38,11 @@
// 你的验证逻辑
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (你的逻辑代码)
{
yield return new ValidationResult(
"错误消息"
,new[] { nameof(Title) } // 验证失败的属性
);
}
}
}

Mvc 特性方式极大的将业务逻辑和验证进行了剥离和解耦,而且还能实现自定义复杂验证。

但是 Mvc 特性验证方式有几个明显的缺点

  • 只能在 控制器 中的 Action(动作方法)中使用
  • 无法在任意类、任意方法中使用
  • 内置的验证类型非常有限,且不易拓展
  • 不支持验证消息后期配置

所以,Fur 提供了新的验证引擎 DataValidation,在完全兼容 Mvc 内置验证的同时提供了大量常见验证、复杂验证、自定义验证等能力。

8.4 DataValidation 验证 🤗

DataValidationFur 框架提供了全新的验证方式,完全兼容 Mvc 内置验证,并且赋予了超能。

8.4.1 DataValidation 优点

  • 完全兼容 Mvc 内置验证引擎
  • 内置常见验证类型及可自定义验证类型功能
  • 提供全局对象拓展验证方式
  • 支持验证消息后期配置,支持实时更新
  • 支持在任何类,任何方法、任何位置实现手动验证、特性方式验证等
  • 支持设置验证结果模型

8.5 DataValidation 使用

8.5.1 注册验证服务

Fur.Web.Core\FurWebCoreStartup.cs
using Microsoft.Extensions.DependencyInjection;
namespace Fur.Web.Core
{
[AppStartup(800)]
public sealed class FurWebCoreStartup : AppStartup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers()
.AddDataValidation();
}
}
}
特别注意

.AddDataValidation() 需在 services.AddControllers() 之后注册。

8.5.2 兼容 Mvc 特性验证

using System.ComponentModel.DataAnnotations;
namespace Fur.Application
{
public class TestDto
{
[Range(10, 20, ErrorMessage = "Id 只能在 10-20 区间取值")]
public int Id { get; set; }
-
[Required(ErrorMessage = "必填"), MinLength(3, ErrorMessage = "字符串长度不能少于3位")]
public string Name { get; set; }
}
}

如下图所示:

8.5.3 兼容 Mvc 复杂验证

using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+
[Required(ErrorMessage = "必填"), MinLength(3, ErrorMessage = "字符串长度不能少于3位")]
public string Name { get; set; }
}
}

如下图所示:

8.5.3 兼容 Mvc 复杂验证

using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Fur.Application
{
public class TestDto : IValidatableObject
{
[Range(10, 20, ErrorMessage = "Id 只能在 10-20 区间取值")]
public int Id { get; set; }
[Required(ErrorMessage = "必填"), MinLength(3, ErrorMessage = "字符串长度不能少于3位")]
public string Name { get; set; }
-
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (Name.StartsWith("Fur"))
{
yield return new ValidationResult(
"不能以 Fur 开头"
, new[] { nameof(Name) }
);
}
}
}
}

如下图所示:

8.6 手动验证

8.7.1 验证模型

using Fur.DataValidation;
using Fur.DynamicApiController;
-
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
[NonValidation] // 跳过全局验证
public DataValidationResult Post(TestDto testDto)
{
return testDto.TryValidate();
}
}
}

如下图所示:

note

支持 Mvc 内置的特性验证、属性验证及复杂的 IValidatableObject 验证。

8.7.2 ValidationTypes 常见验证

Fur 内置了很多常用类型的数据验证,包括:

  • Required:非空、非 Null 类型
  • Numeric:数值类型
  • PositiveNumber:正数类型
  • NegativeNumber:负数类型
  • Integer:整数类型
  • Money:金钱类型
  • Date:日期类型
  • Time:时间类型
  • IDCard:身份证类型
  • PostCode:邮编类型
  • PhoneNumber:手机号类型
  • Telephone:固话类型
  • PhoneOrTelNumber:手机或固话类型
  • EmailAddress:邮件地址类型
  • Url:网址类型
  • Color:颜色值类型
  • Chinese:中文类型
  • IPv4:IPv4 地址类型
  • IPv6:IPv6 地址类型
  • Age:年龄类型
  • ChineseName:中文名类型
  • EnglishName:英文名类型
  • Capital:纯大写英文类型
  • Lowercase:纯小写英文类型
  • Ascii:Ascii 类型
  • Md5:Md5 字符串类型
  • Zip:压缩包格式类型
  • Image:图片格式类型
  • Document:文档格式类型
  • MP3:Mp3 格式类型
  • Flash:Flash 格式类型
  • Video:视频文件格式类型

使用示例

// 验证必填
"".TryValidate(ValidationTypes.Required); // => false
+
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (Name.StartsWith("Fur"))
{
yield return new ValidationResult(
"不能以 Fur 开头"
, new[] { nameof(Name) }
);
}
}
}
}

如下图所示:

8.6 手动验证

8.7.1 验证模型

using Fur.DataValidation;
using Fur.DynamicApiController;
+
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
[NonValidation] // 跳过全局验证
public DataValidationResult Post(TestDto testDto)
{
return testDto.TryValidate();
}
}
}

如下图所示:

note

支持 Mvc 内置的特性验证、属性验证及复杂的 IValidatableObject 验证。

8.7.2 ValidationTypes 常见验证

Fur 内置了很多常用类型的数据验证,包括:

  • Required:非空、非 Null 类型
  • Numeric:数值类型
  • PositiveNumber:正数类型
  • NegativeNumber:负数类型
  • Integer:整数类型
  • Money:金钱类型
  • Date:日期类型
  • Time:时间类型
  • IDCard:身份证类型
  • PostCode:邮编类型
  • PhoneNumber:手机号类型
  • Telephone:固话类型
  • PhoneOrTelNumber:手机或固话类型
  • EmailAddress:邮件地址类型
  • Url:网址类型
  • Color:颜色值类型
  • Chinese:中文类型
  • IPv4:IPv4 地址类型
  • IPv6:IPv6 地址类型
  • Age:年龄类型
  • ChineseName:中文名类型
  • EnglishName:英文名类型
  • Capital:纯大写英文类型
  • Lowercase:纯小写英文类型
  • Ascii:Ascii 类型
  • Md5:Md5 字符串类型
  • Zip:压缩包格式类型
  • Image:图片格式类型
  • Document:文档格式类型
  • MP3:Mp3 格式类型
  • Flash:Flash 格式类型
  • Video:视频文件格式类型

使用示例

// 验证必填
"".TryValidate(ValidationTypes.Required); // => false
// 验证中文
"我叫 MonK".TryValidate(ValidationTypes.Chinese); // => false
// 验证数值
2.TryValidate(ValidationTypes.Numeric); // => true
// 验证整数
true.TryValidate(ValidationTypes.Integer); // => false
@@ -64,20 +64,20 @@
// 修改自定义类型验证失败消息
[ValidationMessage("密码太简单了")]
StrongPassword,
[ValidationMessage("必须以 Fur 开头")]
StartWithFurString
}
}
小知识

除了贴 [ValidationMessageType] 特性外,Fur 框架还提供了 IValidationMessageTypeProvider 方式查找验证消息类型,如下图所示:

using Fur.DataValidation;
using System;
namespace Fur.Application
{
public class MyValidationTypeMessageProvider : IValidationMessageTypeProvider
{
public Type[] Definitions => new[]
{
typeof(MyValidationMessageType),
typeof(MyValidationMessageType2)
};
}
}

注册验证消息提供器

Fur.Web.Core\FurWebCoreStartup.cs
using Microsoft.Extensions.DependencyInjection;
-
namespace Fur.Web.Core
{
[AppStartup(800)]
public sealed class FurWebCoreStartup : AppStartup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers()
.AddDataValidation<MyValidationTypeMessageProvider>();
}
}
}

如下图所示:

  • appsettings.json 方式
Fur.Web.Entry/appsettings.json
{
"AppSettings": {
"ValidationTypeMessageSettings": {
"Definitions": [
["Required", "值不能为空或Null"],
["Numeric", "必须是数值类型"],
+
namespace Fur.Web.Core
{
[AppStartup(800)]
public sealed class FurWebCoreStartup : AppStartup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers()
.AddDataValidation<MyValidationTypeMessageProvider>();
}
}
}

如下图所示:

  • appsettings.json 方式
Fur.Web.Entry/appsettings.json
{
"AppSettings": {
"ValidationTypeMessageSettings": {
"Definitions": [
["Required", "值不能为空或Null"],
["Numeric", "必须是数值类型"],
["StrongPassword", "密码太简单了!!!"]
]
}
}
}
important

appsettings.json 中相同的 Key 或覆盖 IValidationMessageTypeProvider 提供相同 Key 的值。

错误消息查找优先级

DefaultErrorMessage -> IValidationMessageTypeProvider -> appsettings.json (低 -> 高)

8.9 模型验证范围

Fur 提供多种模型验证范围设置:

  • 全局验证(默认)
  • [NonValidation] 跳过验证
  • [TypeFilter(typeof(DataValidationFilter))] 局部验证
  • [ApiController] 控制器范围验证

8.9.1 全局验证

默认情况下,通过 .AddDataValidation() 注册数据验证服务已经启用了全局验证,如若不想启用全局验证,则传入 false 即可,如:.AddDataValidation(false)

8.9.2 [NonValidation] 跳过验证

可通过 [NonValidation] 贴在 控制器动作方法 中跳过全局验证或不需要验证

8.9.3 [TypeFilter(typeof(DataValidationFilter))] 局部验证

我们也可以无需注册 .AddDataValidation() 服务,直接在 动作方法 上贴 [TypeFilter(typeof(DataValidationFilter))] 可启用局部验证。如:

using Fur.DataValidation;
using Fur.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
[TypeFilter(typeof(DataValidationFilter))]
public TestDto Post(TestDto testDto)
{
return testDto;
}
}
}

8.9.4 [ApiController] 控制器范围验证

[ApiController]Mvc 提供的控制器范围(含所有动作方法)的验证。

using Microsoft.AspNetCore.Mvc;
-
namespace Fur.Web.Entry.Controllers
{
[ApiController]
public class MvcController : Controller
{
public IActionResult Index()
{
return View();
}
}
}

8.10 MiniProfiler 查看

如下图所示:

8.10 多语言支持

文档整理中...

8.11 验证模型提供器

文档整理中...

8.12 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
namespace Fur.Web.Entry.Controllers
{
[ApiController]
public class MvcController : Controller
{
public IActionResult Index()
{
return View();
}
}
}

8.10 MiniProfiler 查看

如下图所示:

8.10 多语言支持

文档整理中...

8.11 验证模型提供器

文档整理中...

8.12 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-Interceptor/index.html b/handbook/build/docs/dbcontext-Interceptor/index.html index 0566f697948..8212e822bfc 100644 --- a/handbook/build/docs/dbcontext-Interceptor/index.html +++ b/handbook/build/docs/dbcontext-Interceptor/index.html @@ -4,22 +4,22 @@ -9.24 数据库操作拦截器 | Fur - - - - - - - - - - - +9.24 数据库操作拦截器 | Fur + + + + + + + + + + +
-

9.24 数据库操作拦截器

9.24.1 数据库拦截器

Fur 框架提供四种数据库操作拦截器,可以通过拦截器动态修该数据库连接字符串,动态修改sql,动态更改参数等操作。

Fur 支持这四种拦截器:

  • DbConnectionInterceptor:数据库连接拦截器
  • DbCommandInterceptor:数据库执行 Sql 拦截器
  • SaveChangesInterceptor:提交到数据库拦截器
  • 在数据库上下文中重写 SavedChangesEvent 相关事件

9.24.2 支持拦截类型

9.24.2.1 DbConnectionInterceptor

using Microsoft.EntityFrameworkCore.Diagnostics;
using System.Data.Common;
using System.Threading;
using System.Threading.Tasks;
+

9.24 数据库操作拦截器

9.24.1 数据库拦截器

Fur 框架提供四种数据库操作拦截器,可以通过拦截器动态修该数据库连接字符串,动态修改sql,动态更改参数等操作。

Fur 支持这四种拦截器:

  • DbConnectionInterceptor:数据库连接拦截器
  • DbCommandInterceptor:数据库执行 Sql 拦截器
  • SaveChangesInterceptor:提交到数据库拦截器
  • 在数据库上下文中重写 SavedChangesEvent 相关事件

9.24.2 支持拦截类型

9.24.2.1 DbConnectionInterceptor

using Microsoft.EntityFrameworkCore.Diagnostics;
using System.Data.Common;
using System.Threading;
using System.Threading.Tasks;
namespace Fur.DatabaseAccessor.Interceptors
{
public class SqlConnectionInterceptor : DbConnectionInterceptor
{
// 数据库连接之前
public override InterceptionResult ConnectionOpening(DbConnection connection, ConnectionEventData eventData, InterceptionResult result)
{
return base.ConnectionOpening(connection, eventData, result);
}
// 数据库连接之前(异步)
public override ValueTask<InterceptionResult> ConnectionOpeningAsync(DbConnection connection, ConnectionEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default)
{
return base.ConnectionOpeningAsync(connection, eventData, result, cancellationToken);
}
// 数据库连接成功
public override void ConnectionOpened(DbConnection connection, ConnectionEndEventData eventData)
{
base.ConnectionOpened(connection, eventData);
}
@@ -52,17 +52,17 @@
// 提交到数据库之后
public override int SavedChanges(SaveChangesCompletedEventData eventData, int result)
{
return base.SavedChanges(eventData, result);
}
// 提交到数据库之后(异步)
public override ValueTask<int> SavedChangesAsync(SaveChangesCompletedEventData eventData, int result, CancellationToken cancellationToken = default)
{
return base.SavedChangesAsync(eventData, result, cancellationToken);
}
// 提交数据库失败
public override void SaveChangesFailed(DbContextErrorEventData eventData)
{
base.SaveChangesFailed(eventData);
}
-
// 提交数据库失败(异步)
public override Task SaveChangesFailedAsync(DbContextErrorEventData eventData, CancellationToken cancellationToken = default)
{
return base.SaveChangesFailedAsync(eventData, cancellationToken);
}
}
}

9.24.2.4 SavedChangesEvent 拦截

Fur 框架中为所有 AppDbContext 子类都提供了三个可重写的方法,这三个方法分别由三个事件触发:

  • 提交更改之前 SavingChanges 事件:触发 void SavingChangesEvent(object sender, SavingChangesEventArgs e) 方法
  • 提交更改之后 SavedChanges 事件:触发 void SavedChangesEvent(object sender, SavedChangesEventArgs e) 方法
  • 提交更改失败 SaveChangesFailed 事件:触发 void SaveChangesFailedEvent(object sender, SaveChangesFailedEventArgs e) 方法

通过这三个事件我们可以在数据库做增、删、改时候做拦截,比如设置创建时间、更新时间或其他默认操作

如自动添加租户Id:

protected override void SavingChangesEvent(object sender, SavingChangesEventArgs e)
{
// 获取当前事件对应上下文
var dbContext = sender as FurDbContext;
// 获取所有新增和更新的实体
var entities = dbContext.ChangeTracker.Entries()
.Where(u => u.State == EntityState.Added || u.State == EntityState.Modified);
foreach (var entity in entities)
{
switch (entity.State)
{
// 自动设置租户Id
case EntityState.Added:
entity.Property(nameof(Entity.TenantId)).CurrentValue = GetTenantId();
break;
// 排除租户Id
case EntityState.Modified:
entity.Property(nameof(Entity.TenantId)).IsModified = false;
break;
}
}
}

9.24.3 注册自定义过滤器

定义好过滤器之后,我们需要在数据库上下文中注册:

services.AddSqlitePool<FurDbContext>(interceptors: new IInterceptor[] {
new SqlConnectionProfilerInterceptor(),
new DbContextSaveChangesInterceptor(),
new SqlCommandProfilerInterceptor()
});

9.24.4 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
// 提交数据库失败(异步)
public override Task SaveChangesFailedAsync(DbContextErrorEventData eventData, CancellationToken cancellationToken = default)
{
return base.SaveChangesFailedAsync(eventData, cancellationToken);
}
}
}

9.24.2.4 SavedChangesEvent 拦截

Fur 框架中为所有 AppDbContext 子类都提供了三个可重写的方法,这三个方法分别由三个事件触发:

  • 提交更改之前 SavingChanges 事件:触发 void SavingChangesEvent(object sender, SavingChangesEventArgs e) 方法
  • 提交更改之后 SavedChanges 事件:触发 void SavedChangesEvent(object sender, SavedChangesEventArgs e) 方法
  • 提交更改失败 SaveChangesFailed 事件:触发 void SaveChangesFailedEvent(object sender, SaveChangesFailedEventArgs e) 方法

通过这三个事件我们可以在数据库做增、删、改时候做拦截,比如设置创建时间、更新时间或其他默认操作

如自动添加租户Id:

protected override void SavingChangesEvent(object sender, SavingChangesEventArgs e)
{
// 获取当前事件对应上下文
var dbContext = sender as FurDbContext;
// 获取所有新增和更新的实体
var entities = dbContext.ChangeTracker.Entries()
.Where(u => u.State == EntityState.Added || u.State == EntityState.Modified);
foreach (var entity in entities)
{
switch (entity.State)
{
// 自动设置租户Id
case EntityState.Added:
entity.Property(nameof(Entity.TenantId)).CurrentValue = GetTenantId();
break;
// 排除租户Id
case EntityState.Modified:
entity.Property(nameof(Entity.TenantId)).IsModified = false;
break;
}
}
}

9.24.3 注册自定义过滤器

定义好过滤器之后,我们需要在数据库上下文中注册:

services.AddSqlitePool<FurDbContext>(interceptors: new IInterceptor[] {
new SqlConnectionProfilerInterceptor(),
new DbContextSaveChangesInterceptor(),
new SqlCommandProfilerInterceptor()
});

9.24.4 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-add-or-update/index.html b/handbook/build/docs/dbcontext-add-or-update/index.html index c953bca31de..5ea61843cba 100644 --- a/handbook/build/docs/dbcontext-add-or-update/index.html +++ b/handbook/build/docs/dbcontext-add-or-update/index.html @@ -4,22 +4,22 @@ -9.7 新增或更新操作 | Fur - - - - - - - - - - - +9.7 新增或更新操作 | Fur + + + + + + + + + + +
-

9.7 新增或更新操作

9.7.1 新增或更新(不立即提交)

// ==== 同步操作 ====
+

9.7 新增或更新操作

9.7.1 新增或更新(不立即提交)

// ==== 同步操作 ====
// 示例一
repository.InsertOrUpdate(user);
// 示例二
user.InsertOrUpdate();
// ==== 异步操作 ====
@@ -97,17 +97,17 @@
// 示例五
await user.InsertOrUpdateExcludeNowAsync(u=>u.Name, u=>u.Age);
// 示例六
await user.InsertOrUpdateExcludeNowAsync("Age", "Name");
// 示例七
await user.InsertOrUpdateExcludeNowAsync(new[] { u=>u.Name, u=>u.Age});
-
// 示例八
await user.InsertOrUpdateExcludeNowAsync(new[] {"Age", "Name"});

9.5.7 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
// 示例八
await user.InsertOrUpdateExcludeNowAsync(new[] {"Age", "Name"});

9.5.7 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-add/index.html b/handbook/build/docs/dbcontext-add/index.html index 6716ebb2987..ce7c563a53c 100644 --- a/handbook/build/docs/dbcontext-add/index.html +++ b/handbook/build/docs/dbcontext-add/index.html @@ -4,22 +4,22 @@ -9.5 新增操作 | Fur - - - - - - - - - - - +9.5 新增操作 | Fur + + + + + + + + + + +
-

9.5 新增操作

Fur 框架提供非常多的语法糖进行数据库操作。

9.5.1 新增一条,无返回值

var user = new User { Name = "百小僧", Age = 27 };
+

9.5 新增操作

Fur 框架提供非常多的语法糖进行数据库操作。

9.5.1 新增一条,无返回值

var user = new User { Name = "百小僧", Age = 27 };
// ==== 同步操作 ====
// 示例一
repository.Insert(user);
// 示例二
user.Insert();
@@ -48,17 +48,17 @@
// ==== 异步操作 ====
// 示例一
await repository.InsertNowAsync(user, user2);
// 示例二
await repository.InsertNowAsync(new List<User> { user, user2 });
-
// 示例三
await repository.InsertNowAsync(new[] {user, user2 });
小知识

所有带 Now 结尾的表示立即提交到数据库,也就是立即调用 SaveChangesSaveChangesAsync

9.5.5 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
// 示例三
await repository.InsertNowAsync(new[] {user, user2 });
小知识

所有带 Now 结尾的表示立即提交到数据库,也就是立即调用 SaveChangesSaveChangesAsync

9.5.5 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-audit/index.html b/handbook/build/docs/dbcontext-audit/index.html index 59a79446529..8128053ee15 100644 --- a/handbook/build/docs/dbcontext-audit/index.html +++ b/handbook/build/docs/dbcontext-audit/index.html @@ -4,22 +4,22 @@ -9.22 审计日志 | Fur - - - - - - - - - - - +9.22 审计日志 | Fur + + + + + + + + + + +
-

9.22 审计日志

9.22.1 审计日志

在一个企业应用系统中,用户对系统所有的操作包括请求,数据库操作等等都应该记录起来,那么这些日志我们成为操作日志,也可以说审计日志。

通常来说,我们审计日志更多指的是数据库的操作记录。

审计日志一般会记录以下三个操作:

  • 新增操作:记录某某人在某某时间对哪个表新增了什么数据
  • 更新操作:记录某某人在某某时间对哪个表的哪些数据做了更改,记录更改前的值和更改后的值
  • 删除操作:记录某某人在某某时间对哪个表删除了什么数据

9.22.2 关于 SaveChanges 事件

Fur 框架中为所有 AppDbContext 子类都提供了三个可重写的方法,这三个方法分别由三个事件触发:

  • 提交更改之前 SavingChanges 事件:触发 void SavingChangesEvent(object sender, SavingChangesEventArgs e) 方法
  • 提交更改之后 SavedChanges 事件:触发 void SavedChangesEvent(object sender, SavedChangesEventArgs e) 方法
  • 提交更改失败 SaveChangesFailed 事件:触发 void SaveChangesFailedEvent(object sender, SaveChangesFailedEventArgs e) 方法

通过这三个事件我们就可以捕获所有更改的实体然后保存到数据库审计日志中。

9.22.3 如何使用

我们只需要在 AppDbContext 子类中重写 SavingChanges 事件对应方法即可:

using Fur.DatabaseAccessor;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using System;
using System.Linq;
using System.Security.AccessControl;
+

9.22 审计日志

9.22.1 审计日志

在一个企业应用系统中,用户对系统所有的操作包括请求,数据库操作等等都应该记录起来,那么这些日志我们成为操作日志,也可以说审计日志。

通常来说,我们审计日志更多指的是数据库的操作记录。

审计日志一般会记录以下三个操作:

  • 新增操作:记录某某人在某某时间对哪个表新增了什么数据
  • 更新操作:记录某某人在某某时间对哪个表的哪些数据做了更改,记录更改前的值和更改后的值
  • 删除操作:记录某某人在某某时间对哪个表删除了什么数据

9.22.2 关于 SaveChanges 事件

Fur 框架中为所有 AppDbContext 子类都提供了三个可重写的方法,这三个方法分别由三个事件触发:

  • 提交更改之前 SavingChanges 事件:触发 void SavingChangesEvent(object sender, SavingChangesEventArgs e) 方法
  • 提交更改之后 SavedChanges 事件:触发 void SavedChangesEvent(object sender, SavedChangesEventArgs e) 方法
  • 提交更改失败 SaveChangesFailed 事件:触发 void SaveChangesFailedEvent(object sender, SaveChangesFailedEventArgs e) 方法

通过这三个事件我们就可以捕获所有更改的实体然后保存到数据库审计日志中。

9.22.3 如何使用

我们只需要在 AppDbContext 子类中重写 SavingChanges 事件对应方法即可:

using Fur.DatabaseAccessor;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using System;
using System.Linq;
using System.Security.AccessControl;
namespace Fur.EntityFramework.Core
{
[AppDbContext("Sqlite3ConnectionString")]
public class FurDbContext : AppDbContext<FurDbContext>
{
public FurDbContext(DbContextOptions<FurDbContext> options) : base(options)
{
}
/// <summary>
/// 重写保存之前事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected override void SavingChangesEvent(object sender, SavingChangesEventArgs e)
{
// 获取当前事件对应上下文
var dbContext = sender as FurDbContext;
// 强制重新检查一边实体更改信息
dbContext.ChangeTracker.DetectChanges();
@@ -32,17 +32,17 @@
// 遍历所有属性
foreach (var prop in props)
{
// 获取属性名
var propName = prop.Name;
// 获取现在的实体值
var newValue = currentValues[propName];
object oldValue = null;
// 如果是新增数据,则 databaseValues 为空,所以需要判断一下
if (databaseValues != null)
{
oldValue = databaseValues[propName];
}
-
// 插入审计日志表
dbContext.Audits.Add(new Audit
{
Table = entityType.Name, // 表名
Column = propName, // 更新的列
NewValue = newValue, // 新值
OldValue = oldValue, // 旧值
CreatedTime = DateTime.Now, // 操作时间
UserId = userId, // 操作人
Operate = entity.State.ToString(); // 操作方式:新增、更新、删除
});
}
}
}
}
}
小知识

如果对性能有所要求,那么建议审计日志通过 日志组件 写入数据库,如,通过 Nlog、Log4Net 这些等:

// 插入审计日志表
dbContext.Audits.Add(new Audit
{
Table = entityType.Name, // 表名
Column = propName, // 更新的列
newValue = newValue, // 新值
OldValue = oldValue, // 旧值
CreatedTime = DateTime.Now, // 操作时间
UserId = userId, // 操作人
Operate = entity.State.ToString(); // 操作方式:新增、更新、删除
});

替换为:

logger.Information(JsonConvert.SerializeObject(new Audit
{
Table = entityType.Name, // 表名
Column = propName, // 更新的列
newValue = newValue, // 新值
OldValue = oldValue, // 旧值
CreatedTime = DateTime.Now, // 操作时间
UserId = userId, // 操作人
Operate = entity.State.ToString(); // 操作方式:新增、更新、删除
}));

通过上面的例子,我们就可以对数据库所有的新增、更新、删除进行监控了。

9.22.4 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
// 插入审计日志表
dbContext.Audits.Add(new Audit
{
Table = entityType.Name, // 表名
Column = propName, // 更新的列
NewValue = newValue, // 新值
OldValue = oldValue, // 旧值
CreatedTime = DateTime.Now, // 操作时间
UserId = userId, // 操作人
Operate = entity.State.ToString(); // 操作方式:新增、更新、删除
});
}
}
}
}
}
小知识

如果对性能有所要求,那么建议审计日志通过 日志组件 写入数据库,如,通过 Nlog、Log4Net 这些等:

// 插入审计日志表
dbContext.Audits.Add(new Audit
{
Table = entityType.Name, // 表名
Column = propName, // 更新的列
newValue = newValue, // 新值
OldValue = oldValue, // 旧值
CreatedTime = DateTime.Now, // 操作时间
UserId = userId, // 操作人
Operate = entity.State.ToString(); // 操作方式:新增、更新、删除
});

替换为:

logger.Information(JsonConvert.SerializeObject(new Audit
{
Table = entityType.Name, // 表名
Column = propName, // 更新的列
newValue = newValue, // 新值
OldValue = oldValue, // 旧值
CreatedTime = DateTime.Now, // 操作时间
UserId = userId, // 操作人
Operate = entity.State.ToString(); // 操作方式:新增、更新、删除
}));

通过上面的例子,我们就可以对数据库所有的新增、更新、删除进行监控了。

9.22.4 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-batch/index.html b/handbook/build/docs/dbcontext-batch/index.html index da3a34b1dfd..a79b44d05eb 100644 --- a/handbook/build/docs/dbcontext-batch/index.html +++ b/handbook/build/docs/dbcontext-batch/index.html @@ -4,22 +4,22 @@ -9.9 批量操作 | Fur - - - - - - - - - - - +9.9 批量操作 | Fur + + + + + + + + + + +
-

9.9 批量操作

9.9.1 关于批量操作

Fur 框架中,默认只提供小数据(100 以内)批量数据操作,如果需要更大的数据批量处理,推荐使用第三方包 EFCore.BulkExtensions,支持和 Fur 无缝衔接。

9.9.2 EFCore.BulkExtensions 使用

9.9.2.1 常见批量操作

// 批量插入
repository.DbContext.BulkInsert(entitiesList);
repository.DbContext.BulkInsertAsync(entitiesList);
+

9.9 批量操作

9.9.1 关于批量操作

Fur 框架中,默认只提供小数据(100 以内)批量数据操作,如果需要更大的数据批量处理,推荐使用第三方包 EFCore.BulkExtensions,支持和 Fur 无缝衔接。

9.9.2 EFCore.BulkExtensions 使用

9.9.2.1 常见批量操作

// 批量插入
repository.DbContext.BulkInsert(entitiesList);
repository.DbContext.BulkInsertAsync(entitiesList);
// 批量更新
repository.DbContext.BulkUpdate(entitiesList);
repository.DbContext.BulkUpdateAsync(entitiesList);
// 批量删除
repository.DbContext.BulkDelete(entitiesList);
repository.DbContext.BulkDeleteAsync(entitiesList);
// 批量插入或更新
repository.DbContext.BulkInsertOrUpdate(entitiesList);
repository.DbContext.BulkInsertOrUpdateAsync(entitiesList);
@@ -27,17 +27,17 @@
// 批量读取多个实体
repository.DbContext.BulkRead(entitiesList);
repository.DbContext.BulkReadAsync(entitiesList);
// 批量清空表(慎用!!!!!)
repository.DbContext.Truncate<Entity>();
repository.DbContext.TruncateAsync<Entity>();

9.9.2.2 查询后批量操作

// 根据条件批量删除
repository.Where(a => a.ItemId > 500).BatchDelete();
await repository.Where(a => a.ItemId > 500).BatchDeleteAsync();
// 根据条件批量更新
repository.Where(a => a.ItemId <= 500).BatchUpdate(a => new Item { Quantity = a.Quantity + 100 });
repository.Where(a => a.ItemId <= 500).BatchUpdate(new Item { Description = "Updated" });
await repository.Where(a => a.ItemId <= 500).BatchUpdateAsync(new Item { Description = "Updated" });
-
// 批量更新指定列
var updateColumns = new List<string> { nameof(Item.Quantity) };
var q = repository.Where(a => a.ItemId <= 500);
int affected = q.BatchUpdate(new Item { Description = "Updated" }, updateColumns);

9.9.3 批量操作性能

Operations\Rows100,000 EF100,000 EFBulk1,000,000 EFBulk
Insert38.98 s2.10 s17.99 s
Update109.25 s3.96 s31.45 s
Delete7.26 s2.04 s12.18 s
---------------------------------------------------------------
Together70.70 s5.88 s56.84 s

9.9.4 反馈与建议

与我们交流

给 Fur 提 Issue


了解更多

想了解更多 EFCore.BulkExtensions 知识可查阅 EFCore.BulkExtensions 开源仓库

- - - - - - - - - - - +
// 批量更新指定列
var updateColumns = new List<string> { nameof(Item.Quantity) };
var q = repository.Where(a => a.ItemId <= 500);
int affected = q.BatchUpdate(new Item { Description = "Updated" }, updateColumns);

9.9.3 批量操作性能

Operations\Rows100,000 EF100,000 EFBulk1,000,000 EFBulk
Insert38.98 s2.10 s17.99 s
Update109.25 s3.96 s31.45 s
Delete7.26 s2.04 s12.18 s
---------------------------------------------------------------
Together70.70 s5.88 s56.84 s

9.9.4 反馈与建议

与我们交流

给 Fur 提 Issue


了解更多

想了解更多 EFCore.BulkExtensions 知识可查阅 EFCore.BulkExtensions 开源仓库

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-code-first/index.html b/handbook/build/docs/dbcontext-code-first/index.html index 4266501487e..32d19a69d40 100644 --- a/handbook/build/docs/dbcontext-code-first/index.html +++ b/handbook/build/docs/dbcontext-code-first/index.html @@ -4,36 +4,36 @@ -9.20 模型生成数据库 | Fur - - - - - - - - - - - +9.20 模型生成数据库 | Fur + + + + + + + + + + +
-

9.20 模型生成数据库

9.20.1 数据库开发方式

Fur 提供两种主要方法来 保持实体模型和数据库架构同步

至于我们应该选用哪个方法,请确定你是希望以实体模型为准还是以数据库为准:

  • 如果希望 以实体模型为准,请使用正向工程(Code First)。 对实体模型进行更改时,此方法会以增量方式将相应架构更改应用到数据库,以使数据库保持与实体模型兼容。

  • 如果希望 以数据库架构为准,请使用反向工程(Database First)。 使用此方法,可通过将数据库架构反向工程到实体模型来生成相应的实体类型。

本章节是 正向工程(Code First) 的相关内容。

9.20.2 操作指南

9.20.2.1 创建实体模型 Person

using Fur.DatabaseAccessor;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+

9.20 模型生成数据库

9.20.1 数据库开发方式

Fur 提供两种主要方法来 保持实体模型和数据库架构同步

至于我们应该选用哪个方法,请确定你是希望以实体模型为准还是以数据库为准:

  • 如果希望 以实体模型为准,请使用正向工程(Code First)。 对实体模型进行更改时,此方法会以增量方式将相应架构更改应用到数据库,以使数据库保持与实体模型兼容。

  • 如果希望 以数据库架构为准,请使用反向工程(Database First)。 使用此方法,可通过将数据库架构反向工程到实体模型来生成相应的实体类型。

本章节是 正向工程(Code First) 的相关内容。

9.20.2 操作指南

9.20.2.1 创建实体模型 Person

using Fur.DatabaseAccessor;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Fur.Core
{
public class Person : Entity
{
/// <summary>
/// 构造函数
/// </summary>
public Person()
{
CreatedTime = DateTime.Now;
IsDeleted = false;
}
/// <summary>
/// 姓名
/// </summary>
[MaxLength(32)]
public string Name { get; set; }
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
-
/// <summary>
/// 住址
/// </summary>
public string Address { get; set; }
}
}
实体约定

所有数据库实体必须直接或间接继承 IEntity 接口。

9.20.2.2 打开 程序包管理控制台

9.20.2.3 切换默认项目

程序包管理控制台 默认项目设置为 Fur.Database.Migrations

9.20.2.4 创建模型版本

Add-Migration v1.0.0
特别说明

v1.0.0 是此处数据库更改的版本号,可以写任何字符串,但推荐写版本号,每次 +1

最终命令如下:

PM> Add-Migration v1.0.0
Build started...
Build succeeded.
Microsoft.EntityFrameworkCore.Model.Validation[10400]
Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data, this mode should only be enabled during development.
Microsoft.EntityFrameworkCore.Infrastructure[10403]
Entity Framework Core 5.0.0-rc.1.20451.13 initialized 'FurDbContext' using provider 'Microsoft.EntityFrameworkCore.Sqlite' with options: SensitiveDataLoggingEnabled DetailedErrorsEnabled MaxPoolSize=100 MigrationsAssembly=Fur.Database.Migrations
To undo this action, use Remove-Migration.
PM>

生成成功后,Fur.Database.Migrations 项目下会新增 Migrations 文件夹(如果没有),同时本次的架构生成文件,如:

9.20.2.5 更新到数据库

Update-Database

执行该命令后,数据库就会自动根据模型生成对于的表。

小知识

如果 Update-Database 后面带字符串参数,则会自动还原数据库到指定版本,如:

Update-Database v0.0.3

将数据库还原到 v0.0.3 版本

9.20.3 更新模型

如果模型改变了,重复上面操作即可,如:

Add-Migration v1.0.1
Update-Database

9.20.4 导出 Sql

有些时候,我们没有直接更新数据库的权限,或者怕出问题,我们都会先生成 Sql 看看,这时候只需要通过 Script-Migration 导出即可,如:

Script-Migration

9.20.5 反馈与建议

与我们交流

给 Fur 提 Issue


了解更多

想了解更多 正向工厂 知识可查阅 EF Core - 管理数据库架构 章节。

- - - - - - - - - - - +
/// <summary>
/// 住址
/// </summary>
public string Address { get; set; }
}
}
实体约定

所有数据库实体必须直接或间接继承 IEntity 接口。

9.20.2.2 打开 程序包管理控制台

9.20.2.3 切换默认项目

程序包管理控制台 默认项目设置为 Fur.Database.Migrations

9.20.2.4 创建模型版本

Add-Migration v1.0.0
特别说明

v1.0.0 是此处数据库更改的版本号,可以写任何字符串,但推荐写版本号,每次 +1

最终命令如下:

PM> Add-Migration v1.0.0
Build started...
Build succeeded.
Microsoft.EntityFrameworkCore.Model.Validation[10400]
Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data, this mode should only be enabled during development.
Microsoft.EntityFrameworkCore.Infrastructure[10403]
Entity Framework Core 5.0.0-rc.1.20451.13 initialized 'FurDbContext' using provider 'Microsoft.EntityFrameworkCore.Sqlite' with options: SensitiveDataLoggingEnabled DetailedErrorsEnabled MaxPoolSize=100 MigrationsAssembly=Fur.Database.Migrations
To undo this action, use Remove-Migration.
PM>

生成成功后,Fur.Database.Migrations 项目下会新增 Migrations 文件夹(如果没有),同时本次的架构生成文件,如:

9.20.2.5 更新到数据库

Update-Database

执行该命令后,数据库就会自动根据模型生成对于的表。

小知识

如果 Update-Database 后面带字符串参数,则会自动还原数据库到指定版本,如:

Update-Database v0.0.3

将数据库还原到 v0.0.3 版本

9.20.3 更新模型

如果模型改变了,重复上面操作即可,如:

Add-Migration v1.0.1
Update-Database

9.20.4 导出 Sql

有些时候,我们没有直接更新数据库的权限,或者怕出问题,我们都会先生成 Sql 看看,这时候只需要通过 Script-Migration 导出即可,如:

Script-Migration

9.20.5 反馈与建议

与我们交流

给 Fur 提 Issue


了解更多

想了解更多 正向工厂 知识可查阅 EF Core - 管理数据库架构 章节。

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-db-first/index.html b/handbook/build/docs/dbcontext-db-first/index.html index 9de3e28f5e3..07d9d2a896c 100644 --- a/handbook/build/docs/dbcontext-db-first/index.html +++ b/handbook/build/docs/dbcontext-db-first/index.html @@ -4,22 +4,22 @@ -9.19 数据库生成模型 | Fur - - - - - - - - - - - +9.19 数据库生成模型 | Fur + + + + + + + + + + +
-

9.19 数据库生成模型

9.19.1 数据库开发方式

Fur 提供两种主要方法来 保持实体模型和数据库架构同步

至于我们应该选用哪个方法,请确定你是希望以实体模型为准还是以数据库为准:

  • 如果希望 以实体模型为准,请使用正向工程(Code First)。 对实体模型进行更改时,此方法会以增量方式将相应架构更改应用到数据库,以使数据库保持与实体模型兼容。

  • 如果希望 以数据库架构为准,请使用反向工程(Database First)。 使用此方法,可通过将数据库架构反向工程到实体模型来生成相应的实体类型。

本章节是 反向工程(Database First) 的相关内容。

9.19.2 操作指南

操作之前注意事项

目前 Fur Tools 生成工具默认不支持任何数据库生成,所以如需生成特定数据库的代码,只需要在 Fur.EntityFrameworkCore.Core 安装对应的数据库包即可:

各个数据库的包可查阅:多数据库操作-数据库提供器对应包

另外,只有 SqlServer 数据库支持可视化 GUI 操作,其他的只能命令行操作。

9.19.2.1 打开 程序包管理控制台

注意:开始之前先把 Fur.Web.Entry 设为启动项目。

9.19.2.2 切换默认项目

程序包管理控制台 默认项目设置为 Fur.Core,如果您是其他名字,则切换对应即可。

9.19.2.3 输入 cli.ps1 命令

&"../tools/cli.ps1"
关于数据库命名

如果需要保持和数据库一模一样的命名,则使用 -UseDatabaseNames 参数指定,如:

&"../tools/cli.ps1" -UseDatabaseNames
等待输入

执行上面命令后,此时,Cli 有一个等待输入提示:

Fur Tools v1.0.0 请键入操作类型:[G] 界面操作,[任意字符] 命令行操作
Fur Tools v1.0.0 您的输入是:

输入大写 G 进入界面操作模式,其他任意字符进入命令行操作模式。

注意事项

目前只有 Sql Server 数据库才支持 GUI 界面操作模式,其他数据库请使用命令行模式。

9.19.3 界面操作模式

9.19.3.1 启动界面操作

当我们输入 G 时,将打开 GUI 界面操作模式,如:

这时,Fur Tools 会自动查找所有数据库配置连接字符串的 .json 文件:

{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"Microsoft.EntityFrameworkCore": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DbConnectionString": "Server=localhost;Database=Fur;User=sa;Password=000000;MultipleActiveResultSets=True;",
"Sqlite3ConnectionString": "Data Source=./Fur.db"
}
}

9.13.3.2 加载数据库表

选择连接字符串之后,点击 加载数据库表和视图 按钮加载。

9.13.3.3 选择表或视图生成

加载表完成后,可以选择您要生成的表或视图,支持多选

点击底部按钮 立即生成

9.13.3.4 选择保存目录

点击 立即生成 按钮后,会弹出实体保存选择目录资源管理器,默认实体只能保存在 Fur.Core 层:

点击确定后就可完成所有生成操作。

9.13.3.5 生成最终实体代码

最终脚本如下:

PM> &"../tools/cli.ps1"
// -----------------------------------------------------------------------------
// ______ _______ _
// | ____| |__ __| | |
// | |__ _ _ _ __ | | ___ ___ | |___
// | __| | | | '__| | |/ _ \ / _ \| / __|
// | | | |_| | | | | (_) | (_) | \__ \
// |_| \__,_|_| |_|\___/ \___/|_|___/
//
// -----------------------------------------------------------------------------
// Fur 是 .NET 5 平台下极易入门、极速开发的 Web 应用框架。
// Copyright © 2020 Fur, Baiqian Co.,Ltd.
//
// 框架名称:Fur
// 框架作者:百小僧
// 框架版本:1.0.0
// 源码地址:https://gitee.com/monksoul/Fur
// 开源协议:Apache-2.0(http://www.apache.org/licenses/LICENSE-2.0)
// -----------------------------------------------------------------------------
Fur Tools v1.0.0 启动中......
Fur Tools v1.0.0 启动成功!
Fur Tools v1.0.0 请键入操作类型:[G] 界面操作,[任意字符] 命令行操作
Fur Tools v1.0.0 您的输入是: G
Fur Tools v1.0.0 正在加载数据库表和视图......
Fur Tools v1.0.0 加载成功!
Fur Tools v1.0.0 正在编译解决方案代码......
Build started...
Build succeeded.
For foreign key FK_PersonDetail_Person_PersonId on table dbo.PersonDetail, unable to model the end of the foreign key on principal table dbo.Person. This is usually because the principal table was not included in the selection set.
Fur Tools v1.0.0 编译成功!
Fur Tools v1.0.0 开始生成实体文件......
Fur Tools v1.0.0 正在生成 City.cs 实体代码......
Fur Tools v1.0.0 成功生成 City.cs 实体代码
// -----------------------------------------------------------------------------
// 以下代码由 Fur Tools v1.0.0 生成
// -----------------------------------------------------------------------------
+

9.19 数据库生成模型

9.19.1 数据库开发方式

Fur 提供两种主要方法来 保持实体模型和数据库架构同步

至于我们应该选用哪个方法,请确定你是希望以实体模型为准还是以数据库为准:

  • 如果希望 以实体模型为准,请使用正向工程(Code First)。 对实体模型进行更改时,此方法会以增量方式将相应架构更改应用到数据库,以使数据库保持与实体模型兼容。

  • 如果希望 以数据库架构为准,请使用反向工程(Database First)。 使用此方法,可通过将数据库架构反向工程到实体模型来生成相应的实体类型。

本章节是 反向工程(Database First) 的相关内容。

9.19.2 操作指南

操作之前注意事项

目前 Fur Tools 生成工具默认不支持任何数据库生成,所以如需生成特定数据库的代码,只需要在 Fur.EntityFrameworkCore.Core 安装对应的数据库包即可:

各个数据库的包可查阅:多数据库操作-数据库提供器对应包

另外,只有 SqlServer 数据库支持可视化 GUI 操作,其他的只能命令行操作。

9.19.2.1 打开 程序包管理控制台

注意:开始之前先把 Fur.Web.Entry 设为启动项目。

9.19.2.2 切换默认项目

程序包管理控制台 默认项目设置为 Fur.Core,如果您是其他名字,则切换对应即可。

9.19.2.3 输入 cli.ps1 命令

&"../tools/cli.ps1"
关于数据库命名

如果需要保持和数据库一模一样的命名,则使用 -UseDatabaseNames 参数指定,如:

&"../tools/cli.ps1" -UseDatabaseNames
等待输入

执行上面命令后,此时,Cli 有一个等待输入提示:

Fur Tools v1.0.0 请键入操作类型:[G] 界面操作,[任意字符] 命令行操作
Fur Tools v1.0.0 您的输入是:

输入大写 G 进入界面操作模式,其他任意字符进入命令行操作模式。

注意事项

目前只有 Sql Server 数据库才支持 GUI 界面操作模式,其他数据库请使用命令行模式。

9.19.3 界面操作模式

9.19.3.1 启动界面操作

当我们输入 G 时,将打开 GUI 界面操作模式,如:

这时,Fur Tools 会自动查找所有数据库配置连接字符串的 .json 文件:

{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"Microsoft.EntityFrameworkCore": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DbConnectionString": "Server=localhost;Database=Fur;User=sa;Password=000000;MultipleActiveResultSets=True;",
"Sqlite3ConnectionString": "Data Source=./Fur.db"
}
}

9.13.3.2 加载数据库表

选择连接字符串之后,点击 加载数据库表和视图 按钮加载。

9.13.3.3 选择表或视图生成

加载表完成后,可以选择您要生成的表或视图,支持多选

点击底部按钮 立即生成

9.13.3.4 选择保存目录

点击 立即生成 按钮后,会弹出实体保存选择目录资源管理器,默认实体只能保存在 Fur.Core 层:

点击确定后就可完成所有生成操作。

9.13.3.5 生成最终实体代码

最终脚本如下:

PM> &"../tools/cli.ps1"
// -----------------------------------------------------------------------------
// ______ _______ _
// | ____| |__ __| | |
// | |__ _ _ _ __ | | ___ ___ | |___
// | __| | | | '__| | |/ _ \ / _ \| / __|
// | | | |_| | | | | (_) | (_) | \__ \
// |_| \__,_|_| |_|\___/ \___/|_|___/
//
// -----------------------------------------------------------------------------
// Fur 是 .NET 5 平台下极易入门、极速开发的 Web 应用框架。
// Copyright © 2020 Fur, Baiqian Co.,Ltd.
//
// 框架名称:Fur
// 框架作者:百小僧
// 框架版本:1.0.0
// 源码地址:https://gitee.com/monksoul/Fur
// 开源协议:Apache-2.0(http://www.apache.org/licenses/LICENSE-2.0)
// -----------------------------------------------------------------------------
Fur Tools v1.0.0 启动中......
Fur Tools v1.0.0 启动成功!
Fur Tools v1.0.0 请键入操作类型:[G] 界面操作,[任意字符] 命令行操作
Fur Tools v1.0.0 您的输入是: G
Fur Tools v1.0.0 正在加载数据库表和视图......
Fur Tools v1.0.0 加载成功!
Fur Tools v1.0.0 正在编译解决方案代码......
Build started...
Build succeeded.
For foreign key FK_PersonDetail_Person_PersonId on table dbo.PersonDetail, unable to model the end of the foreign key on principal table dbo.Person. This is usually because the principal table was not included in the selection set.
Fur Tools v1.0.0 编译成功!
Fur Tools v1.0.0 开始生成实体文件......
Fur Tools v1.0.0 正在生成 City.cs 实体代码......
Fur Tools v1.0.0 成功生成 City.cs 实体代码
// -----------------------------------------------------------------------------
// 以下代码由 Fur Tools v1.0.0 生成
// -----------------------------------------------------------------------------
using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
#nullable disable
namespace Fur.Core
{
public partial class City : IEntity, IEntityTypeBuilder<City>
{
@@ -56,17 +56,17 @@
entityBuilder.Property(e => e.Name).HasMaxLength(32);
}
}
}
-
Fur Tools v1.0.0 全部实体生成成功!
PM>

9.13.4 命令参数配置

Fur Tools Cli 支持多个参数配置,使用方法只需要在命令后面添加即可,如:

&"../tools/cli.ps1" -Context 数据库上下文名 -ConnectionName 连接字符串Key

支持参数如下:

  • -Tables:配置要生成的数据库表,数组类型,如果为空,则生成数据库所有表和视图。如:-Tables Person,PersonDetails
  • -Context:配置数据库上下文,默认 FurDbContext,如果有多个数据库上下文,则此参数必须配置
  • -ConnectionName:配置数据库连接字符串,对于 appsetting.json 中的 Key
  • -OutputDir:生成实体代码输出目录,默认为:./Fur.Core/Entities/
  • -DbProvider:数据库提供器,默认是 Microsoft.EntityFrameworkCore.SqlServer,其他数据库请指定对应程序集
    • SqlServerMicrosoft.EntityFrameworkCore.SqlServer
    • SqliteMicrosoft.EntityFrameworkCore.Sqlite
    • CosmosMicrosoft.EntityFrameworkCore.Cosmos
    • InMemoryDatabaseMicrosoft.EntityFrameworkCore.InMemory
    • MySqlPomelo.EntityFrameworkCore.MySql
    • PostgreSQLNpgsql.EntityFrameworkCore.PostgreSQL
    • OracleCitms.EntityFrameworkCore.Oracle
    • DmMicrosoft.EntityFrameworkCore.Dm
  • -EntryProject:Web 启用项目层名,默认 Fur.Web.Entry
  • -CoreProject:实体项目层名,默认 Fur.Core
  • -DbContextLocators:多数据库上下文定位器,默认 MasterDbContextLocator,支持多个,如:MasterDbContextLocator,MySqlDbContextLocator
  • -Product:解决方案默认前缀,如 Fur
  • -UseDatabaseNames:是否保持生成和数据库、表一致的名称

9.13.5 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
Fur Tools v1.0.0 全部实体生成成功!
PM>

9.13.4 命令参数配置

Fur Tools Cli 支持多个参数配置,使用方法只需要在命令后面添加即可,如:

&"../tools/cli.ps1" -Context 数据库上下文名 -ConnectionName 连接字符串Key

支持参数如下:

  • -Tables:配置要生成的数据库表,数组类型,如果为空,则生成数据库所有表和视图。如:-Tables Person,PersonDetails
  • -Context:配置数据库上下文,默认 FurDbContext,如果有多个数据库上下文,则此参数必须配置
  • -ConnectionName:配置数据库连接字符串,对于 appsetting.json 中的 Key
  • -OutputDir:生成实体代码输出目录,默认为:./Fur.Core/Entities/
  • -DbProvider:数据库提供器,默认是 Microsoft.EntityFrameworkCore.SqlServer,其他数据库请指定对应程序集
    • SqlServerMicrosoft.EntityFrameworkCore.SqlServer
    • SqliteMicrosoft.EntityFrameworkCore.Sqlite
    • CosmosMicrosoft.EntityFrameworkCore.Cosmos
    • InMemoryDatabaseMicrosoft.EntityFrameworkCore.InMemory
    • MySqlPomelo.EntityFrameworkCore.MySql
    • PostgreSQLNpgsql.EntityFrameworkCore.PostgreSQL
    • OracleCitms.EntityFrameworkCore.Oracle
    • DmMicrosoft.EntityFrameworkCore.Dm
  • -EntryProject:Web 启用项目层名,默认 Fur.Web.Entry
  • -CoreProject:实体项目层名,默认 Fur.Core
  • -DbContextLocators:多数据库上下文定位器,默认 MasterDbContextLocator,支持多个,如:MasterDbContextLocator,MySqlDbContextLocator
  • -Product:解决方案默认前缀,如 Fur
  • -UseDatabaseNames:是否保持生成和数据库、表一致的名称

9.13.5 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-delete/index.html b/handbook/build/docs/dbcontext-delete/index.html index de94e4c233d..674958231be 100644 --- a/handbook/build/docs/dbcontext-delete/index.html +++ b/handbook/build/docs/dbcontext-delete/index.html @@ -4,22 +4,22 @@ -9.8 删除操作 | Fur - - - - - - - - - - - +9.8 删除操作 | Fur + + + + + + + + + + +
-

9.8 删除操作

9.8.1 删除一个实体(不立即提交)

// ==== 同步操作 ====
+

9.8 删除操作

9.8.1 删除一个实体(不立即提交)

// ==== 同步操作 ====
// 示例一
repository.Delete(user);
// 示例二
user.Delete();
// 示例三
repository.ChangeEntityState(user, EntityState.Deleted);
@@ -64,17 +64,17 @@
// 示例三
await repository.FakeDeleteAsync(1);
// 示例四
await repository.FakeDeleteNowAsync(1);
// 示例五
await entity.FakeDeleteAsync();
-
// 示例六
await repository.UpdateIncludeAsync(user, u => u.IsDeleted);

9.8.9 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
// 示例六
await repository.UpdateIncludeAsync(user, u => u.IsDeleted);

9.8.9 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-filter/index.html b/handbook/build/docs/dbcontext-filter/index.html index 232d5a56910..81944252b79 100644 --- a/handbook/build/docs/dbcontext-filter/index.html +++ b/handbook/build/docs/dbcontext-filter/index.html @@ -4,22 +4,22 @@ -9.23 实体/全局查询筛选器 | Fur - - - - - - - - - - - +9.23 实体/全局查询筛选器 | Fur + + + + + + + + + + +
-

9.23 实体/全局查询筛选器

9.23.1 查询筛选器

通常,我们系统中有一些维护字段,如 IsDeleted 字段,这个字段用来标识用户已经删除的数据,那么我们需要每次查询数据的时候带上这个字段,避免查询出不该出现的数据。

Fur 提供非常灵活方便的全局查询筛选器,能够应用到每一次查询中。

9.23.2 多种筛选器配置

9.23.2.1 单表筛选器

单表筛选器就是只针对特定实体进行筛选操作,使用简单,只需要在继承 IEntityTypeBuilder<TEntity> 接口并实现即可,如:

using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
+

9.23 实体/全局查询筛选器

9.23.1 查询筛选器

通常,我们系统中有一些维护字段,如 IsDeleted 字段,这个字段用来标识用户已经删除的数据,那么我们需要每次查询数据的时候带上这个字段,避免查询出不该出现的数据。

Fur 提供非常灵活方便的全局查询筛选器,能够应用到每一次查询中。

9.23.2 多种筛选器配置

9.23.2.1 单表筛选器

单表筛选器就是只针对特定实体进行筛选操作,使用简单,只需要在继承 IEntityTypeBuilder<TEntity> 接口并实现即可,如:

using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
namespace Fur.Core
{
public class Person : Entity, IEntityTypeBuilder<Person>
{
public Person()
{
CreatedTime = DateTime.Now;
IsDeleted = false;
}
public string Name { get; set; }
public int Age { get; set; }
@@ -31,17 +31,17 @@
public void OnCreating(ModelBuilder modelBuilder, EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)
{
}
/// <summary>
/// 构建 u => EF.Property<bool>(u, "IsDeleted") == false 表达式
/// </summary>
/// <param name="entityBuilder"></param>
/// <returns></returns>
private LambdaExpression BuilderIsDeleteLambdaExpression(EntityTypeBuilder entityBuilder)
{
// 获取实体构建器元数据
var metadata = entityBuilder.Metadata;
if (metadata.FindProperty(nameof(Entity.IsDeleted)) == null) return default;
// 创建表达式元素
var parameter = Expression.Parameter(metadata.ClrType, "u");
var properyName = Expression.Constant(nameof(Entity.IsDeleted));
var propertyValue = Expression.Constant(false);
-
// 构建表达式 u => EF.Property<bool>(u, "IsDeleted") == false
var expressionBody = Expression.Equal(Expression.Call(typeof(EF), nameof(EF.Property), new[] { typeof(bool) }, parameter, properyName), propertyValue);
var expression = Expression.Lambda(expressionBody, parameter);
return expression;
}
}
}
小建议

如果对动态构建 LambdaExpression 不熟悉的朋友,可以使用 System.Linq.Dynamic.Corehttps://github.com/zzzprojects/System.Linq.Dynamic.Core

9.23.3 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
// 构建表达式 u => EF.Property<bool>(u, "IsDeleted") == false
var expressionBody = Expression.Equal(Expression.Call(typeof(EF), nameof(EF.Property), new[] { typeof(bool) }, parameter, properyName), propertyValue);
var expression = Expression.Lambda(expressionBody, parameter);
return expression;
}
}
}
小建议

如果对动态构建 LambdaExpression 不熟悉的朋友,可以使用 System.Linq.Dynamic.Corehttps://github.com/zzzprojects/System.Linq.Dynamic.Core

9.23.3 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-function/index.html b/handbook/build/docs/dbcontext-function/index.html index 15389192afa..fcf9a2a0843 100644 --- a/handbook/build/docs/dbcontext-function/index.html +++ b/handbook/build/docs/dbcontext-function/index.html @@ -4,22 +4,22 @@ -9.14 函数操作 | Fur - - - - - - - - - - - +9.14 函数操作 | Fur + + + + + + + + + + +
-

9.14 函数操作

温馨提示

推荐使用 《9.15 Sql 高级代理》代替本章节功能。Sql 高级代理 能够提供更容易且更易维护的方式。

9.14.1 数据库函数

引用百度百科:

数据库函数是指当需要分析数据清单中的数值是否符合特定条件时,使用数据库工作表函数。

简单来说,数据库函数就是用于子计算的函数。其计算的结果可以用于构建 sql 语句。

9.14.1.1 支持标量函数的数据库

SqlServerSqliteCosmosInMemoryDatabaseMySqlPostgreSQLOracleFirebirdDm

9.14.1.2 支持表值函数的数据库

SqlServerSqliteCosmosInMemoryDatabaseMySqlPostgreSQLOracleFirebirdDm

9.14.2 数据库函数类型

在关系型数据库中,数据库函数有这两种类型:

  • 标量函数:只能返回单个值
  • 表值函数:只能返回一个结果集

9.14.3 函数的使用

9.14.3.1 标量函数返回 object

// ISqlRepository 方法
var value = _sqlRepository.SqlFunctionScalar("func_GetValue");
+

9.14 函数操作

温馨提示

推荐使用 《9.15 Sql 高级代理》代替本章节功能。Sql 高级代理 能够提供更容易且更易维护的方式。

9.14.1 数据库函数

引用百度百科:

数据库函数是指当需要分析数据清单中的数值是否符合特定条件时,使用数据库工作表函数。

简单来说,数据库函数就是用于子计算的函数。其计算的结果可以用于构建 sql 语句。

9.14.1.1 支持标量函数的数据库

SqlServerSqliteCosmosInMemoryDatabaseMySqlPostgreSQLOracleFirebirdDm

9.14.1.2 支持表值函数的数据库

SqlServerSqliteCosmosInMemoryDatabaseMySqlPostgreSQLOracleFirebirdDm

9.14.2 数据库函数类型

在关系型数据库中,数据库函数有这两种类型:

  • 标量函数:只能返回单个值
  • 表值函数:只能返回一个结果集

9.14.3 函数的使用

9.14.3.1 标量函数返回 object

// ISqlRepository 方法
var value = _sqlRepository.SqlFunctionScalar("func_GetValue");
// ISqlDispatchProxy 方式
var value = _sqlExecuteProxy.GetValue(); // 推荐方式
// 实体仓储方式
var value = _personRepository.SqlFunctionScalar("func_GetValue");
// IRepository 非泛型方式
var value = _repository.Sql().SqlFunctionScalar("func_GetValue");
@@ -36,24 +36,24 @@
// 实体仓储方式
var value = _personRepository.SqlFunctionQuery<Person>("func_GetTable");
// IRepository 非泛型方式
var value = _repository.Sql().SqlFunctionQuery<Person>("func_GetTable");
// 变态懒人方式,直接通过函数名执行
var value = "func_GetTable".SqlFunctionQuery<Person>();
关于异步

Fur 框架每一个数据库操作都支持异步方式,由于篇幅有限,就不列举异步方式了。

9.14.4 在 Linq 中使用 标量函数

Fur 框架提供非常灵活的在 Linq 中使用标量函数的方法。如果像使用这样的方式,需要满足以下两个条件:

  • 标量函数必须定义在公开静态类中,且自己也是公开静态方法
  • 公开静态方法必须贴有 [QueryableFunction] 特性

示例如下:

9.14.4.1 创建标量函数

CREATE FUNCTION FN_GetId
(
@id INT
)
RETURNS INT
AS
BEGIN
RETURN @id + 1;
END;

9.14.4.2 创建静态类和静态方法

创建静态类,如 QueryFunctions,将该 标量函数 放在静态类中:

using Fur.DatabaseAccessor;
using System;
-
namespace Fur.Application
{
// 必须是公开静态的
public static class QueryFunctions
{
// 必须是静态方法
[QueryableFunction("FN_GetId", "dbo")] // 配置标量函数
public static int GetId(int id) => throw new NotSupportedException();
}
}

9.14.4.3 在 Linq 中使用

_personRepository.Where(u => u.Id > QueryFunctions.GetId(1)).ToList();
SELECT [p].[Id], [p].[Address], [p].[Age], [p].[CreatedTime], [p].[IsDeleted], [p].[Name], [p].[UpdatedTime]
FROM [Person] AS [p]
WHERE [p].[Id] > [dbo].[FN_GetId](1) // 💥 注意这里

9.14.5 在 Linq 中使用 表值函数

EF Core 5.0 版本支持在 Linq 中操作 表值函数,操作有点类似 视图操作

示例如下:

9.14.5.1 创建表值函数

CREATE FUNCTION dbo.GetPersons
(
@id INT
)
RETURNS TABLE
AS
RETURN
(
SELECT Id,
Name,
Age,
Address
FROM dbo.Person
WHERE Id > @id
);

9.14.5.2 创建表值函数模型

namespace Fur.Core
{
public class F_Person
{
/// <summary>
/// 主键Id
/// </summary>
public int Id { get; set; }
+
namespace Fur.Application
{
// 必须是公开静态的
public static class QueryFunctions
{
// 必须是静态方法
[QueryableFunction("FN_GetId", "dbo")] // 配置标量函数
public static int GetId(int id) => throw new NotSupportedException();
}
}

9.14.4.3 在 Linq 中使用

_personRepository.Where(u => u.Id > QueryFunctions.GetId(1)).ToList();
SELECT [p].[Id], [p].[Address], [p].[Age], [p].[CreatedTime], [p].[IsDeleted], [p].[Name], [p].[UpdatedTime]
FROM [Person] AS [p]
WHERE [p].[Id] > [dbo].[FN_GetId](1) // 💥 注意这里

9.14.5 在 Linq 中使用 表值函数

EF Core 5.0 版本支持在 Linq 中操作 表值函数,操作有点类似 视图操作

示例如下:

9.14.5.1 创建表值函数

CREATE FUNCTION dbo.GetPersons
(
@id INT
)
RETURNS TABLE
AS
RETURN
(
SELECT Id,
Name,
Age,
Address
FROM dbo.Person
WHERE Id > @id
);

9.14.5.2 创建表值函数模型

namespace Fur.Core
{
public class F_Person
{
/// <summary>
/// 主键Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
/// <summary>
/// 住址
/// </summary>
public string Address { get; set; }
}
}

9.14.5.3 表值函数配置

DbContext 类中定义方法:

using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using System.Linq;
namespace Fur.EntityFramework.Core
{
[AppDbContext("Sqlite3ConnectionString")]
public class FurDbContext : AppDbContext<FurDbContext>
{
public IQueryable<F_Person> GetPersons(int id) => FromExpression(() => GetPersons(id));
public FurDbContext(DbContextOptions<FurDbContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
-
modelBuilder.Entity(typeof(F_Person)).HasNoKey();
modelBuilder.HasDbFunction(() => GetPersons(default));
}
}
}

9.14.5.4 在 Linq 中使用

IQueryable<F_Person> query = _repository.DynamicDbContext.GetPersons(1);
var result = query.Where(u => u.Name.Equals("Fur")).ToList();

最终生成 Sql

SELECT [g].Id, [g].Name, [g].Age, [g].Address
FROM dbo.GetPersons(1) AS [g]
WHERE [g].Name == N'Fur';

9.14.6 在 EF Core 内置函数

EF Core 为我们提供了很多常用的内置函数,可以在 Lambda 条件中使用,主要是通过 EF.Functions 调用,如:

_repository.Where(u => EF.Functions.DateDiffHour(u.CreatedDt, DateTime.Now) > 8).FirstOrDefault();

这个语句使用了 EF.Functions.DateDiffHour 最终生成的 Sql 如下:

SELECT TOP(1) [a].*
FROM [dbo].[TEST] AS [a]
WHERE DATEDIFF(HOUR, [a].[CREATED_DT], GETDATE()) > 8

EF Core 内置函数就不一一列出了,可以通过 EF.Functions 查看更多,如果不能满足自己的需求,那么可以自定义 Linq 标量函数

9.14.7 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
modelBuilder.Entity(typeof(F_Person)).HasNoKey();
modelBuilder.HasDbFunction(() => GetPersons(default));
}
}
}

9.14.5.4 在 Linq 中使用

IQueryable<F_Person> query = _repository.DynamicDbContext.GetPersons(1);
var result = query.Where(u => u.Name.Equals("Fur")).ToList();

最终生成 Sql

SELECT [g].Id, [g].Name, [g].Age, [g].Address
FROM dbo.GetPersons(1) AS [g]
WHERE [g].Name == N'Fur';

9.14.6 在 EF Core 内置函数

EF Core 为我们提供了很多常用的内置函数,可以在 Lambda 条件中使用,主要是通过 EF.Functions 调用,如:

_repository.Where(u => EF.Functions.DateDiffHour(u.CreatedDt, DateTime.Now) > 8).FirstOrDefault();

这个语句使用了 EF.Functions.DateDiffHour 最终生成的 Sql 如下:

SELECT TOP(1) [a].*
FROM [dbo].[TEST] AS [a]
WHERE DATEDIFF(HOUR, [a].[CREATED_DT], GETDATE()) > 8

EF Core 内置函数就不一一列出了,可以通过 EF.Functions 查看更多,如果不能满足自己的需求,那么可以自定义 Linq 标量函数

9.14.7 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-hight-query/index.html b/handbook/build/docs/dbcontext-hight-query/index.html index 5f26b213d39..29dfaa47d5f 100644 --- a/handbook/build/docs/dbcontext-hight-query/index.html +++ b/handbook/build/docs/dbcontext-hight-query/index.html @@ -4,22 +4,22 @@ -9.11 高级查询操作 | Fur - - - - - - - - - - - +9.11 高级查询操作 | Fur + + + + + + + + + + +
-

9.11 高级查询操作

9.11.1 关联数据模型

using Fur.DatabaseAccessor;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+

9.11 高级查询操作

9.11.1 关联数据模型

using Fur.DatabaseAccessor;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Fur.Core
{
public class Person : Entity
{
/// <summary>
/// 构造函数
/// </summary>
public Person()
{
CreatedTime = DateTime.Now;
IsDeleted = false;
}
/// <summary>
/// 姓名
/// </summary>
[MaxLength(32)]
public string Name { get; set; }
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
@@ -50,17 +50,17 @@
// 示例三,支持 ? 语法
var customers = repository.AsQueryable()
.Include(c => c.Location)
.Where(c => c.Location?.Name == "test") // 注意 Location?.Name
.ToList();

9.11.10.2 动态 Lambda

// 示例一
var x = Expression.Parameter(typeof(int), "x");
var y = Expression.Parameter(typeof(int), "y");
var e = DynamicExpressionParser
.ParseLambda(new ParameterExpression[] { x, y }, null, "(x + y) * 2");
// 示例二
var e = DynamicExpressionParser.ParseLambda(
typeof(Customer), typeof(bool),
"City = @0 and Orders.Count >= @1",
"London", 10);

9.11.11 性能优化

默认情况下,EF Core 会跟踪所有实体,也就是任何数据改变都会引起数据检查,所以如果只做查询操作,建议关闭实体跟踪功能。

Fur 框架提供了以下高性能实体集合:

  • DetachedEntities:脱轨/不追踪实体
  • AsQueryable():不追踪实体
  • Entities.AsNoTracking():手动关闭实体追踪

EF Core 中,复杂查询总是会生成一个 sql,也就是 AsSingleQuery(),我们也可以设置为 AsSplitQuery() 切割成多个查询。

9.11.12 分表查询小例子

using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
namespace Fur.Core
{
public class Person : Entity, IEntityTypeBuilder<Person>
{
public string Name { get; set; }
-
/// <summary>
/// 配置实体关系
/// </summary>
/// <param name="entityBuilder"></param>
/// <param name="dbContext"></param>
/// <param name="dbContextLocator"></param>
public void Configure(EntityTypeBuilder<City> entityBuilder, DbContext dbContext, Type dbContextLocator)
{
entityBuilder.ToSqlQuery(
@"select * from dbo.person.2020-09-19
union all
select * from dbo.person.2020-09-20");
}
}
}
var posts = repository.Where(u => u.Id > 10).ToList();

9.11.12 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
/// <summary>
/// 配置实体关系
/// </summary>
/// <param name="entityBuilder"></param>
/// <param name="dbContext"></param>
/// <param name="dbContextLocator"></param>
public void Configure(EntityTypeBuilder<City> entityBuilder, DbContext dbContext, Type dbContextLocator)
{
entityBuilder.ToSqlQuery(
@"select * from dbo.person.2020-09-19
union all
select * from dbo.person.2020-09-20");
}
}
}
var posts = repository.Where(u => u.Id > 10).ToList();

9.11.12 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-locator/index.html b/handbook/build/docs/dbcontext-locator/index.html index cb7664add55..181d7580e75 100644 --- a/handbook/build/docs/dbcontext-locator/index.html +++ b/handbook/build/docs/dbcontext-locator/index.html @@ -4,34 +4,34 @@ -9.2 数据库上下文定位器 | Fur - - - - - - - - - - - +9.2 数据库上下文定位器 | Fur + + + + + + + + + + +
-

9.2 数据库上下文定位器

9.2.1 数据库上下文定位器

在了解数据库上下文定位器之前,我们先了解什么是 定位器定位器 就是给物体安装特殊配置,使其能够被实时追踪和定位。

那为什么需要 定位器

由于 EF Core 本身支持多个数据库上下文操作,但是通过 依赖注入 的方式默认只初始化一个数据库上下文,也就是如果我们想要操作多个数据库上下文,那么 构造函数 注入方式就会变得复杂。

所以,Fur 实现了一套 定位器 功能,通过这个 定位器 ,我们就能够通过 依赖注入 等多个方式定位到数据库上下文并初始化。

9.2.2 数据库上下文定位器作用

  • 能够实现构造函数初始化多个数据库上下文
  • 能够避免业务层直接引用 DbContext
  • 能够实现动态切换数据库、读写分离、主从库等复杂操作

9.2.3 如何定义数据库上下文定位器

定义数据库上下文定位器只需遵循三个原则即可:

  • 必须是公开 class 类型同时具备无参构造函数
  • 该类型必须继承 IDbContextLocator 接口
  • 数据库上下文定位器和数据库上下文必须是一对一关系,也就是不能同时被多个数据库上下文使用

数据库上下文定位器定义代码如下:

using Fur.DatabaseAccessor;
+

9.2 数据库上下文定位器

9.2.1 数据库上下文定位器

在了解数据库上下文定位器之前,我们先了解什么是 定位器定位器 就是给物体安装特殊配置,使其能够被实时追踪和定位。

那为什么需要 定位器

由于 EF Core 本身支持多个数据库上下文操作,但是通过 依赖注入 的方式默认只初始化一个数据库上下文,也就是如果我们想要操作多个数据库上下文,那么 构造函数 注入方式就会变得复杂。

所以,Fur 实现了一套 定位器 功能,通过这个 定位器 ,我们就能够通过 依赖注入 等多个方式定位到数据库上下文并初始化。

9.2.2 数据库上下文定位器作用

  • 能够实现构造函数初始化多个数据库上下文
  • 能够避免业务层直接引用 DbContext
  • 能够实现动态切换数据库、读写分离、主从库等复杂操作

9.2.3 如何定义数据库上下文定位器

定义数据库上下文定位器只需遵循三个原则即可:

  • 必须是公开 class 类型同时具备无参构造函数
  • 该类型必须继承 IDbContextLocator 接口
  • 数据库上下文定位器和数据库上下文必须是一对一关系,也就是不能同时被多个数据库上下文使用

数据库上下文定位器定义代码如下:

using Fur.DatabaseAccessor;
namespace Fur.Core
{
public sealed class FurDbContextLocator : IDbContextLocator
{
}
}

9.2.4 默认数据库上下文定位器

Fur 框架中已经提供了 MasterDbContextLocator 默认数据库上下文定位器,所以默认数据库上下文只需继承 AppDbContext<TDbContext> 即可。

AppDbContext<TDbContext> 定义代码如下:

using Fur.DependencyInjection;
using Microsoft.EntityFrameworkCore;
-
namespace Fur.DatabaseAccessor
{
/// <summary>
/// 默认应用数据库上下文
/// </summary>
/// <typeparam name="TDbContext">数据库上下文</typeparam>
[NonBeScan]
public abstract class AppDbContext<TDbContext> : AppDbContext<TDbContext, MasterDbContextLocator>
where TDbContext : DbContext
{
/// <summary>
/// 构造函数
/// </summary>
/// <param name="options"></param>
public AppDbContext(DbContextOptions<TDbContext> options) : base(options)
{
}
}
}

9.2.5 数据库上下文定位器支持对象

目前数据库上下文支持以下多个对象:

  • AppDbContext<TEntity, TDbContextLocator>:数据上下文
  • IRepository<TEntity, TDbContextLocator:实体仓储
  • ISqlRepository<TDbContextLocator>: Sql 操作仓储
  • Func<Type, DbContext>:依赖注入获取数据库上下文
  • Entity<Tkey, TDbContextLocator> :实体配置
  • EntityBase<Tkey, TDbContextLocator1, ... TDbContextLocator8>:实体配置
  • EntityNotKey<TDbContextLocator1, ... TDbContextLocator8>:无键实体配置
  • IEntitySeedData<TEntity, TDbContextLocator1, ... TDbContextLocator8>:种子数据配置
  • IEntityTypeBuilder<TEntity, TDbContextLocator1, ... TDbContextLocator8>:实体类型构建器
  • IModelBuilderFilter<TDbContextLocator1, ... TDbContextLocator8>:模型构建筛选器
  • [QueryableFunction(DbContextLocators=Type[])]:查询函数

9.2.6 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
namespace Fur.DatabaseAccessor
{
/// <summary>
/// 默认应用数据库上下文
/// </summary>
/// <typeparam name="TDbContext">数据库上下文</typeparam>
[NonBeScan]
public abstract class AppDbContext<TDbContext> : AppDbContext<TDbContext, MasterDbContextLocator>
where TDbContext : DbContext
{
/// <summary>
/// 构造函数
/// </summary>
/// <param name="options"></param>
public AppDbContext(DbContextOptions<TDbContext> options) : base(options)
{
}
}
}

9.2.5 数据库上下文定位器支持对象

目前数据库上下文支持以下多个对象:

  • AppDbContext<TEntity, TDbContextLocator>:数据上下文
  • IRepository<TEntity, TDbContextLocator:实体仓储
  • ISqlRepository<TDbContextLocator>: Sql 操作仓储
  • Func<Type, DbContext>:依赖注入获取数据库上下文
  • Entity<Tkey, TDbContextLocator> :实体配置
  • EntityBase<Tkey, TDbContextLocator1, ... TDbContextLocator8>:实体配置
  • EntityNotKey<TDbContextLocator1, ... TDbContextLocator8>:无键实体配置
  • IEntitySeedData<TEntity, TDbContextLocator1, ... TDbContextLocator8>:种子数据配置
  • IEntityTypeBuilder<TEntity, TDbContextLocator1, ... TDbContextLocator8>:实体类型构建器
  • IModelBuilderFilter<TDbContextLocator1, ... TDbContextLocator8>:模型构建筛选器
  • [QueryableFunction(DbContextLocators=Type[])]:查询函数

9.2.6 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-multi-database/index.html b/handbook/build/docs/dbcontext-multi-database/index.html index fc9636dfad6..e1aad77be10 100644 --- a/handbook/build/docs/dbcontext-multi-database/index.html +++ b/handbook/build/docs/dbcontext-multi-database/index.html @@ -4,22 +4,22 @@ -9.18 多数据库操作 | Fur - - - - - - - - - - - +9.18 多数据库操作 | Fur + + + + + + + + + + +
-

9.18 多数据库操作

9.18.1 Fur 支持数据库提供器

SqlServerSqliteCosmosInMemoryDatabaseMySqlPostgreSQLOracleFirebirdDm

9.18.1.1 数据库提供器对应包

  • SqlServerMicrosoft.EntityFrameworkCore.SqlServer
  • SqliteMicrosoft.EntityFrameworkCore.Sqlite
  • CosmosMicrosoft.EntityFrameworkCore.Cosmos
  • InMemoryDatabaseMicrosoft.EntityFrameworkCore.InMemory
  • MySqlPomelo.EntityFrameworkCore.MySql
  • PostgreSQLNpgsql.EntityFrameworkCore.PostgreSQL
  • OracleCitms.EntityFrameworkCore.Oracle
  • FirebirdFirebirdSql.EntityFrameworkCore.Firebird
  • DmMicrosoft.EntityFrameworkCore.Dm
小知识

这些数据库包应该安装在 Fur.EntityFramework.Core 层。

9.18.2 多数据库服务注册

// 注册 SqlServer
options.AddDbPool<FurDbContext>(DbProvider.SqlServer);
+

9.18 多数据库操作

9.18.1 Fur 支持数据库提供器

SqlServerSqliteCosmosInMemoryDatabaseMySqlPostgreSQLOracleFirebirdDm

9.18.1.1 数据库提供器对应包

  • SqlServerMicrosoft.EntityFrameworkCore.SqlServer
  • SqliteMicrosoft.EntityFrameworkCore.Sqlite
  • CosmosMicrosoft.EntityFrameworkCore.Cosmos
  • InMemoryDatabaseMicrosoft.EntityFrameworkCore.InMemory
  • MySqlPomelo.EntityFrameworkCore.MySql
  • PostgreSQLNpgsql.EntityFrameworkCore.PostgreSQL
  • OracleCitms.EntityFrameworkCore.Oracle
  • FirebirdFirebirdSql.EntityFrameworkCore.Firebird
  • DmMicrosoft.EntityFrameworkCore.Dm
小知识

这些数据库包应该安装在 Fur.EntityFramework.Core 层。

9.18.2 多数据库服务注册

// 注册 SqlServer
options.AddDbPool<FurDbContext>(DbProvider.SqlServer);
// 注册 Sqlite
options.AddDbPool<FurDbContext>(DbProvider.Sqlite);
// 注册 Cosmos
options.AddDbPool<FurDbContext>(DbProvider.Cosmos);
// 注册 InMemoryDatabase
options.AddDbPool<FurDbContext>(DbProvider.InMemoryDatabase);
@@ -36,17 +36,17 @@
// 切换到 MySql 操作 Person表
var mysqlRepository = sqlRepository.Change<MySqlDbContextLocator>();
// 切换到 Sqlite 操作 Person表
var sqliteRepository = sqlRepository.Change<SqliteDbContextLocator>();

9.18.3.4 实体定义方式

// 支持一个数据库
public class Person: IEntity<MySqlDbContextLocator>
{
// ....
}
-
// 支持多个数据库
public class Person: IEntity<MySqlDbContextLocator, SqliteDbContextLocator>
{
// ....
}
小知识

所有的 实体依赖接口或抽象类 都支持泛型方式 指定 数据库上下文定位器,最多支持 8 个。

9.18.3.5 Linq 函数方式

public static class QueryFunctions
{
[QueryableFunction("FN_GetId", "dbo", typeof(MySqlDbContextLocator), typeof(SqliteDbContextLocator))]
public static int GetId(int id) => throw new NotSupportedException();
}

9.18.4 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
// 支持多个数据库
public class Person: IEntity<MySqlDbContextLocator, SqliteDbContextLocator>
{
// ....
}
小知识

所有的 实体依赖接口或抽象类 都支持泛型方式 指定 数据库上下文定位器,最多支持 8 个。

9.18.3.5 Linq 函数方式

public static class QueryFunctions
{
[QueryableFunction("FN_GetId", "dbo", typeof(MySqlDbContextLocator), typeof(SqliteDbContextLocator))]
public static int GetId(int id) => throw new NotSupportedException();
}

9.18.4 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-proc/index.html b/handbook/build/docs/dbcontext-proc/index.html index 16e3dc5ea7e..5b6aebcfb15 100644 --- a/handbook/build/docs/dbcontext-proc/index.html +++ b/handbook/build/docs/dbcontext-proc/index.html @@ -4,22 +4,22 @@ -9.13 存储过程操作 | Fur - - - - - - - - - - - +9.13 存储过程操作 | Fur + + + + + + + + + + +
-

9.13 存储过程操作

温馨提示

推荐使用 《9.15 Sql 高级代理》代替本章节功能。Sql 高级代理 能够提供更容易且更易维护的方式。

9.13.1 关于存储过程

引用百度百科:

存储过程(Stored Procedure)是在大型数据库系统中,一组为了完成特定功能的 SQL 语句集,它存储在数据库中,一次编译后永久有效,用户通过指定存储过程的名字并给出参数(如果该存储过程带有参数)来执行它。

存储过程是数据库中的一个重要对象。在数据量特别庞大的情况下利用存储过程能达到倍速的效率提升。

简单来说,存储过程就是关系型数据库中(Sqlite 除外)中编写逻辑的函数/方法,通过这种方式,可以将 sql 编译缓存起来,大大提高存储过程的执行效率。

这里不讨论存储过程的优缺点。

9.13.1.1 支持存储过程的数据库

SqlServerSqliteCosmosInMemoryDatabaseMySqlPostgreSQLOracleFirebirdDm

9.13.2 存储过程使用

Fur 框架中提供了多种存储过程操作方式:

  • ISqlRepositorySql 操作仓储,可通过 依赖注入
  • ISqlDispatchProxySql 代理方式(高级用法,推荐)
  • 通过任意实体仓储操作:personRepository.SqlProcedureQuery(procName)
  • 通过字符串拓展方法:procName.SqlProcedureQuery()
  • 通过 repository.Sql().SqlProcedureQuery() 方式

9.13.2.1 初始化方式

using Fur.DatabaseAccessor;
using Fur.DynamicApiController;
+

9.13 存储过程操作

温馨提示

推荐使用 《9.15 Sql 高级代理》代替本章节功能。Sql 高级代理 能够提供更容易且更易维护的方式。

9.13.1 关于存储过程

引用百度百科:

存储过程(Stored Procedure)是在大型数据库系统中,一组为了完成特定功能的 SQL 语句集,它存储在数据库中,一次编译后永久有效,用户通过指定存储过程的名字并给出参数(如果该存储过程带有参数)来执行它。

存储过程是数据库中的一个重要对象。在数据量特别庞大的情况下利用存储过程能达到倍速的效率提升。

简单来说,存储过程就是关系型数据库中(Sqlite 除外)中编写逻辑的函数/方法,通过这种方式,可以将 sql 编译缓存起来,大大提高存储过程的执行效率。

这里不讨论存储过程的优缺点。

9.13.1.1 支持存储过程的数据库

SqlServerSqliteCosmosInMemoryDatabaseMySqlPostgreSQLOracleFirebirdDm

9.13.2 存储过程使用

Fur 框架中提供了多种存储过程操作方式:

  • ISqlRepositorySql 操作仓储,可通过 依赖注入
  • ISqlDispatchProxySql 代理方式(高级用法,推荐)
  • 通过任意实体仓储操作:personRepository.SqlProcedureQuery(procName)
  • 通过字符串拓展方法:procName.SqlProcedureQuery()
  • 通过 repository.Sql().SqlProcedureQuery() 方式

9.13.2.1 初始化方式

using Fur.DatabaseAccessor;
using Fur.DynamicApiController;
namespace Fur.Application
{
[DynamicApiController]
public class SqlService
{
private ISqlRepository _sqlRepository;
public SqlService(ISqlRepository sqlRepository)
{
_sqlRepository = sqlRepository;
}
}
}

9.13.2.2 返回 DataTable

// ISqlRepository 方法
var dataTable = _sqlRepository.SqlProcedureQuery("proc_GetPersons");
// ISqlDispatchProxy 方式
var dataTable = _sqlExecuteProxy.GetPersons(); // 推荐方式
// 实体仓储方式
var dataTable = _personRepository.SqlProcedureQuery("proc_GetPersons");
@@ -112,17 +112,17 @@
// IRepository 非泛型方式
ProcedureOutputResult<(List<Test>, List<Test>)> result = _repository.Sql().SqlProcedureOutput<(List<Test>, List<Test>)>("proc_Complex", new ProcOutputModel{});
// 变态懒人方式,直接通过存储过程名执行
ProcedureOutputResult<(List<Test>, List<Test>)> result = "proc_Complex".SqlProcedureOutput<(List<Test>, List<Test>)>(new ProcOutputModel{});
// 获取 OUTPUT 参数值
var outputs = result.OutputValues;
// 获取 RETURN 返回值
var reval = result.ReturnValue;
-
// 获取返回结果集
var (list1,list2) = result.Result;
关于异步

Fur 框架每一个数据库操作都支持异步方式,由于篇幅有限,就不列举异步方式了。

9.13.3 关于 [DbParameter]

[DbParameter] 特性是用来标注 Sql函数存储过程 参数的,可配置属性:

  • Direction:设置参数方向,ParameterDirection 枚举类型,默认 ParameterDirection.Input
  • DbType:设置参数类型,DbType 枚举类型,无默认
  • Size:设置参数长度的,int 类型

其中 Direction 属性是默认构造函数参数。

9.13.4 关于 ProcedureOutputResult

ProcedureOutputResultProcedureOutputResult<TResult> 是复杂存储过程执行返回模型类,有以下属性:

  • OutputValues:多个输出值,ProcedureOutputValue 类型
  • ReturnValue:返回值,object 类型
  • Result:结果集,非泛型版本是 DataSet类型,否则是 泛型类型

9.13.5 存储过程参数

所有 sql 参数都支持四种方式:

  • DbParameter[]:数组类型
  • new {}:匿名类型
  • new Class{}:强类型类型(支持复杂存储过程参数)
  • Dictionary<string,object> 类型

9.13.6 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
// 获取返回结果集
var (list1,list2) = result.Result;
关于异步

Fur 框架每一个数据库操作都支持异步方式,由于篇幅有限,就不列举异步方式了。

9.13.3 关于 [DbParameter]

[DbParameter] 特性是用来标注 Sql函数存储过程 参数的,可配置属性:

  • Direction:设置参数方向,ParameterDirection 枚举类型,默认 ParameterDirection.Input
  • DbType:设置参数类型,DbType 枚举类型,无默认
  • Size:设置参数长度的,int 类型

其中 Direction 属性是默认构造函数参数。

9.13.4 关于 ProcedureOutputResult

ProcedureOutputResultProcedureOutputResult<TResult> 是复杂存储过程执行返回模型类,有以下属性:

  • OutputValues:多个输出值,ProcedureOutputValue 类型
  • ReturnValue:返回值,object 类型
  • Result:结果集,非泛型版本是 DataSet类型,否则是 泛型类型

9.13.5 存储过程参数

所有 sql 参数都支持四种方式:

  • DbParameter[]:数组类型
  • new {}:匿名类型
  • new Class{}:强类型类型(支持复杂存储过程参数)
  • Dictionary<string,object> 类型

9.13.6 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-query/index.html b/handbook/build/docs/dbcontext-query/index.html index 50e9b436c24..c02ec0902bf 100644 --- a/handbook/build/docs/dbcontext-query/index.html +++ b/handbook/build/docs/dbcontext-query/index.html @@ -4,22 +4,22 @@ -9.10 查询操作 | Fur - - - - - - - - - - - +9.10 查询操作 | Fur + + + + + + + + + + +
-

9.10 查询操作

9.10.1 根据主键查询一条

// ==== 同步操作 ====
+

9.10 查询操作

9.10.1 根据主键查询一条

// ==== 同步操作 ====
// 示例一
var person = repository.Find(1);
// 示例二
var person = repository.FindOrDefault(1);
// 示例三
var person = repository.Entities.Find(1);
@@ -131,17 +131,17 @@
// 示例二
var sum = await repository.AsQueryable().AverageAsync(u => u.Cost);
// 示例三
var sum = await repository.DetachedEntities.AverageAsync(u => u.Cost);

9.10.6.7 时间查询

var starDate = DateTime.Parse("2020-09-10");
var endDate = DateTime.Parse("2020-09-10");
var query = repository.Where(u => u.CreatedDt >= starDate && u.CreatedDt <= endDate);

9.10.6.8 模糊查询

// 示例一
repository.Where(u => u.Name.StartWith("Fur"));
// 示例二
_testRepository.Where(u => u.Name.EndWith("Fur"));
-
// 示例三
_testRepository.Where(u => u.Name.Contains("Fur"));

9.10.6.9 Case When

数据库中的 Case When 实际上对应的是我们程序中的 三元表达式 ,也就是使用 三元表达式 即可自动生成 Case When 语句。

9.10.7 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
// 示例三
_testRepository.Where(u => u.Name.Contains("Fur"));

9.10.6.9 Case When

数据库中的 Case When 实际上对应的是我们程序中的 三元表达式 ,也就是使用 三元表达式 即可自动生成 Case When 语句。

9.10.7 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-read-write/index.html b/handbook/build/docs/dbcontext-read-write/index.html index 97b9f3de9fc..390b21a5e53 100644 --- a/handbook/build/docs/dbcontext-read-write/index.html +++ b/handbook/build/docs/dbcontext-read-write/index.html @@ -4,44 +4,44 @@ -9.26 读写分离/主从复制 | Fur - - - - - - - - - - - +9.26 读写分离/主从复制 | Fur + + + + + + + + + + +
-

9.26 读写分离/主从复制

9.26.1 读写分离

其实就是将数据库分为了主从库,一个主库用于写数据,多个从库完成读数据的操作,主从库之间通过某种机制进行数据的同步,是一种常见的数据库架构。

9.26.1.1 解决了什么问题

大多数互联网业务,往往读多写少,这时候,数据库的读会首先成为数据库的瓶颈,这时,如果我们希望能够线性的提升数据库的读性能,消除读写锁冲突从而提升数据库的写性能,那么就可以使用“分组架构”(读写分离架构)。

用一句话概括,读写分离是用来解决数据库的读性能瓶颈的。

9.26.1.2 注意事项

  • 数据库连接池要进行区分,哪些是读连接池,哪个是写连接池,研发的难度会增加;
  • 为了保证高可用,读连接池要能够实现故障自动转移;
  • 主从的一致性问题需要考虑。

9.26.2 如何实现

Fur 在数据库模块设计之初,就考虑了读写分离这种情况,所以从底层就支持动态切换数据库上下文及读写操作方法约束。

读写分离操作主要使用 IMSRepository 仓储,该仓储已经为开发者提供方便的操作调用。当然也可以不使用该仓储。

下面就给大家演示如何读写多库读写操作。

9.26.2.1 创建 主库 数据库上下文

using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
+

9.26 读写分离/主从复制

9.26.1 读写分离

其实就是将数据库分为了主从库,一个主库用于写数据,多个从库完成读数据的操作,主从库之间通过某种机制进行数据的同步,是一种常见的数据库架构。

9.26.1.1 解决了什么问题

大多数互联网业务,往往读多写少,这时候,数据库的读会首先成为数据库的瓶颈,这时,如果我们希望能够线性的提升数据库的读性能,消除读写锁冲突从而提升数据库的写性能,那么就可以使用“分组架构”(读写分离架构)。

用一句话概括,读写分离是用来解决数据库的读性能瓶颈的。

9.26.1.2 注意事项

  • 数据库连接池要进行区分,哪些是读连接池,哪个是写连接池,研发的难度会增加;
  • 为了保证高可用,读连接池要能够实现故障自动转移;
  • 主从的一致性问题需要考虑。

9.26.2 如何实现

Fur 在数据库模块设计之初,就考虑了读写分离这种情况,所以从底层就支持动态切换数据库上下文及读写操作方法约束。

读写分离操作主要使用 IMSRepository 仓储,该仓储已经为开发者提供方便的操作调用。当然也可以不使用该仓储。

下面就给大家演示如何读写多库读写操作。

9.26.2.1 创建 主库 数据库上下文

using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
namespace Fur.EntityFramework.Core
{
/// <summary>
/// 主库数据库上下文
/// </summary>
[AppDbContext("MasterConnectionString")]
public class MasterDbContext : AppDbContext<MasterDbContext>
{
public MasterDbContext(DbContextOptions<MasterDbContext> options) : base(options)
{
}
}
}

数据库连接字符串:

{
"ConnectionStrings": {
"MasterConnectionString": "Server=localhost;Database=Fur;User=sa;Password=000000;MultipleActiveResultSets=True;"
}
}

9.26.2.2 创建 从库 数据库上下文

using Fur.Core;
using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
namespace Fur.EntityFramework.Core
{
/// <summary>
/// 从库数据库上下文
/// </summary>
[AppDbContext("SlaveConnectionString")]
public class SlaveDbContext : AppDbContext<SlaveDbContext, SlaveDbContextLocator>
{
public SlaveDbContext(DbContextOptions<SlaveDbContext> options) : base(options)
{
}
}
}
特别注意

多数据库操作除了默认数据库无需自定义 数据库上下文定位器,其他数据库都需要有数据库上下文定位器。如 SlaveDbContextLocator

从库数据库上下文定位器:

using Fur.DatabaseAccessor;
namespace Fur.Core
{
/// <summary>
/// 从库数据库上下文定位器
/// </summary>
public class SlaveDbContextLocator : IDbContextLocator
{
}
}

数据库连接字符串:

{
"ConnectionStrings": {
"SlaveConnectionString": "Server=localhost;Database=FurSlave;User=sa;Password=000000;MultipleActiveResultSets=True;"
}
}

9.26.2.3 注册 主从库 数据库上下文

using Fur.Core;
using Microsoft.Extensions.DependencyInjection;
namespace Fur.EntityFramework.Core
{
[AppStartup(600)]
public sealed class FurEntityFrameworkCoreStartup : AppStartup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddDatabaseAccessor(options =>
{
services.AddSqlServerPool<MasterDbContext>();
services.AddSqlServerPool<SlaveDbContext, SlaveDbContextLocator>();
});
}
}
}

9.26.2.4 创建 Person 实体

由于 主从库 具有相同的数据库结构,所以实体也必须声明 主从库

using Fur.DatabaseAccessor;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Fur.Core
{
public class Person : IEntity<MasterDbContextLocator, SlaveDbContextLocator>
{
/// <summary>
/// 主键Id
/// </summary>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
-
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
}
}

9.26.2.5 将 Person 转换成数据库表

创建主库数据库表:

Add-Migration v0.0.1 -Context MasterDbContext
Update-Database -Context MasterDbContext

创建从库数据库表:

Add-Migration v0.0.1 -Context SlaveDbContext
Update-Database -Context SlaveDbContext

9.26.2.6 使用例子

using Fur.Core;
using Fur.DatabaseAccessor;
using Fur.DynamicApiController;
using System.Collections.Generic;
+
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
}
}

9.26.2.5 将 Person 转换成数据库表

创建主库数据库表:

Add-Migration v0.0.1 -Context MasterDbContext
Update-Database -Context MasterDbContext

创建从库数据库表:

Add-Migration v0.0.1 -Context SlaveDbContext
Update-Database -Context SlaveDbContext

9.26.2.6 使用例子

using Fur.Core;
using Fur.DatabaseAccessor;
using Fur.DynamicApiController;
using System.Collections.Generic;
namespace Fur.Application
{
public class PersonService : IDynamicApiController
{
/// <summary>
/// 可调配仓储(读写分离)
/// </summary>
private readonly IMSRepository<MasterDbContextLocator, SlaveDbContextLocator> _msRepository;
/// <summary>
/// 构造函数初始化
/// </summary>
/// <param name="msRepository"></param>
public PersonService(IMSRepository<MasterDbContextLocator, SlaveDbContextLocator> msRepository)
{
_msRepository = msRepository;
}
/// <summary>
/// 新增走主库
/// </summary>
/// <param name="person"></param>
/// <returns></returns>
public void Insert(Person person)
{
_msRepository.Master<Person>().Insert(person);
}
/// <summary>
/// 查询走从库
/// </summary>
/// <returns></returns>
public List<Person> Get()
{
return _msRepository.Slave1<Person>().AsEnumerable();
}
}
}

9.26.3 主从复制

主从复制:是一种数据备份的方案。

简单来说,是使用两个或两个以上相同的数据库,将一个数据库当做主数据库,而另一个数据库当做从数据库。在主数据库中进行相应操作时,从数据库记录下所有主数据库的操作,使其二者一模一样。

9.26.4 主从复制几种方式

9.26.4.1 同步复制

所谓的同步复制,意思是 Master 的变化,必须等待 Slave-1,Slave-2,...,Slave-n 完成后才能返回。 -这样,显然不可取,比如,在 Web 前端页面上,用户增加了条记录,需要等待很长时间。

9.26.4.2 异步复制

如同 AJAX 请求一样。Master 只需要完成自己的数据库操作即可。至于 Slaves 是否收到二进制日志,是否完成操作,不用关心。(推荐方式)

9.26.4.3 半同步复制

Master 只保证 Slaves 中的一个操作成功,就返回,其他 Slave 不管。

下面将使用 SqlServer 简单配置主从复制功能。

9.26.5 SqlServer 主库配置

9.26.5.1 添加 本地发布

9.26.5.2 选择 分发服务器

9.26.5.3 启用 代理

9.26.5.4 发布数据库

9.26.5.5 快照发布

具体选择何种发布类型,视具体业务场景而定。

9.26.5.6 选择发布项目

9.26.5.7 配置分发计划

9.26.5.8 配置安全设置

9.26.5.9 完成配置

9.26.6 SqlServer 从库配置

9.26.6.1 添加 本地订阅

9.26.6.2 选择 分发服务器

9.26.6.3 选择 分发代理位置

9.26.6.4 选择 订阅数据库

9.26.6.5 选择 分发安全设置

9.26.6.6 选择 同步计划

9.26.6.7 完成订阅

9.26.7 分发定义监视

9.26.8 查看主从复制结果

特别特性

主从复制有一定迟延性,所以系统设计要有一定“容忍性"。

9.26.9 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +这样,显然不可取,比如,在 Web 前端页面上,用户增加了条记录,需要等待很长时间。

9.26.4.2 异步复制

如同 AJAX 请求一样。Master 只需要完成自己的数据库操作即可。至于 Slaves 是否收到二进制日志,是否完成操作,不用关心。(推荐方式)

9.26.4.3 半同步复制

Master 只保证 Slaves 中的一个操作成功,就返回,其他 Slave 不管。

下面将使用 SqlServer 简单配置主从复制功能。

9.26.5 SqlServer 主库配置

9.26.5.1 添加 本地发布

9.26.5.2 选择 分发服务器

9.26.5.3 启用 代理

9.26.5.4 发布数据库

9.26.5.5 快照发布

具体选择何种发布类型,视具体业务场景而定。

9.26.5.6 选择发布项目

9.26.5.7 配置分发计划

9.26.5.8 配置安全设置

9.26.5.9 完成配置

9.26.6 SqlServer 从库配置

9.26.6.1 添加 本地订阅

9.26.6.2 选择 分发服务器

9.26.6.3 选择 分发代理位置

9.26.6.4 选择 订阅数据库

9.26.6.5 选择 分发安全设置

9.26.6.6 选择 同步计划

9.26.6.7 完成订阅

9.26.7 分发定义监视

9.26.8 查看主从复制结果

特别特性

主从复制有一定迟延性,所以系统设计要有一定“容忍性"。

9.26.9 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-repository/index.html b/handbook/build/docs/dbcontext-repository/index.html index 4a8556a6398..7792b85f736 100644 --- a/handbook/build/docs/dbcontext-repository/index.html +++ b/handbook/build/docs/dbcontext-repository/index.html @@ -4,39 +4,39 @@ -9.4 仓储模式 | Fur - - - - - - - - - - - +9.4 仓储模式 | Fur + + + + + + + + + + +
-

9.4 仓储模式

9.4.1 什么是仓储

在领域层和数据映射层的中介,使用类似集合的接口来存取领域对象,实际上,仓储被用于领域对象在数据库上的操作(实体 Entity 和值对象 Value types)。一般来说,我们针对不同的实体(或聚合根 Aggregate Root)会创建相对应的仓储。

简单来说,仓储就是数据存取操作的载体,但不限定于数据库。

9.4.1 内置仓储

Fur 框架内置了一个数据库操作的仓储,方便大家拓展和集成:

9.4.1.1 非泛型超级仓储

  • IRepository:默认非泛型仓储接口,支持切换到任何仓储
  • EFCoreRepository:默认非泛型仓储实现

9.4.1.2 泛型实体仓储

  • IRepository<TEntity>:默认数据库实体仓储接口
  • EFCoreRepository<TEntity>:默认数据库实体仓储实现

9.4.1.3 泛型多数据库实体仓储

  • IRepository<TEntity, TDbContextLocator>:任意数据库的实体仓储接口
  • EFCoreRepository<TEntity, TDbContextLocator>:任意数据库的实体仓储实现

9.4.1.4 Sql 操作仓储

  • ISqlRepository:默认数据库 Sql 操作仓储接口
  • SqlRepository:默认数据库 Sql 操作仓储实现

9.4.1.5 多数据库 Sql 操作仓储

  • ISqlRepository<TDbContextLocator>:任意数据库的 Sql 操作仓储接口
  • SqlRepository<TDbContextLocator>:任意数据库的 Sql 操作仓储实现

9.4.1.6 只读实体仓储(支持多库)

  • IReadableRepository<TEntity>:默认数据库只读实体仓储接口
  • IReadableRepository<TEntity, TDbContextLocator>:多数据库只读实体仓储实现

9.4.1.7 只写实体仓储(支持多库)

  • IWritableRepository<TEntity>:默认数据库只写实体仓储接口
  • IWritableRepository<TEntity, TDbContextLocator>:多数据库只写实体仓储实现

9.4.1.8 只允许新增实体仓储(支持多库)

  • IInsertableRepository<TEntity>:默认数据库只允许新增的实体仓储接口
  • IInsertableRepository<TEntity, TDbContextLocator>:多数据库只允许新增的实体仓储实现

9.4.1.9 只允许更新实体仓储(支持多库)

  • IUpdateableRepository<TEntity>:默认数据库只允许更新的实体仓储接口
  • IUpdateableRepository<TEntity, TDbContextLocator>:多数据库只允许更新的实体仓储实现

9.4.1.10 只允许删除实体仓储(支持多库)

  • IDeletableRepository<TEntity>:默认数据库只允许删除的实体仓储接口
  • IDeletableRepository<TEntity, TDbContextLocator>:多数据库只允许删除的实体仓储实现

9.4.1.11 只允许拓展操作实体仓储(支持多库)

  • IOperableRepository<TEntity>:默认数据库只允许拓展操作实体仓储接口
  • IOperableRepository<TEntity, TDbContextLocator>:多数据库只允许拓展操作实体仓储实现

9.4.1.12 只允许 Sql 查询仓储(支持多库)

  • ISqlReaderRepository:默认数据库只允许 Sql 查询仓储接口
  • ISqlReaderRepository<TDbContextLocator>:多数据库只允许 Sql 查询仓储实现

9.4.1.13 只允许 Sql 非查询仓储(支持多库)

  • ISqlExecutableRepository:默认数据库只允许 Sql 非查询仓储接口
  • ISqlExecutableRepository<TDbContextLocator>:多数据库只允许 Sql 非查询仓储实现

9.4.1.14 读写分离仓储

  • IMSRepository:最多支持 一主7从 仓储

9.4.2 仓储使用

Fur 提供了非常多的方式创建仓储,目的是为了让大家可以在不同的场景中使用。

9.4.2.1 构造函数注入

private readonly IRepository<Person> _personRepository;
public FurService(IRepository<Person> personRepository)
{
_personRepository = personRepository;
}

9.4.2.2 方法参数注入

public async Task<List<PersonDto>> GetAll([FromServices] IRepository<Person> repository, string keyword)
{
var persons = await repository.AsQueryable().ToListAsync();
return persons.Adapt<List<PersonDto>>();
}

9.4.2.3 Db.GetRepository 获取

// 非泛型仓储
var repository = Db.GetRepository();
+

9.4 仓储模式

9.4.1 什么是仓储

在领域层和数据映射层的中介,使用类似集合的接口来存取领域对象,实际上,仓储被用于领域对象在数据库上的操作(实体 Entity 和值对象 Value types)。一般来说,我们针对不同的实体(或聚合根 Aggregate Root)会创建相对应的仓储。

简单来说,仓储就是数据存取操作的载体,但不限定于数据库。

9.4.1 内置仓储

Fur 框架内置了一个数据库操作的仓储,方便大家拓展和集成:

9.4.1.1 非泛型超级仓储

  • IRepository:默认非泛型仓储接口,支持切换到任何仓储
  • EFCoreRepository:默认非泛型仓储实现

9.4.1.2 泛型实体仓储

  • IRepository<TEntity>:默认数据库实体仓储接口
  • EFCoreRepository<TEntity>:默认数据库实体仓储实现

9.4.1.3 泛型多数据库实体仓储

  • IRepository<TEntity, TDbContextLocator>:任意数据库的实体仓储接口
  • EFCoreRepository<TEntity, TDbContextLocator>:任意数据库的实体仓储实现

9.4.1.4 Sql 操作仓储

  • ISqlRepository:默认数据库 Sql 操作仓储接口
  • SqlRepository:默认数据库 Sql 操作仓储实现

9.4.1.5 多数据库 Sql 操作仓储

  • ISqlRepository<TDbContextLocator>:任意数据库的 Sql 操作仓储接口
  • SqlRepository<TDbContextLocator>:任意数据库的 Sql 操作仓储实现

9.4.1.6 只读实体仓储(支持多库)

  • IReadableRepository<TEntity>:默认数据库只读实体仓储接口
  • IReadableRepository<TEntity, TDbContextLocator>:多数据库只读实体仓储实现

9.4.1.7 只写实体仓储(支持多库)

  • IWritableRepository<TEntity>:默认数据库只写实体仓储接口
  • IWritableRepository<TEntity, TDbContextLocator>:多数据库只写实体仓储实现

9.4.1.8 只允许新增实体仓储(支持多库)

  • IInsertableRepository<TEntity>:默认数据库只允许新增的实体仓储接口
  • IInsertableRepository<TEntity, TDbContextLocator>:多数据库只允许新增的实体仓储实现

9.4.1.9 只允许更新实体仓储(支持多库)

  • IUpdateableRepository<TEntity>:默认数据库只允许更新的实体仓储接口
  • IUpdateableRepository<TEntity, TDbContextLocator>:多数据库只允许更新的实体仓储实现

9.4.1.10 只允许删除实体仓储(支持多库)

  • IDeletableRepository<TEntity>:默认数据库只允许删除的实体仓储接口
  • IDeletableRepository<TEntity, TDbContextLocator>:多数据库只允许删除的实体仓储实现

9.4.1.11 只允许拓展操作实体仓储(支持多库)

  • IOperableRepository<TEntity>:默认数据库只允许拓展操作实体仓储接口
  • IOperableRepository<TEntity, TDbContextLocator>:多数据库只允许拓展操作实体仓储实现

9.4.1.12 只允许 Sql 查询仓储(支持多库)

  • ISqlReaderRepository:默认数据库只允许 Sql 查询仓储接口
  • ISqlReaderRepository<TDbContextLocator>:多数据库只允许 Sql 查询仓储实现

9.4.1.13 只允许 Sql 非查询仓储(支持多库)

  • ISqlExecutableRepository:默认数据库只允许 Sql 非查询仓储接口
  • ISqlExecutableRepository<TDbContextLocator>:多数据库只允许 Sql 非查询仓储实现

9.4.1.14 读写分离仓储

  • IMSRepository:最多支持 一主7从 仓储

9.4.2 仓储使用

Fur 提供了非常多的方式创建仓储,目的是为了让大家可以在不同的场景中使用。

9.4.2.1 构造函数注入

private readonly IRepository<Person> _personRepository;
public FurService(IRepository<Person> personRepository)
{
_personRepository = personRepository;
}

9.4.2.2 方法参数注入

public async Task<List<PersonDto>> GetAll([FromServices] IRepository<Person> repository, string keyword)
{
var persons = await repository.AsQueryable().ToListAsync();
return persons.Adapt<List<PersonDto>>();
}

9.4.2.3 Db.GetRepository 获取

// 非泛型仓储
var repository = Db.GetRepository();
// 泛型仓储
var repository = Db.GetRepository<Person>();
// Sql 仓储
var sqlRepository = Db.GetSqlRepository();
特别说明

不管采用那种方式,Fur 都保证了仓储一次请求唯一性。同时 Db.GetRepository<TEntity>() 方式支持任何静态类中使用。

9.4.3 仓储高级用法

9.4.3.1 动态切换实体仓储

var userRepository = personRepository.Change<User>();

9.4.3.2 动态切换仓储类型

比如,读写分离/主从库仓储:

// 只读仓储
var readRepository = personRepository.Constraint<IReadableRepository<User>>();
// 只写仓储
var readRepository = personRepository.Constraint<IWritableRepository<User>>();
小知识

.Constraint 支持切换任何仓储类型。

9.4.3.3 获取 Sql 操作仓储

var sqlRepository = repository.Sql();

9.4.4 多数据库操作

Fur 通过 DbContextLocator 数据库上下文定位器实现多种数据库操作,可以随意切换数据库

9.4.4.1 动态切换多个数据库

动态切换数据库

// 切换到 MSSQL 操作 Person表
var mssqlRepository = repository.Change<Person, MsSqlDbContextLocator>();
// 切换到 MySql 操作 Person表
var mysqlRepository = repository.Change<Person, MySqlDbContextLocator>();
// 切换到 Sqlite 操作 Person表
var sqliteRepository = repository.Change<Person, SqliteDbContextLocator>();
// 其他更多数据库一样的操作

另外任何仓储或实体配置都支持多个数据库同时操作

仓储方式

IRepository<Person, MsSqlDbContextLocator> mssqlRepository
-
ISqlRepository<MsSqlDbContextLocator> mssqlRepository;

动态 sql 方式

"select * from person".Change<MsSqlDbContextLocator>().SqlQuery();

实体配置方式

public class User:Entity<MsSqlDbContextLocator, MySqlDbContextLocator>
{
}

Sql 代理方式

[SqlFunction("funcName", DbContextLocator = typeof(MySqlDbContextLocator))]
int GetAge(int id);

Linq 中方式

[QueryableFunction("funcName","dbo", DbContextLocator = typeof(MySqlDbContextLocator))]
string GetName()=> throw Oops.Oh("不支持该数据库操作");

9.4.5 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
ISqlRepository<MsSqlDbContextLocator> mssqlRepository;

动态 sql 方式

"select * from person".Change<MsSqlDbContextLocator>().SqlQuery();

实体配置方式

public class User:Entity<MsSqlDbContextLocator, MySqlDbContextLocator>
{
}

Sql 代理方式

[SqlFunction("funcName", DbContextLocator = typeof(MySqlDbContextLocator))]
int GetAge(int id);

Linq 中方式

[QueryableFunction("funcName","dbo", DbContextLocator = typeof(MySqlDbContextLocator))]
string GetName()=> throw Oops.Oh("不支持该数据库操作");

9.4.5 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-seed-data/index.html b/handbook/build/docs/dbcontext-seed-data/index.html index 4754a5e356b..a0633553466 100644 --- a/handbook/build/docs/dbcontext-seed-data/index.html +++ b/handbook/build/docs/dbcontext-seed-data/index.html @@ -4,38 +4,38 @@ -9.21 实体种子数据 | Fur - - - - - - - - - - - +9.21 实体种子数据 | Fur + + + + + + + + + + +
-

9.21 实体种子数据

9.21.1 什么是种子数据

Fur 框架种,种子数据通常指的是通过程序为数据库预先设置一些初始化数据,比如我们的数据字典表,我们可能希望在系统构建初期就自动将一些规范化数据保存到数据库中。

如性别:男/女,地区,行业信息等等。

9.21.2 如何配置

Fur 提供非常灵活方便的 IEntitySeedData<TEntity> 依赖接口可以快速的构建种子数据,支持任何无参构造函数对象类中使用。如我们需要为 Person 表插入初始化数据:

9.21.2.1 在实体定义中使用

using Fur.DatabaseAccessor;
using System;
using System.Collections.Generic;
+

9.21 实体种子数据

9.21.1 什么是种子数据

Fur 框架种,种子数据通常指的是通过程序为数据库预先设置一些初始化数据,比如我们的数据字典表,我们可能希望在系统构建初期就自动将一些规范化数据保存到数据库中。

如性别:男/女,地区,行业信息等等。

9.21.2 如何配置

Fur 提供非常灵活方便的 IEntitySeedData<TEntity> 依赖接口可以快速的构建种子数据,支持任何无参构造函数对象类中使用。如我们需要为 Person 表插入初始化数据:

9.21.2.1 在实体定义中使用

using Fur.DatabaseAccessor;
using System;
using System.Collections.Generic;
namespace Fur.Core
{
public class Person : EntityBase, IEntitySeedData<Person>
{
public string Name { get; set; }
public int Age { get; set; }
public string Address { get; set; }
// 配置种子数据
public IEnumerable<Person> HasData(DbContext dbContext, Type dbContextLocator)
{
return new List<Person>
{
new Person { Id = 1, Name = "百小僧", Address = "广东省中山市" },
new Person { Id = 2, Name = "新生帝", Address = "广东省珠海市" }
};
}
}
}
特别注意

主键 值必须手动插入,因为会自动关闭主键或自增标识检查。

9.21.2.2 在任意对象类中使用

using Fur.DatabaseAccessor;
using System.Collections.Generic;
namespace Fur.Application
{
public class PersonSeedData : IEntitySeedData<Person>
{
// 配置种子数据
public IEnumerable<Person> HasData(DbContext dbContext, Type dbContextLocator)
{
return new List<Person>
{
new Person { Id = 1, Name = "百小僧", Address = "广东省中山市" },
new Person { Id = 2, Name = "新生帝", Address = "广东省珠海市" }
};
}
}
}

9.21.3 导航属性

通常我们的实体有 一对多多对多等外键关系,那么我们需要单独为每一个实体添加数据种子,而不是直接写在主表中。

9.21.4 多个数据库种子数据

Fur 提供泛型的方式支持多个数据库种子数据设定,如:

using Fur.DatabaseAccessor;
using System.Collections.Generic;
-
namespace Fur.Application
{
public class PersonSeedData : IEntitySeedData<Person, MySqlDbContextLocator, SqliteDbContextLocator>
{
// 配置种子数据
public IEnumerable<Person> HasData(DbContext dbContext, Type dbContextLocator)
{
return new List<Person>
{
new Person { Id = 1, Name = "百小僧", Address = "广东省中山市" },
new Person { Id = 2, Name = "新生帝", Address = "广东省珠海市" }
};
}
}
}

上面的例子表示同时为 MySqlDbContextSqliteDbContext 创建种子数据。

9.21.5 反馈与建议

与我们交流

给 Fur 提 Issue


了解更多

想了解更多 数据种子 知识可查阅 EF Core - 数据种子设定 章节。

- - - - - - - - - - - +
namespace Fur.Application
{
public class PersonSeedData : IEntitySeedData<Person, MySqlDbContextLocator, SqliteDbContextLocator>
{
// 配置种子数据
public IEnumerable<Person> HasData(DbContext dbContext, Type dbContextLocator)
{
return new List<Person>
{
new Person { Id = 1, Name = "百小僧", Address = "广东省中山市" },
new Person { Id = 2, Name = "新生帝", Address = "广东省珠海市" }
};
}
}
}

上面的例子表示同时为 MySqlDbContextSqliteDbContext 创建种子数据。

9.21.5 反馈与建议

与我们交流

给 Fur 提 Issue


了解更多

想了解更多 数据种子 知识可查阅 EF Core - 数据种子设定 章节。

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-sql-proxy/index.html b/handbook/build/docs/dbcontext-sql-proxy/index.html index face45ec0e4..d3883086103 100644 --- a/handbook/build/docs/dbcontext-sql-proxy/index.html +++ b/handbook/build/docs/dbcontext-sql-proxy/index.html @@ -4,22 +4,22 @@ -9.17 Sql 高级代理 | Fur - - - - - - - - - - - +9.17 Sql 高级代理 | Fur + + + + + + + + + + +
-

9.17 Sql 高级代理

9.17.1 关于 Sql 代理

Sql 代理是 Fur 框架中对 Sql 操作一个非常重要的概念,通过这种方式可以大大提高 Sql 书写效率,而且后期极易维护。

Sql 代理属于 Fur 框架中一个高级功能。

9.17.2 了解 ISqlDispatchProxy

ISqlDispatchProxy 接口是 Fur 实现被代理接口的唯一依赖,任何公开的接口一旦集成了 ISqlDispatchProxy 接口,那么这个接口就是被托管拦截Sql 操作接口。

简单定义一个 Sql 代理接口

using Fur.DatabaseAccessor;
+

9.17 Sql 高级代理

9.17.1 关于 Sql 代理

Sql 代理是 Fur 框架中对 Sql 操作一个非常重要的概念,通过这种方式可以大大提高 Sql 书写效率,而且后期极易维护。

Sql 代理属于 Fur 框架中一个高级功能。

9.17.2 了解 ISqlDispatchProxy

ISqlDispatchProxy 接口是 Fur 实现被代理接口的唯一依赖,任何公开的接口一旦集成了 ISqlDispatchProxy 接口,那么这个接口就是被托管拦截Sql 操作接口。

简单定义一个 Sql 代理接口

using Fur.DatabaseAccessor;
namespace Fur.Application
{
public interface ISql : ISqlDispatchProxy
{
}
}

一旦这个接口继承了 ISqlDispatchProxy,那么它就会动态创建接口实例,而且支持依赖注入/控制反转获取实例

9.17.3 开始领略 Sql 代理

下面我讲通过多个例子来演示 Sql 代理的用法,为什么推荐这种方式操作 Sql

支持各种方式获取实例:

9.17.3.1 构造函数方式

private readonly Isql _sql;
public FurService(Isql sql)
{
_sql = sql;
}

9.17.3.2 方法参数注入

public async Task<List<PersonDto>> GetAll([FromServices] Isql, string keyword)
{
}

9.17.3.3 App.GetSqlDispatchProxy<ISql>()

var sql = App.GetSqlDispatchProxy<ISql>();

9.17.4 Sql 操作

9.17.4.1 返回 DataTable

using Fur.DatabaseAccessor;
namespace Fur.Application
{
public interface ISql : ISqlDispatchProxy
{
// 执行sql并传入参数,基元类型
[SqlExecute("select * from person where id >@id and name like %@name%")]
DataTable GetPerson(int id, string name);
// 执行sql并传入参数,对象类型
[SqlExecute("select * from person where id >@id and name like %@name%")]
DataTable GetPerson(MyParam paras));
@@ -69,17 +69,17 @@
[SqlProcedure("PROC_Name")]
ProcedureOutputResult GetOutput(ProcOutputModel pams);
[SqlProcedure("PROC_Name")]
ProcedureOutputResult<(List<Person>, List<Student>)> GetOutput(ProcOutputModel pams);
}
}

9.17.5 函数 操作

using Fur.DatabaseAccessor;
namespace Fur.Application
{
public interface ISql : ISqlDispatchProxy
{
[SqlFunction("FN_Name")] // 标量函数
string GetValue(MyParam dto);
-
[SqlProcedure("FN_Name")] // 表值函数
List<Person> GetPersons(int id);
}
}
补充说明

Sql 代理会自动判断返回值然后自动执行特定函数类型。

9.17.6 为什么用它?

通过上面的例子大家就可以了解,这种方式操作 sql 非常简单,而且极易维护。大家不用去关系返回值,关心用哪个方法,所有东西会自动给你处理好。

所以,如果需要用 Sql 操作,推荐使用 Sql 高级代理。

9.17.7 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
[SqlProcedure("FN_Name")] // 表值函数
List<Person> GetPersons(int id);
}
}
补充说明

Sql 代理会自动判断返回值然后自动执行特定函数类型。

9.17.6 为什么用它?

通过上面的例子大家就可以了解,这种方式操作 sql 非常简单,而且极易维护。大家不用去关系返回值,关心用哪个方法,所有东西会自动给你处理好。

所以,如果需要用 Sql 操作,推荐使用 Sql 高级代理。

9.17.7 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-sql-template/index.html b/handbook/build/docs/dbcontext-sql-template/index.html index ded0cc234ac..70233683fb7 100644 --- a/handbook/build/docs/dbcontext-sql-template/index.html +++ b/handbook/build/docs/dbcontext-sql-template/index.html @@ -4,34 +4,34 @@ -9.16 Sql 模板 | Fur - - - - - - - - - - - +9.16 Sql 模板 | Fur + + + + + + + + + + +
-

9.16 Sql 模板

9.16.1 Sql 模板

通常我们程序中执行数据库的 sql 语句都写在了程序集中,随程序一起编译,后续需要修改,则重新编译代码。

所以,Fur 创造出一种 Sql 模板的方式,程序执行 Sql 时,只需要使用特殊标记即可:#(模板Key),这些真实的 Sql 配置在 .json.xml 配置文件中。

如:

  • Json 方式
{
"Select.User": "select * from User where id > @id"
}
  • Xml 方式
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<Select.User>select * from User where id > @id</Select.User>
</configuration>

9.16.2 Sql 模板优缺点

9.16.2.1 优点

  • 支持 Sql 动态配置,可在程序运行时动态调配 Sql 语句
  • 支持程序 Sql 语句加密

9.16.2.2 缺点

  • 需增加对应配置文件
  • 不容易调试 Sql 代码

9.16.3 如何使用

在执行 Sql 的时候,只需要填写指定模板即可。

9.16.3.1 常规使用

// 仓储方式
var users = repository.SqlQuery<User>("#(Select.User)", new { id = 1});
+

9.16 Sql 模板

9.16.1 Sql 模板

通常我们程序中执行数据库的 sql 语句都写在了程序集中,随程序一起编译,后续需要修改,则重新编译代码。

所以,Fur 创造出一种 Sql 模板的方式,程序执行 Sql 时,只需要使用特殊标记即可:#(模板Key),这些真实的 Sql 配置在 .json.xml 配置文件中。

如:

  • Json 方式
{
"Select.User": "select * from User where id > @id"
}
  • Xml 方式
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<Select.User>select * from User where id > @id</Select.User>
</configuration>

9.16.2 Sql 模板优缺点

9.16.2.1 优点

  • 支持 Sql 动态配置,可在程序运行时动态调配 Sql 语句
  • 支持程序 Sql 语句加密

9.16.2.2 缺点

  • 需增加对应配置文件
  • 不容易调试 Sql 代码

9.16.3 如何使用

在执行 Sql 的时候,只需要填写指定模板即可。

9.16.3.1 常规使用

// 仓储方式
var users = repository.SqlQuery<User>("#(Select.User)", new { id = 1});
// 懒人方式
var users = "#(Select.User)".SqlQuery<User>(new { id = 1});
-
// Sql 代理方式
[SqlExecute("#(Select.User)")]
List<User> GetUser(int id);

9.16.3.2 高级嵌套

var users = repository.SqlQuery<User>(
@"select * from user u
left join #(User.Detail) d on u.Id = d.UserId
where id > @id");

9.16.4 Sql 模板配置

9.16.4.1 普通模式

{
"Select.User": "select * from User"
}

9.16.4.2 更多配置

{
"Select.User": {
"Sql": "select * from User where id > @id and Name = @name",
"Params": [
{
"Name": " Id",
"Value": "1",
"DbType": "Int16",
"Size": 10
},
{
"Name": " Name",
"Value": "百小僧",
"DbType": "String",
"Size": 10
}
]
}
}

9.16.5 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
// Sql 代理方式
[SqlExecute("#(Select.User)")]
List<User> GetUser(int id);

9.16.3.2 高级嵌套

var users = repository.SqlQuery<User>(
@"select * from user u
left join #(User.Detail) d on u.Id = d.UserId
where id > @id");

9.16.4 Sql 模板配置

9.16.4.1 普通模式

{
"Select.User": "select * from User"
}

9.16.4.2 更多配置

{
"Select.User": {
"Sql": "select * from User where id > @id and Name = @name",
"Params": [
{
"Name": " Id",
"Value": "1",
"DbType": "Int16",
"Size": 10
},
{
"Name": " Name",
"Value": "百小僧",
"DbType": "String",
"Size": 10
}
]
}
}

9.16.5 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-sql/index.html b/handbook/build/docs/dbcontext-sql/index.html index 463d7a33839..391dd42361b 100644 --- a/handbook/build/docs/dbcontext-sql/index.html +++ b/handbook/build/docs/dbcontext-sql/index.html @@ -4,22 +4,22 @@ -9.15 Sql 操作 | Fur - - - - - - - - - - - +9.15 Sql 操作 | Fur + + + + + + + + + + +
-

9.15 Sql 操作

温馨提示

推荐使用 《9.15 Sql 高级代理》代替本章节功能。Sql 高级代理 能够提供更容易且更易维护的方式。

9.15.1 关于 Sql

Fur 框架提供非常多且灵活的 sql 操作方法,且性能不输于 dapper,同时逼近 ADO.NET 原生操作。

9.15.2 懒人无敌 Sql 🐮

9.15.2.1 返回 DataTable

// ==== 同步操作 ====
+

9.15 Sql 操作

温馨提示

推荐使用 《9.15 Sql 高级代理》代替本章节功能。Sql 高级代理 能够提供更容易且更易维护的方式。

9.15.1 关于 Sql

Fur 框架提供非常多且灵活的 sql 操作方法,且性能不输于 dapper,同时逼近 ADO.NET 原生操作。

9.15.2 懒人无敌 Sql 🐮

9.15.2.1 返回 DataTable

// ==== 同步操作 ====
// 示例一
var dataTable = "select * from person".SqlQuery();
// 示例二
var dataTable = "select top 10 * from person where id > @id".SqlQuery(new {id = 10});
// 示例三
var dataTable = "select Id, Name, Age from person where name like %@name%".SqlQuery(new Dictionary<string,object>{ {"name", "Fur"} });
@@ -166,17 +166,17 @@
// 示例四
var persons = sqlRepository.SqlQuery<Person>("select * from person");
// 示例五
var persons = sqlRepository.SqlQuery<Person>("select * from person where id > @id", new { id = 10});
// 不再举例子。。。。。。
补充说明

不管是那种方式操作 Sql ,方法名参数都是一致的,如:

  • SqlQuery
  • SqlQueryAsync
  • SqlQueries
  • SqlQueriesAsync
  • SqlNonQuery
  • SqlNonQueryAsync
  • SqlScalar
  • SqlScalarAsync
  • SqlProcedureQuery
  • SqlProcedureQueryAsync
  • SqlProcedureQueries
  • SqlProcedureQueriesAsync
  • SqlProcedureScalar
  • SqlProcedureScalarAsync
  • SqlProcedureNonQuery
  • SqlProcedureNonQueryAsync
  • SqlProcedureOutput
  • SqlProcedureOutputAsync
  • SqlFunctionScalar
  • SqlFunctionScalarAsync
  • SqlFunctionQuery
  • SqlFunctionQuery

9.15.6 IRepository 操作

IRepository 也能操作 sql,调用方法也是和上面一致的,如:

var dataTable = repository.Sql().SqlQuery("select * from person");
特别说明

由于篇幅有限,不再列举所有例子。

9.15.7 IRepository<TEntity> 操作

IRepository<TEntity> 也能操作 sql,调用方法也是和上面一致的,如:

var dataTable = personRepository.SqlQuery("select * from person");
特别说明

由于篇幅有限,不再列举所有例子。

9.15.8 关于 Sql 参数

所有 sql存储过程函数 参数都支持四种方式:

  • DbParameter[]:数组类型
  • new {}:匿名类型
  • new Class{}:强类型类型(支持复杂存储过程参数)
  • Dictionary<string,object> 类型
小知识

建议除了复杂的存储过程(带 OUTPUT/RETURN)的以外,所有参数建议使用 new {} 匿名类型,如果需要动态参数,则可以使用 Dictionary<string,object> 类型。

9.15.9 多数据库 Sql 操作 💯 💛

Fur 框架拥有非常灵活的多数据库操作方式,只需通过多数据库上下文定位器即可动态切换数据库。

9.15.9.1 懒人无敌 🐮 方式

var dataTable = "select * from person".Change<MySqlDbContextLocator>().SqlQuery();
-
var persons = "select * from person whre id > @id".Change<SqliteDbContextLocator>().SqlQuery<Person>();
补充说明

懒人方式 只需要通过 Change<TDbContextLocator> 方式即可动态切换数据库。

9.15.9.2 ISqlRepository 方式

只需要通过 ISqlRepository<TDbContextLocator> 注入或通过 sqlRepository.Change<TDbContextLocator>() 切换。

9.15.9.3 IRepository 方式

只需要通过 repository.Change<TDbContextLocator>() 获取即可。

9.15.9.4 IRepository<TEntity> 方式

只需要通过 IRepository<TEntity, TDbContextLocator> 注入或通过 personRepository.Change<TEntity, TDbContextLocator>() 切换。

9.15.10 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
var persons = "select * from person whre id > @id".Change<SqliteDbContextLocator>().SqlQuery<Person>();
补充说明

懒人方式 只需要通过 Change<TDbContextLocator> 方式即可动态切换数据库。

9.15.9.2 ISqlRepository 方式

只需要通过 ISqlRepository<TDbContextLocator> 注入或通过 sqlRepository.Change<TDbContextLocator>() 切换。

9.15.9.3 IRepository 方式

只需要通过 repository.Change<TDbContextLocator>() 获取即可。

9.15.9.4 IRepository<TEntity> 方式

只需要通过 IRepository<TEntity, TDbContextLocator> 注入或通过 personRepository.Change<TEntity, TDbContextLocator>() 切换。

9.15.10 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-update/index.html b/handbook/build/docs/dbcontext-update/index.html index e21fca97b9f..543da87f18d 100644 --- a/handbook/build/docs/dbcontext-update/index.html +++ b/handbook/build/docs/dbcontext-update/index.html @@ -4,22 +4,22 @@ -9.6 更新操作 | Fur - - - - - - - - - - - +9.6 更新操作 | Fur + + + + + + + + + + +
-

9.6 更新操作

9.6.1 更新全部列(不立即提交)

// ==== 同步操作 ====
+

9.6 更新操作

9.6.1 更新全部列(不立即提交)

// ==== 同步操作 ====
// 示例一
repository.Update(user);
// 示例二
user.Update();
// 示例三
repository.ChangeEntityState(user, EntityState.Modified);
@@ -191,17 +191,17 @@
// ==== 异步操作 ====
// 示例一
await repository.UpdateNowAsync(user, user2);
// 示例二
await repository.UpdateNowAsync(new List<User> { user, user2 });
-
// 示例三
await repository.UpdateNowAsync(new[] {user, user2 });
小知识

所有带 Now 结尾的表示立即提交到数据库,也就是立即调用 SaveChangesSaveChangesAsync

9.6.15 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
// 示例三
await repository.UpdateNowAsync(new[] {user, user2 });
小知识

所有带 Now 结尾的表示立即提交到数据库,也就是立即调用 SaveChangesSaveChangesAsync

9.6.15 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext-view/index.html b/handbook/build/docs/dbcontext-view/index.html index 0586f4346f3..4f31275ab3a 100644 --- a/handbook/build/docs/dbcontext-view/index.html +++ b/handbook/build/docs/dbcontext-view/index.html @@ -4,22 +4,22 @@ -9.12 视图操作 | Fur - - - - - - - - - - - +9.12 视图操作 | Fur + + + + + + + + + + +
-

9.12 视图操作

9.12.1 关于视图

视图是数据库中非常重要的对象,是一张虚拟表,通过视图我们可以对结果进行筛选缓存,同时还能实现颗粒化权限控制,如控制指定行,指定列。

9.12.2 视图的使用

Fur 中实现视图的操作非常简单,只需要创建视图模型,并继承 EntityNotKey 基类即可。代码如下:

9.12.2.1 创建视图 SQL

CREATE VIEW V_Person AS
SELECT Id,Name,Age,Address FROM person

9.12.2.2 视图模型

using Fur.DatabaseAccessor;
+

9.12 视图操作

9.12.1 关于视图

视图是数据库中非常重要的对象,是一张虚拟表,通过视图我们可以对结果进行筛选缓存,同时还能实现颗粒化权限控制,如控制指定行,指定列。

9.12.2 视图的使用

Fur 中实现视图的操作非常简单,只需要创建视图模型,并继承 EntityNotKey 基类即可。代码如下:

9.12.2.1 创建视图 SQL

CREATE VIEW V_Person AS
SELECT Id,Name,Age,Address FROM person

9.12.2.2 视图模型

using Fur.DatabaseAccessor;
namespace Fur.Core
{
public class V_Person : EntityNotKey
{
/// <summary>
/// 配置视图名
/// </summary>
public V_Person() : base("V_Person")
{
}
/// <summary>
/// 主键Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
@@ -27,17 +27,17 @@
/// <summary>
/// 住址
/// </summary>
public string Address { get; set; }
}
}
视图名称

视图实体只需要继承 EntityNotKey 基类并编写无参构造函数继承 base("视图名称") 即可。

9.12.3 视图使用

视图除了不能操作(写)以外,其他操作和表操作无异。

var vEntities = v_repository.Where(u => u.Id >10).ToList();

9.12.4 视图最佳读取方式 ✔

由于视图是虚拟表,不应该对其进行写操作,所以应该采用 只读仓储初始化视图

using Fur.Core;
using Fur.DatabaseAccessor;
using Fur.DynamicApiController;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Fur.Application.Persons
{
public class FurService : IDynamicApiController
{
private readonly IReadableRepository<V_Person> _readableRepository;
public FurService(IRepository<V_Person> repository)
{
// 初始化只读仓储
_readableRepository = repository.Constraint<IReadableRepository<V_Person>>();
}
-
/// <summary>
/// 读取视图
/// </summary>
/// <returns></returns>
public async Task<List<V_Person>> GetVPerson()
{
var list = await _readableRepository.AsAsyncEnumerable();
return list;
}
}
}
小知识

通过 .Constraint<TEntity,TDbContextLocator> 方法可以将仓储约束为特定仓储,如只读仓储,可读可写仓储,只新增仓储等。

9.12.5 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
/// <summary>
/// 读取视图
/// </summary>
/// <returns></returns>
public async Task<List<V_Person>> GetVPerson()
{
var list = await _readableRepository.AsAsyncEnumerable();
return list;
}
}
}
小知识

通过 .Constraint<TEntity,TDbContextLocator> 方法可以将仓储约束为特定仓储,如只读仓储,可读可写仓储,只新增仓储等。

9.12.5 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dbcontext/index.html b/handbook/build/docs/dbcontext/index.html index ab255696410..c52ee620f63 100644 --- a/handbook/build/docs/dbcontext/index.html +++ b/handbook/build/docs/dbcontext/index.html @@ -4,24 +4,24 @@ -9.1 数据库上下文 | Fur - - - - - - - - - - - +9.1 数据库上下文 | Fur + + + + + + + + + + +
-

9.1 数据库上下文

9.1.1 数据库上下文

简单来说,数据库上下文是负责和数据库交互的对象,提供程序对数据库存取提供了大量的方法。

Fur 框架中,默认集成了微软亲儿子:EntityFramework Core ,也就是通常数据库上下文指的是 DbContext 类或它的实现类。

9.1.2 AppDbContext

在我们实际项目开发过程中,使用 EFCore 提供的 DbContext 操作对象操作数据库有些繁琐和复杂,且默认不具备读写分离、多库等操作功能。

所以,Fur 框架提供了 AppDbContext<TDbContext, TDbContextLocator> 数据库上下文,该上下文继承自 DbContext

特别说明

后续章节,皆采用 EFCore 代替 EntityFramework Core

9.1.3 AppDbContextDbContext 区别

  • AppDbContext 继承自 DbContext,具备 DbContext 所有功能。
  • AppDbContext 支持多数据库操作泛型版本,如:AppDbContext<TDbContext, TDbContextLocator>
  • AppDbContext 自动配置实体信息,无需在 OnModelCreating 中配置
  • AppDbContext 支持内置多租户支持
  • AppDbContext 支持全局模型配置拦截器
  • AppDbContext 支持数据提交更改多个事件
  • AppDbContext 提供更加强大的模型操作能力,如果 Sql 操作,读写分离等
  • AppDbContext 能够得到 Fur 框架更多的功能支持

9.1.4 如何定义数据库上下文

Fur 框架中了,提供了两种 AppDbContext 定义方式:

  • AppDbContext<TDbContext> 操作默认数据库
  • AppDbContext<TDbContext, TDbContextLocator> 操作 N 个数据库

其中 AppDbContext<TDbContext> 默认继承自 AppDbContext<TDbContext, TDbContextLocator>

下面是数据库上下文创建的多个例子:

9.1.4.1 创建默认数据库上下文

using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
+

9.1 数据库上下文

9.1.1 数据库上下文

简单来说,数据库上下文是负责和数据库交互的对象,提供程序对数据库存取提供了大量的方法。

Fur 框架中,默认集成了微软亲儿子:EntityFramework Core ,也就是通常数据库上下文指的是 DbContext 类或它的实现类。

9.1.2 AppDbContext

在我们实际项目开发过程中,使用 EFCore 提供的 DbContext 操作对象操作数据库有些繁琐和复杂,且默认不具备读写分离、多库等操作功能。

所以,Fur 框架提供了 AppDbContext<TDbContext, TDbContextLocator> 数据库上下文,该上下文继承自 DbContext

特别说明

后续章节,皆采用 EFCore 代替 EntityFramework Core

9.1.3 AppDbContextDbContext 区别

  • AppDbContext 继承自 DbContext,具备 DbContext 所有功能。
  • AppDbContext 支持多数据库操作泛型版本,如:AppDbContext<TDbContext, TDbContextLocator>
  • AppDbContext 自动配置实体信息,无需在 OnModelCreating 中配置
  • AppDbContext 支持内置多租户支持
  • AppDbContext 支持全局模型配置拦截器
  • AppDbContext 支持数据提交更改多个事件
  • AppDbContext 提供更加强大的模型操作能力,如果 Sql 操作,读写分离等
  • AppDbContext 能够得到 Fur 框架更多的功能支持

9.1.4 如何定义数据库上下文

Fur 框架中了,提供了两种 AppDbContext 定义方式:

  • AppDbContext<TDbContext> 操作默认数据库
  • AppDbContext<TDbContext, TDbContextLocator> 操作 N 个数据库

其中 AppDbContext<TDbContext> 默认继承自 AppDbContext<TDbContext, TDbContextLocator>

下面是数据库上下文创建的多个例子:

9.1.4.1 创建默认数据库上下文

using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
namespace Fur.EntityFramework.Core
{
[AppDbContext("连接字符串或appsetting.json 键")]
public class FurDbContext : AppDbContext<FurDbContext> // 继承 AppDbContext<> 类
{
/// <summary>
/// 继承父类构造函数
/// </summary>
/// <param name="options"></param>
public FurDbContext(DbContextOptions<FurDbContext> options) : base(options)
{
}
}
}

9.1.4.2 创建其他数据库上下文

using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
-
namespace Fur.EntityFramework.Core
{
[AppDbContext("连接字符串或appsetting.json 键")]
public class FurOtherDbContext : AppDbContext<FurOtherDbContext, FurOtherDbContextLocator> // 继承 AppDbContext<> 类
{
/// <summary>
/// 继承父类构造函数
/// </summary>
/// <param name="options"></param>
public FurOtherDbContext(DbContextOptions<FurOtherDbContext> options) : base(options)
{
}
}
}
特别注意

所有数据库上下文都应该在 Fur.EntityFramework.Core 项目中创建。关于 TDbContextLocator 将在下一章节 《9.2 数据库上下文定位器》阐述。

9.1.5 配置连接字符串

Fur 框架提供多种数据库连接字符串配置方式:

  • 在注册数据库服务时配置:AddSqlServerPool<TDbContext>("连接字符串") 方式
  • 使用 [AppDbContext("连接字符串/Key")] 特性方式(只在 AppDbContext 实现类有效推荐
  • 通过重写 OnConfiguring(DbContextOptionsBuilder optionsBuilder) 配置

9.1.5.1 在注册数据库服务时配置

Fur.EntityFramework.Core\FurEntityFrameworkCoreStartup.cs
using Fur.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
+
namespace Fur.EntityFramework.Core
{
[AppDbContext("连接字符串或appsetting.json 键")]
public class FurOtherDbContext : AppDbContext<FurOtherDbContext, FurOtherDbContextLocator> // 继承 AppDbContext<> 类
{
/// <summary>
/// 继承父类构造函数
/// </summary>
/// <param name="options"></param>
public FurOtherDbContext(DbContextOptions<FurOtherDbContext> options) : base(options)
{
}
}
}
特别注意

所有数据库上下文都应该在 Fur.EntityFramework.Core 项目中创建。关于 TDbContextLocator 将在下一章节 《9.2 数据库上下文定位器》阐述。

9.1.5 配置连接字符串

Fur 框架提供多种数据库连接字符串配置方式:

  • 在注册数据库服务时配置:AddSqlServerPool<TDbContext>("连接字符串") 方式
  • 使用 [AppDbContext("连接字符串/Key")] 特性方式(只在 AppDbContext 实现类有效推荐
  • 通过重写 OnConfiguring(DbContextOptionsBuilder optionsBuilder) 配置

9.1.5.1 在注册数据库服务时配置

Fur.EntityFramework.Core\FurEntityFrameworkCoreStartup.cs
using Fur.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
namespace Fur.EntityFramework.Core
{
[AppStartup(600)]
public sealed class FurEntityFrameworkCoreStartup : AppStartup
{
public void ConfigureServices(IServiceCollection services)
{
// 配置数据库上下文,支持N个数据库
services.AddDatabaseAccessor(options =>
{
// 配置默认数据库
options.AddDbPool<FurDbContext>(DbProvider.SqlServer, "连接字符串");
// 配置多个数据库,多个数据库必须指定数据库上下文定位器
options.AddDbPool<SqliteDbContext, SqliteDbContextLocaotr>(DbProvider.Sqlite, "连接字符串");
});
}
}
}

9.1.5.2 [AppDbContext] 方式配置

using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
namespace Fur.EntityFramework.Core
{
[AppDbContext("DbConnectionString")] // 支持 `appsetting.json` 名或 连接字符串
public class FurDbContext : AppDbContext<FurDbContext>
{
/// <summary>
/// 继承父类构造函数
/// </summary>
/// <param name="options"></param>
public FurDbContext(DbContextOptions<FurDbContext> options) : base(options)
{
}
}
}
小提示

Fur 推荐使用此方式配置数据库连接字符串。

[AppDbContext] 内置属性:

  • ConnectionString:数据库连接字符串,或配置文件中的路径(支持自定义配置查找),或 appsetting.jsonConnectionStrings 配置字符串
  • TablePrefix:当前数据库上下文表统一前缀
  • TableSuffix:当前数据库上下文表统一后缀

9.1.5.3 OnConfiguring 方式配置

using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
@@ -30,17 +30,17 @@
optionsBuilder.UseSqlServer("数据库连接字符串");
}
}
}
特别注意

这三种方式可以同时使用,但是有优先级:[AppDbContext] -> 在注册数据库服务时配置 -> OnConfiguring(低到高)

也就是 OnConfiguring 配置会覆盖 在注册数据库服务时配置 配置,在注册数据库服务时配置 配置会覆盖 [AppDbContext] 配置所配置的连接字符串。

9.1.6 数据库上下文定义位置

特别注意

Fur 框架中,数据库上下文需定义在 Fur.EntityFramework.Core 中,且每一个数据库上下文都必须拥有唯一的 DbContextLocator 定位器

9.1.7 数据库上下文注册

数据库上下文配置好数据库连接字符串后,需要注册该数据库上下文,并指定数据库类型,如:

Fur\framework\Fur.EntityFramework.Core\FurEntityFrameworkCoreStartup.cs
using Fur.DatabaseAccessor;
using Microsoft.Extensions.DependencyInjection;
namespace Fur.EntityFramework.Core
{
[AppStartup(600)]
public sealed class FurEntityFrameworkCoreStartup : AppStartup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddDatabaseAccessor(options =>
{
options.AddDbPool<FurDbContext>(DbProvider.Sqlite);
});
}
}
}

如果有多个数据库操作,那么从第二个起,就需要绑定数据库上下文定位器,如:

options.AddDbPool<FurDbContext>(DbProvider.Sqlite); // 第一个数据库
options.AddDbPool<SecondDbContext, SecondDbContextDbContextLocator>(DbProvider.SqlServer); // 第二个数据库
-
options.AddDbPool<ThirdDbContext, ThirdDbContextDbContextLocator>(DbProvider.SqlServer); // 第三个数据库

9.1.8 动态数据库上下文对象

Fur 框架中,数据库上下文是定义在 Fur.EntityFramework.Core 项目层,并且该层不被 Fur.ApplicationFur.Core 等层引用。

所以就不能直接在 Fur.Application 项目层直接使用 Fur.EntityFramework.Core 定义的数据库上下文。

Fur 为了解决这个问题,提供了两种方式处理:

  • respository.DbContext :当前数据库上下文对象,返回是 DbContext 抽象类型
  • respository.DynamicDbContext:当前数据库上下文对象,返回的是 dynamic 类型

如果你只是想使用 DbContext 的功能,直接使用 respository.DbContext 即可,如:

respository.DbContext.SaveChanges();

如果你想能够获取具体的数据库上下文类型,如 MyDbContext,那么使用 respository.DynamicDbContext 就可以获取到具体的 MyDbContext 类型。如:

var persons = respository.DynamicDbContext.Persons.Find(1);
var users = respository.DynamicDbContext.Users;

这样就可以直接操作 MyDbContext 定义的属性和方法了。

9.1.9 反馈与建议

与我们交流

给 Fur 提 Issue


了解更多

想了解更多 数据库上下文 知识可查阅 EF Core - 配置 DbContext 章节。

- - - - - - - - - - - +
options.AddDbPool<ThirdDbContext, ThirdDbContextDbContextLocator>(DbProvider.SqlServer); // 第三个数据库

9.1.8 动态数据库上下文对象

Fur 框架中,数据库上下文是定义在 Fur.EntityFramework.Core 项目层,并且该层不被 Fur.ApplicationFur.Core 等层引用。

所以就不能直接在 Fur.Application 项目层直接使用 Fur.EntityFramework.Core 定义的数据库上下文。

Fur 为了解决这个问题,提供了两种方式处理:

  • respository.DbContext :当前数据库上下文对象,返回是 DbContext 抽象类型
  • respository.DynamicDbContext:当前数据库上下文对象,返回的是 dynamic 类型

如果你只是想使用 DbContext 的功能,直接使用 respository.DbContext 即可,如:

respository.DbContext.SaveChanges();

如果你想能够获取具体的数据库上下文类型,如 MyDbContext,那么使用 respository.DynamicDbContext 就可以获取到具体的 MyDbContext 类型。如:

var persons = respository.DynamicDbContext.Persons.Find(1);
var users = respository.DynamicDbContext.Users;

这样就可以直接操作 MyDbContext 定义的属性和方法了。

9.1.9 反馈与建议

与我们交流

给 Fur 提 Issue


了解更多

想了解更多 数据库上下文 知识可查阅 EF Core - 配置 DbContext 章节。

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dependency-injection/index.html b/handbook/build/docs/dependency-injection/index.html index b53e7df55d5..3d16023d6fc 100644 --- a/handbook/build/docs/dependency-injection/index.html +++ b/handbook/build/docs/dependency-injection/index.html @@ -4,28 +4,28 @@ -11. 依赖注入/控制反转 | Fur - - - - - - - - - - - +11. 依赖注入/控制反转 | Fur + + + + + + + + + + +
-

11. 依赖注入/控制反转

11.1 依赖注入

所谓依赖注入,是指程序运行过程中,如果需要调用另一个对象协助时,无须在代码中创建被调用者,而是依赖于外部的注入。

通俗来讲,就是把有依赖关系的类放到容器中,然后在我们需要这些类时,容器自动解析出这些类的实例。

依赖注入最大的好处时实现类的解耦,利于程序拓展、单元测试、自动化模拟测试等。

依赖注入的英文为:Dependency Injection,简称 DI

11.2 控制反转

控制反转只是一个概念,也就是将创建对象实例的控制权(原本是程序员)从代码控制权剥离到 IOC 容器 中控制。

控制反转的英文为:Inversion of Control,简称 IOC

11.3 IOC/DI 优缺点

传统的代码,每个对象负责管理与自己需要依赖的对象,导致如果需要切换依赖对象的实现类时,需要修改多处地方。同时,过度耦合也使得对象难以进行单元测试。

  • 优点

    • 依赖注入把对象的创造交给外部去管理,很好的解决了代码紧耦合(tight couple)的问题,是一种让代码实现松耦合(loose couple)的机制
    • 松耦合让代码更具灵活性,能更好地应对需求变动,以及方便单元测试
  • 缺点

    • 目前主流的 IOC/DI 基本采用反射的方式来实现依赖注入,在一定程度会影响性能
特别说明

在本章节不打算细讲 依赖注入/控制反转 具体实现和应用场景,想了解更多知识,可查阅 【ASP.NET Core 依赖注入】 官方文档。

11.4 依赖注入的三种方式

11.4.1 构造方法注入

目前构造方法注入是依赖注入推荐使用方式。

  • 优点

    • 在构造方法中体现出对其他类的依赖,一眼就能看出这个类需要其他那些类才能工作
    • 脱离了 IOC 框架,这个类仍然可以工作,POJO 的概念
    • 一旦对象初始化成功了,这个对象的状态肯定是正确的
  • 缺点

    • 构造函数会有很多参数(Bad smell)
    • 有些类是需要默认构造函数的,比如 MVC 框架的 Controller 类,一旦使用构造函数注入,就无法使用默认构造函数
    • 这个类里面的有些方法并不需要用到这些依赖(Bad smell)

代码示例:

public class FurService
{
private readonly IRepository _repository;
public FurService(IRepository repository)
{
_repository = repository;
}
}

11.4.2 属性方式注入

通过属性方式注入容易和类的实例属性混淆,不建议使用。

  • 优点

    • 在对象的整个生命周期内,可以随时动态的改变依赖
    • 非常灵活
  • 缺点

    • 对象在创建后,被设置依赖对象之前这段时间状态是不对的
    • 不直观,无法清晰地表示哪些属性是必须的
public class FurService
{
public IRepository Repository { get; set; }
}

11.4.3 方法参数注入

方法参数注入的意思是在创建对象后,通过自动调用某个方法来注入依赖。

  • 优点:

    • 比较灵活
  • 缺点:

    • 新加入依赖时会破坏原有的方法签名,如果这个方法已经被其他很多模块用到就很麻烦
    • 与构造方法注入一样,会有很多参数
public class FurService
{
public Person GetById([FromServices]IRepository repository, int id)
{
return repository.Find(id);
}
}

11.5 注册对象生存期

11.5.1 暂时/瞬时 生存期

暂时生存期服务是每次从服务容器进行请求时创建的。 这种生存期适合轻量级、 无状态的服务。

在处理请求的应用中,在请求结束时会释放暂时服务。

通常我们使用 ITransient 接口依赖表示该生命周期。

11.5.2 作用域 生存期

作用域生存期服务针对每个客户端请求(连接)创建一次。在处理请求的应用中,在请求结束时会释放有作用域的服务。

通常我们使用 IScoped 接口依赖表示该生命周期。

11.5.3 单例 生存期

在首次请求它们时进行创建,之后每个后续请求都使用相同的实例。

通常我们使用 ISingleton 接口依赖表示该生命周期。

了解更多

想了解更多 服务生存期 知识可查阅 ASP.NET Core - 依赖注入 - 服务生存期 章节。

11.6 内置依赖接口

Fur 框架提供三个接口依赖分别对应不同的服务生存期:

  • ITransient:对应暂时/瞬时作用域服务生存期
  • IScoped:对应请求作用域服务生存期
  • ISingleton:对应单例作用域服务生存期

11.7 常见使用

11.7.2 第一个例子

创建 IBusinessService 接口和 BusinessService 实现类,代码如下:

using Fur.Core;
using Fur.DatabaseAccessor;
using Fur.DependencyInjection;
+

11. 依赖注入/控制反转

11.1 依赖注入

所谓依赖注入,是指程序运行过程中,如果需要调用另一个对象协助时,无须在代码中创建被调用者,而是依赖于外部的注入。

通俗来讲,就是把有依赖关系的类放到容器中,然后在我们需要这些类时,容器自动解析出这些类的实例。

依赖注入最大的好处时实现类的解耦,利于程序拓展、单元测试、自动化模拟测试等。

依赖注入的英文为:Dependency Injection,简称 DI

11.2 控制反转

控制反转只是一个概念,也就是将创建对象实例的控制权(原本是程序员)从代码控制权剥离到 IOC 容器 中控制。

控制反转的英文为:Inversion of Control,简称 IOC

11.3 IOC/DI 优缺点

传统的代码,每个对象负责管理与自己需要依赖的对象,导致如果需要切换依赖对象的实现类时,需要修改多处地方。同时,过度耦合也使得对象难以进行单元测试。

  • 优点

    • 依赖注入把对象的创造交给外部去管理,很好的解决了代码紧耦合(tight couple)的问题,是一种让代码实现松耦合(loose couple)的机制
    • 松耦合让代码更具灵活性,能更好地应对需求变动,以及方便单元测试
  • 缺点

    • 目前主流的 IOC/DI 基本采用反射的方式来实现依赖注入,在一定程度会影响性能
特别说明

在本章节不打算细讲 依赖注入/控制反转 具体实现和应用场景,想了解更多知识,可查阅 【ASP.NET Core 依赖注入】 官方文档。

11.4 依赖注入的三种方式

11.4.1 构造方法注入

目前构造方法注入是依赖注入推荐使用方式。

  • 优点

    • 在构造方法中体现出对其他类的依赖,一眼就能看出这个类需要其他那些类才能工作
    • 脱离了 IOC 框架,这个类仍然可以工作,POJO 的概念
    • 一旦对象初始化成功了,这个对象的状态肯定是正确的
  • 缺点

    • 构造函数会有很多参数(Bad smell)
    • 有些类是需要默认构造函数的,比如 MVC 框架的 Controller 类,一旦使用构造函数注入,就无法使用默认构造函数
    • 这个类里面的有些方法并不需要用到这些依赖(Bad smell)

代码示例:

public class FurService
{
private readonly IRepository _repository;
public FurService(IRepository repository)
{
_repository = repository;
}
}

11.4.2 属性方式注入

通过属性方式注入容易和类的实例属性混淆,不建议使用。

  • 优点

    • 在对象的整个生命周期内,可以随时动态的改变依赖
    • 非常灵活
  • 缺点

    • 对象在创建后,被设置依赖对象之前这段时间状态是不对的
    • 不直观,无法清晰地表示哪些属性是必须的
public class FurService
{
public IRepository Repository { get; set; }
}

11.4.3 方法参数注入

方法参数注入的意思是在创建对象后,通过自动调用某个方法来注入依赖。

  • 优点:

    • 比较灵活
  • 缺点:

    • 新加入依赖时会破坏原有的方法签名,如果这个方法已经被其他很多模块用到就很麻烦
    • 与构造方法注入一样,会有很多参数
public class FurService
{
public Person GetById([FromServices]IRepository repository, int id)
{
return repository.Find(id);
}
}

11.5 注册对象生存期

11.5.1 暂时/瞬时 生存期

暂时生存期服务是每次从服务容器进行请求时创建的。 这种生存期适合轻量级、 无状态的服务。

在处理请求的应用中,在请求结束时会释放暂时服务。

通常我们使用 ITransient 接口依赖表示该生命周期。

11.5.2 作用域 生存期

作用域生存期服务针对每个客户端请求(连接)创建一次。在处理请求的应用中,在请求结束时会释放有作用域的服务。

通常我们使用 IScoped 接口依赖表示该生命周期。

11.5.3 单例 生存期

在首次请求它们时进行创建,之后每个后续请求都使用相同的实例。

通常我们使用 ISingleton 接口依赖表示该生命周期。

了解更多

想了解更多 服务生存期 知识可查阅 ASP.NET Core - 依赖注入 - 服务生存期 章节。

11.6 内置依赖接口

Fur 框架提供三个接口依赖分别对应不同的服务生存期:

  • ITransient:对应暂时/瞬时作用域服务生存期
  • IScoped:对应请求作用域服务生存期
  • ISingleton:对应单例作用域服务生存期

11.7 常见使用

11.7.2 第一个例子

创建 IBusinessService 接口和 BusinessService 实现类,代码如下:

using Fur.Core;
using Fur.DatabaseAccessor;
using Fur.DependencyInjection;
namespace Fur.Application
{
public interface IBusinessService
{
Person Get(int id);
}
public class BusinessService : IBusinessService, ITransient
{
private readonly IRepository<Person> _personRepository;
public BusinessService(IRepository<Person> personRepository)
{
_personRepository = personRepository;
}
public Person Get(int id)
{
return _personRepository.Find(id);
}
}
}

创建 PersonController 控制器,代码如下:

using Fur.Application;
using Microsoft.AspNetCore.Mvc;
namespace Fur.Web.Entry.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class PersonController : ControllerBase
{
private readonly IBusinessService _businessService;
public PersonController(IBusinessService businessService)
{
_businessService = businessService;
}
-
[HttpGet]
public IActionResult Get(int id)
{
var person = _businessService.Get(id);
return new JsonResult(person);
}
}
}

例子解说

Fur 框架提供了非常灵活且方便的实现依赖注入的方式,只需要实例类继承对应生存期的接口即可,这里继承了 ITransient,也就表明了这是一个 暂时/瞬时 作用域实例类。该类就可以作为被注入对象,同时也能注入其他接口对象。

上面的例子中,BusinessService 注入了 IRepository<Person> 仓储接口,同时 PersonController 控制器注入了 IBusinessService 接口。

这样 PersonControllerBusinessService 之间就实现了解耦,不再依赖于具体的 BusinessService 实例。

这就是依赖注入/控制反转最经典的例子。

11.7.3 注册泛型实例

创建 IBusinessService<T> 接口和 BusinessService<T> 实现类,代码如下:

using Fur.Core;
using Fur.DatabaseAccessor;
using Fur.DependencyInjection;
+
[HttpGet]
public IActionResult Get(int id)
{
var person = _businessService.Get(id);
return new JsonResult(person);
}
}
}

例子解说

Fur 框架提供了非常灵活且方便的实现依赖注入的方式,只需要实例类继承对应生存期的接口即可,这里继承了 ITransient,也就表明了这是一个 暂时/瞬时 作用域实例类。该类就可以作为被注入对象,同时也能注入其他接口对象。

上面的例子中,BusinessService 注入了 IRepository<Person> 仓储接口,同时 PersonController 控制器注入了 IBusinessService 接口。

这样 PersonControllerBusinessService 之间就实现了解耦,不再依赖于具体的 BusinessService 实例。

这就是依赖注入/控制反转最经典的例子。

11.7.3 注册泛型实例

创建 IBusinessService<T> 接口和 BusinessService<T> 实现类,代码如下:

using Fur.Core;
using Fur.DatabaseAccessor;
using Fur.DependencyInjection;
namespace Fur.Application
{
public interface IBusinessService<T>
{
Person Get(int id);
}
public class BusinessService<T> : IBusinessService<T>, ITransient
{
private readonly IRepository<Person> _personRepository;
public BusinessService(IRepository<Person> personRepository)
{
_personRepository = personRepository;
}
@@ -37,7 +37,7 @@
public class OtherBusinessService : IBusinessService, ITransient
{
public string GetName()
{
return "我是:" + nameof(OtherBusinessService);
}
}
}

创建 ValueController 控制器,代码如下:

using Fur.Application;
using Fur.DependencyInjection;
using Microsoft.AspNetCore.Mvc;
using System;
namespace Fur.Web.Entry.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ValueController : ControllerBase
{
private readonly IBusinessService _businessService;
private readonly IBusinessService _otherBusinessService;
public ValueController(Func<string, ITransient, object> resolveNamed)
{
_businessService = resolveNamed("BusinessService", default) as IBusinessService;
_otherBusinessService = resolveNamed("OtherBusinessService", default) as IBusinessService;
}
-
[HttpGet]
public string GetName()
{
return _businessService.GetName() + "----------" + _otherBusinessService.GetName();
}
}
}
小知识

如果需要自定义解析名称,只需要贴 [Injection(Named = "名称")] 即可,如:

using Fur.DependencyInjection;
+
[HttpGet]
public string GetName()
{
return _businessService.GetName() + "----------" + _otherBusinessService.GetName();
}
}
}
小知识

如果需要自定义解析名称,只需要贴 [Injection(Named = "名称")] 即可,如:

using Fur.DependencyInjection;
namespace Fur.Application
{
[Injection(Named = "BusName1")]
public class BusinessService : IBusinessService, ITransient
{
// ...
}
[Injection(Named = "BusName2")]
public class OtherBusinessService : IBusinessService, ITransient
{
// ...
}
}

解析服务:

_businessService = resolveNamed("BusName1", default) as IBusinessService;
_otherBusinessService = resolveNamed("BusName2", default) as IBusinessService;

11.7.5 无接口方式

有些时候,我们不想定义接口,而是想把实例类作为可依赖注入的对象,如 MVC 中的控制器。

创建 SelfService 实例类,代码如下:

using Fur.Core;
using Fur.DatabaseAccessor;
using Fur.DependencyInjection;
namespace Fur.Application
{
public class SelfService : ITransient
{
private readonly IRepository<Person> _personRepository;
@@ -52,17 +52,17 @@
/// <summary>
/// 拦截方法
/// </summary>
/// <param name="targetMethod"></param>
/// <param name="args"></param>
/// <returns></returns>
protected override object Invoke(MethodInfo targetMethod, object[] args)
{
Console.WriteLine("SayHello 方法被调用了");
var result = targetMethod.Invoke(Target, args);
Console.WriteLine("SayHello 方法返回值:" + result);
-
return result;
}
}
}

之后我们只需要为 TestService 增加 [Injection] 特性即可,如:

[Injection(Proxy = typeof(LogDispatchProxy))]
public class TestService: ITestService, ITransient
{
public string SayHello(string word)
{
return $"Hello {word}";
}
}

之后 SayHello 方法被调用的时候就可以实现动态拦截了,比如这里写日志。

11.12.1 AOP 的作用

这种面向切面的能力(动态拦截/代理)可以实现很多很多功能,如:

  • 动态日志记录
  • 动态修改参数
  • 动态修改返回值
  • 动态方法重定向
  • 动态修改代码逻辑
  • 动态实现异常监听

还可以做更多更多的事情。

11.13 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
return result;
}
}
}

之后我们只需要为 TestService 增加 [Injection] 特性即可,如:

[Injection(Proxy = typeof(LogDispatchProxy))]
public class TestService: ITestService, ITransient
{
public string SayHello(string word)
{
return $"Hello {word}";
}
}

之后 SayHello 方法被调用的时候就可以实现动态拦截了,比如这里写日志。

11.12.1 AOP 的作用

这种面向切面的能力(动态拦截/代理)可以实现很多很多功能,如:

  • 动态日志记录
  • 动态修改参数
  • 动态修改返回值
  • 动态方法重定向
  • 动态修改代码逻辑
  • 动态实现异常监听

还可以做更多更多的事情。

11.13 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/deploy/index.html b/handbook/build/docs/deploy/index.html index 35b264f0414..43aa9489ac2 100644 --- a/handbook/build/docs/deploy/index.html +++ b/handbook/build/docs/deploy/index.html @@ -4,32 +4,32 @@ -25. 托管部署 | Fur - - - - - - - - - - - +25. 托管部署 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/devops/index.html b/handbook/build/docs/devops/index.html index 40da3c996aa..087579b74ef 100644 --- a/handbook/build/docs/devops/index.html +++ b/handbook/build/docs/devops/index.html @@ -4,32 +4,32 @@ -26. 持续部署集成 | Fur - - - - - - - - - - - +26. 持续部署集成 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/dynamic-api-controller/index.html b/handbook/build/docs/dynamic-api-controller/index.html index fecb8992a20..216e29ae163 100644 --- a/handbook/build/docs/dynamic-api-controller/index.html +++ b/handbook/build/docs/dynamic-api-controller/index.html @@ -4,58 +4,58 @@ -5. 动态 WebAPI | Fur - - - - - - - - - - - +5. 动态 WebAPI | Fur + + + + + + + + + + +
-

5. 动态 WebAPI

5.1 什么是控制器

简单来说,控制器是一个承上启下的作用,根据用户输入,执行响应行为(动作方法),同时在行为中调用模型的业务逻辑,返回给用户结果(视图)。

ASP.NET Core 中,控制器有两种表现形式:

  • Mvc(带视图)
  • WebAPI(RESTful API)
using Microsoft.AspNetCore.Mvc;
+

5. 动态 WebAPI

5.1 什么是控制器

简单来说,控制器是一个承上启下的作用,根据用户输入,执行响应行为(动作方法),同时在行为中调用模型的业务逻辑,返回给用户结果(视图)。

ASP.NET Core 中,控制器有两种表现形式:

  • Mvc(带视图)
  • WebAPI(RESTful API)
using Microsoft.AspNetCore.Mvc;
namespace Fur.Web.Entry.Controllers
{
public class MvcController : Controller
{
public IActionResult Index()
{
return View();
}
}
}

Mvc 控制器和 WebAPI 控制器最大的区别是 WebAPI 控制器不带 视图 和通过 请求谓词和路由地址响应行为

5.2 Mvc 控制器 约定和缺点

在学习动态 WebAPI 控制器之前,首先了解 ASP.NET CoreWebAPI 的一些约定和注意事项。

5.2.1 WebAPI 约定

ASP.NET Core 应用中,一个 WebAPI 控制器需遵循以下约定:

  • 控制器类必须继承 ControllerBase 或间接继承
  • 动作方法必须贴有 [HttpMethod] 特性,如:[HttpGet]
  • 控制器或动作方法至少有一个配置 [Route] 特性
  • 生成 WebAPI 路由地址时会自动去掉控制器名称 Controller 后缀,同时也会去掉动作方法匹配的 HttpVerb 谓词,如 GET,POST,DELETE,PUT
  • 不支持返回非 IEnumerable<T> 泛型对象
  • 不支持类类型参数在 GET,HEAD 请求下生成 Query 参数

除了上述约定外,WebAPI 路由地址基本靠手工完成,不利于书写,不利于维护,再者,在移动应用对接中难以进行多版本控制。

5.2.2 .NET Core WebAPI 缺点

通过上一章节可以看出,ASP.NET Core 应用实现 WebAPI 需要遵循种种约定,而且容易出错。

除了这些约定,.NET Core WebAPI 有以下缺点:

  • 路由地址基本靠手工完成
  • 在现在移动为王的时代,不利于进行多版本控制
  • 对接 Swagger 文档分组比较复杂
  • 实现 Policy 策略授权也比较复杂
  • 不支持控制器热拔插插件化
  • 难以实现复杂自定义的 RESTful API 风格

5.3 动态 WebAPI 控制器

针对以上 ASP.NET Core 提供的 WebAPI 必须遵循的约定和不可避免的缺点,Fur 框架创造出一种更加灵活创建 WebAPI 控制器的方式。

这个方式在继承了 ASP.NET Core WebAPI 所有优点,同时进行了大量拓展和优化。优化后的 WebAPI 具有以下优点:

  • 具备原有的 ControllerBase 所有功能
  • 支持任意公开 非静态 非抽象 非泛型类转控制器
  • 提供更加灵活方便的 IDynamicApiController 空接口或 [DynamicApiController] 特性替代 ControllerBase 抽象类
  • 无需手动配置 [HttpMethod] 特性,同时支持一个动作方法多个 HttpVerb
  • 无需手动配置 [Route] 特性,支持更加灵活的配置及自动路由生成
  • 支持返回泛型接口,泛型类
  • Swagger 深度结合,提供极其方便的创建 Swagger 分组配置
  • 支持 Basic Auth,Jwt,ApiKey 等多种权限灵活配置
  • 支持控制器、动作方法版本控制功能
  • 支持 GET、HEAD 请求自动转换 类类型参数
  • 支持生成 OAS3 接口规范

5.4 注册动态 WebAPI 服务

Fur.Web.Core\FurWebCoreStartup.cs
using Microsoft.Extensions.DependencyInjection;
namespace Fur.Web.Core
{
[AppStartup(800)]
public sealed class FurWebCoreStartup : AppStartup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers()
.AddDynamicApiControllers();
}
}
}
特别注意

.AddDynamicApiControllers() 必须在 services.AddControllers() 之后注册。

5.5 第一个例子

创建一个 FurAppService 类继承 IDynamicApiController 接口 或 贴 [DynamicApiController] 特性,并在这个类中编写一个 Get 方法。

  • IDynamicApiController 方式
using Fur.DynamicApiController;
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public string Get()
{
return $"Hello {nameof(Fur)}";
}
}
}
  • [DynamicApiController] 方式
using Fur.DynamicApiController;
-
namespace Fur.Application
{
[DynamicApiController]
public class FurAppService
{
public string Get()
{
return $"Hello {nameof(Fur)}";
}
}
}

如下图所示,一个 WebAPI 接口就这么生成了。

5.6 动态 WebAPI 原理解析

5.6.1 控制器特性提供器

Fur 框架会在应用启动时注册 DynamicApiControllerFeatureProvider 控制器特性提供器,该提供器继承自 ControllerFeatureProvider 类。

接着重写 bool IsController(TypeInfo typeInfo) 方法,用来标识控制器类型。在 Fur 框架中,继承自 ControllerBase 类或 IDynamicApiController 接口或 [DynamicApiController] 特性都会被标记为控制器类型。

5.6.2 应用模型转换器

Fur 框架同时在应用启动时注册 DynamicApiControllerApplicationModelConvention 应用模型转换器,该转换器继承自 IApplicationModelConvention 接口。

接着实现 void Apply(ApplicationModel application) 接口方法。在该方法中配置控制器名称、路由、导出可见性及动作方法名称、路由、导出可见性等。

实际上该方法做的就是按照 WebAPI 约定 提前帮我们配置好路由、请求谓词等信息。避免了手动配置的同时还增加了许多新特性,如版本控制。

5.7 动态 WebAPI 配置约定

5.7.1 控制器默认约定

  • 生成控制器名称默认去除以 AppServices,AppService,ApiController,Controller,Services,Service 作为前后缀的字符串。见第一个例子中的 FurAppService -> Fur 支持自定义配置
  • 控制器名称带 V[0-9_] 结尾的,会自动生成控制器版本号,如 FurAppServiceV2 -> Fur@2FurAppServiceV1_1_0 -> Fur@1.1.0支持版本分隔符配置
  • 控制名称以 骆驼命名(CamelCase) 会自动切割成多个单词 - 连接。支持自定义配置

5.7.2 动作方法默认约定

  • 生成的动作方法名称默认去除以 Post/Add/Create/Insert/Submit,GetAll/GetList/Get/Find/Fetch/Query/Search,Put/Update,Delete/Remove/Clear,Patch 开头的字符串。支持自定义配置
  • 生成的动作方法名称默认去除以 Async 作为前后缀的字符串。支持自定义配置
  • 动作方法名称带 V[0-9_] 结尾的,会自动生成动作方法版本号,如 ChangePasswordV2 -> ChangePassword@2ChangePasswordV1_1_0 -> ChangePassword@1.1.0支持版本分隔符配置
  • 动作方法名称以 骆驼命名(CamelCase) 会自动切割成多个单词 - 连接。支持自定义配置
  • 动作方法参数将自动转为小写。支持自定义配置

5.7.3 请求谓词默认约定

  • 动作方法名
    • Post/Add/Create/Insert/Submit 开头,则添加 [HttpPost] 特性。
    • GetAll/GetList/Get/Find/Fetch/Query 开头,则添加 [HttpGet] 特性。
    • Put/Update 开头,则添加 [HttpPut] 特性。
    • Delete/Remove/Clear 开头,则添加 [HttpDelete] 特性。
    • Patch 开头,则添加 [HttpPatch] 特性
    • 支持自定义配置
  • 如果不在上面约定中,则默认添加 [HttpPost] 特性。支持自定义配置

5.7.4 路由地址默认约定

  • 默认以 api 开头。支持自定义配置
  • 默认转换为小写路由地址。支持自定义配置
  • 生成控制器路由模板格式为:api/前置参数列表/模块名或默认区域名/[controller@版本号]/后置参数列表
  • 生成动作方法路由模板格式为:前置参数列表/模块名/[action@版本号]/后置参数列表

5.7.5 其他约定

  • 默认不处理 ControllerBase 控制器类型。支持自定义配置
  • 默认不处理 GET,HEAD 请求的引用类型参数。支持自定义配置

5.8 更多例子

5.8.1 多种请求谓词方法

using Fur.DynamicApiController;
+
namespace Fur.Application
{
[DynamicApiController]
public class FurAppService
{
public string Get()
{
return $"Hello {nameof(Fur)}";
}
}
}

如下图所示,一个 WebAPI 接口就这么生成了。

5.6 动态 WebAPI 原理解析

5.6.1 控制器特性提供器

Fur 框架会在应用启动时注册 DynamicApiControllerFeatureProvider 控制器特性提供器,该提供器继承自 ControllerFeatureProvider 类。

接着重写 bool IsController(TypeInfo typeInfo) 方法,用来标识控制器类型。在 Fur 框架中,继承自 ControllerBase 类或 IDynamicApiController 接口或 [DynamicApiController] 特性都会被标记为控制器类型。

5.6.2 应用模型转换器

Fur 框架同时在应用启动时注册 DynamicApiControllerApplicationModelConvention 应用模型转换器,该转换器继承自 IApplicationModelConvention 接口。

接着实现 void Apply(ApplicationModel application) 接口方法。在该方法中配置控制器名称、路由、导出可见性及动作方法名称、路由、导出可见性等。

实际上该方法做的就是按照 WebAPI 约定 提前帮我们配置好路由、请求谓词等信息。避免了手动配置的同时还增加了许多新特性,如版本控制。

5.7 动态 WebAPI 配置约定

5.7.1 控制器默认约定

  • 生成控制器名称默认去除以 AppServices,AppService,ApiController,Controller,Services,Service 作为前后缀的字符串。见第一个例子中的 FurAppService -> Fur 支持自定义配置
  • 控制器名称带 V[0-9_] 结尾的,会自动生成控制器版本号,如 FurAppServiceV2 -> Fur@2FurAppServiceV1_1_0 -> Fur@1.1.0支持版本分隔符配置
  • 控制名称以 骆驼命名(CamelCase) 会自动切割成多个单词 - 连接。支持自定义配置

5.7.2 动作方法默认约定

  • 生成的动作方法名称默认去除以 Post/Add/Create/Insert/Submit,GetAll/GetList/Get/Find/Fetch/Query/Search,Put/Update,Delete/Remove/Clear,Patch 开头的字符串。支持自定义配置
  • 生成的动作方法名称默认去除以 Async 作为前后缀的字符串。支持自定义配置
  • 动作方法名称带 V[0-9_] 结尾的,会自动生成动作方法版本号,如 ChangePasswordV2 -> ChangePassword@2ChangePasswordV1_1_0 -> ChangePassword@1.1.0支持版本分隔符配置
  • 动作方法名称以 骆驼命名(CamelCase) 会自动切割成多个单词 - 连接。支持自定义配置
  • 动作方法参数将自动转为小写。支持自定义配置

5.7.3 请求谓词默认约定

  • 动作方法名
    • Post/Add/Create/Insert/Submit 开头,则添加 [HttpPost] 特性。
    • GetAll/GetList/Get/Find/Fetch/Query 开头,则添加 [HttpGet] 特性。
    • Put/Update 开头,则添加 [HttpPut] 特性。
    • Delete/Remove/Clear 开头,则添加 [HttpDelete] 特性。
    • Patch 开头,则添加 [HttpPatch] 特性
    • 支持自定义配置
  • 如果不在上面约定中,则默认添加 [HttpPost] 特性。支持自定义配置

5.7.4 路由地址默认约定

  • 默认以 api 开头。支持自定义配置
  • 默认转换为小写路由地址。支持自定义配置
  • 生成控制器路由模板格式为:api/前置参数列表/模块名或默认区域名/[controller@版本号]/后置参数列表
  • 生成动作方法路由模板格式为:前置参数列表/模块名/[action@版本号]/后置参数列表

5.7.5 其他约定

  • 默认不处理 ControllerBase 控制器类型。支持自定义配置
  • 默认不处理 GET,HEAD 请求的引用类型参数。支持自定义配置

5.8 更多例子

5.8.1 多种请求谓词方法

using Fur.DynamicApiController;
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public string Get()
{
return $"GET 请求";
}
public string Post()
{
return $"POST 请求";
}
public string Delete()
{
return $"DELETE 请求";
}
public string Put()
{
return $"PUT 请求";
}
-
public string Patch()
{
return $"PATCH 请求";
}
}
}

如下图所示:

5.8.2 多个自定义动作方法

using Fur.DynamicApiController;
+
public string Patch()
{
return $"PATCH 请求";
}
}
}

如下图所示:

5.8.2 多个自定义动作方法

using Fur.DynamicApiController;
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public string GetVersion()
{
return $"v1.0.0";
}
public string ChangeProfile()
{
return "修改成功";
}
-
public string DeleteUser()
{
return "删除成功";
}
}
}

如下图所示:

5.8.3 带参数动作方法

using Fur.DynamicApiController;
+
public string DeleteUser()
{
return "删除成功";
}
}
}

如下图所示:

5.8.3 带参数动作方法

using Fur.DynamicApiController;
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public string GetUser(int id)
{
return $"{id}";
}
public string GetUser(int id, string name)
{
return $"{id} {name}";
}
-
public TestDto Add(TestDto testDto)
{
return testDto;
}
}
}

如下图所示:

5.8.5 GET/HEAD 类类型参数

默认情况下,ASP.NET Core 会将 GET/HEAD 请求中的 类类型参数 设置为 [FromBody] 绑定,如:

using Fur.DynamicApiController;
-
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public TestDto GetTest(TestDto testDto)
{
return testDto;
}
}
}

如下图所示:

但是,GET、HEAD 请求不支持 From Body 绑定。所以我们需要转换为 Query 查询参数。

Fur 框架支持以下两种方式配置:

using Fur.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
-
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public TestDto GetTest([FromQuery] TestDto testDto)
{
return testDto;
}
}
}

如下图所示:

5.8.6 自定义参数位置

Fur 框架提供了非常方便的自定义参数位置的特性 [ApiSeat],通过 [ApiSeat] 可配置参数位置,支持以下四种位置:

  • ApiSeats.ControllerStart:控制器之前
  • ApiSeats.ControllerEnd:控制器之后
  • ApiSeats.ActionStart:动作方法之前
  • ApiSeats.ActionEnd:动作方法之后。默认值
using Fur.DynamicApiController;
using System;
+
public TestDto Add(TestDto testDto)
{
return testDto;
}
}
}

如下图所示:

5.8.5 GET/HEAD 类类型参数

默认情况下,ASP.NET Core 会将 GET/HEAD 请求中的 类类型参数 设置为 [FromBody] 绑定,如:

using Fur.DynamicApiController;
+
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public TestDto GetTest(TestDto testDto)
{
return testDto;
}
}
}

如下图所示:

但是,GET、HEAD 请求不支持 From Body 绑定。所以我们需要转换为 Query 查询参数。

Fur 框架支持以下两种方式配置:

using Fur.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
+
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public TestDto GetTest([FromQuery] TestDto testDto)
{
return testDto;
}
}
}

如下图所示:

5.8.6 自定义参数位置

Fur 框架提供了非常方便的自定义参数位置的特性 [ApiSeat],通过 [ApiSeat] 可配置参数位置,支持以下四种位置:

  • ApiSeats.ControllerStart:控制器之前
  • ApiSeats.ControllerEnd:控制器之后
  • ApiSeats.ActionStart:动作方法之前
  • ApiSeats.ActionEnd:动作方法之后。默认值
using Fur.DynamicApiController;
using System;
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
// 参数默认为 ApiSeats.ActionEnd
public string RouteSeat(int id, string name)
{
return "配置路由参数位置";
}
-
public string RouteSeat(
[ApiSeat(ApiSeats.ControllerStart)] int id, // 控制器名称之前
[ApiSeat(ApiSeats.ControllerEnd)] string name, // 控制器名称之后
[ApiSeat(ApiSeats.ControllerEnd)] int age, // 控制器名称之后
[ApiSeat(ApiSeats.ActionStart)] decimal weight, // 动作方法名称之前
[ApiSeat(ApiSeats.ActionStart)] float height, // 动作方法名称之前
[ApiSeat(ApiSeats.ActionEnd)] DateTime birthday) // 动作方法名称之后(默认值)
{
return "配置路由参数位置";
}
}
}

如下图所示:

温馨提示

多个 同位置 配置的参数将按照 定义参数顺序 进行排序。

特别注意

[ApiSeat] 只能应用于贴了 [FromRoute] 特性的参数或 基元类型、值类型、可空基元类型和可空值类型

5.8.7 自定义请求谓词

using Fur.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
-
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
[HttpPost]
public string GetVersion()
{
return "1.0.0";
}
}
}

如下图所示:

5.8.8 支持多个谓词

using Fur.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
-
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
[HttpPost, HttpGet, AcceptVerbs("PUT", "DELETE")]
public string GetVersion()
{
return "1.0.0";
}
}
}

如下图所示:

特别注意

如果动作方法中含有 类类型参数,且含有 POST/PUT/DELETE 任意请求谓词,那么该参数会自动添加 [FromBody] 参数,即使在 GET/HEAD 请求中不支持。

5.8.9 支持自定义路由

支持控制器和动作方法自定义路由:

using Fur.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
-
namespace Fur.Application
{
[Route("customapi/mobile/[controller]")]
public class FurAppService : IDynamicApiController
{
public string GetVersion()
{
return "1.0.0";
}
}
}

如下图所示:

小提示

动态方法自定义路由如果以 / 开头,则不会合并控制器路由。

推荐配置

自定义路由如果需要用到 控制器/动作方法名称,推荐使用 [controller][action] 占位符,因为该占位符已经自动处理了 前后缀、版本号、模块名称等。

5.8.10 多路由随意组合

Fur 框架提供了非常灵活的各种路由组合方式,支持一对多,多对多路由组合:

using Fur.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
-
namespace Fur.Application
{
[Route("api/[controller]")]
[Route("api/[controller]/second")]
[Route("api/[controller]/three")]
public class FurAppService : IDynamicApiController
{
[HttpGet]
[HttpGet("get/[action]")]
[HttpPost]
[HttpPost("post/cus-version")]
public string GetVersion()
{
return "1.0.0";
}
}
}

如下图所示:

特别注意

动作方法不能同时贴 [Route][HttpMethod] 特性,只能二取一。

5.8.11 支持版本控制

using Fur.DynamicApiController;
+
public string RouteSeat(
[ApiSeat(ApiSeats.ControllerStart)] int id, // 控制器名称之前
[ApiSeat(ApiSeats.ControllerEnd)] string name, // 控制器名称之后
[ApiSeat(ApiSeats.ControllerEnd)] int age, // 控制器名称之后
[ApiSeat(ApiSeats.ActionStart)] decimal weight, // 动作方法名称之前
[ApiSeat(ApiSeats.ActionStart)] float height, // 动作方法名称之前
[ApiSeat(ApiSeats.ActionEnd)] DateTime birthday) // 动作方法名称之后(默认值)
{
return "配置路由参数位置";
}
}
}

如下图所示:

温馨提示

多个 同位置 配置的参数将按照 定义参数顺序 进行排序。

特别注意

[ApiSeat] 只能应用于贴了 [FromRoute] 特性的参数或 基元类型、值类型、可空基元类型和可空值类型

5.8.7 自定义请求谓词

using Fur.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
+
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
[HttpPost]
public string GetVersion()
{
return "1.0.0";
}
}
}

如下图所示:

5.8.8 支持多个谓词

using Fur.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
+
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
[HttpPost, HttpGet, AcceptVerbs("PUT", "DELETE")]
public string GetVersion()
{
return "1.0.0";
}
}
}

如下图所示:

特别注意

如果动作方法中含有 类类型参数,且含有 POST/PUT/DELETE 任意请求谓词,那么该参数会自动添加 [FromBody] 参数,即使在 GET/HEAD 请求中不支持。

5.8.9 支持自定义路由

支持控制器和动作方法自定义路由:

using Fur.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
+
namespace Fur.Application
{
[Route("customapi/mobile/[controller]")]
public class FurAppService : IDynamicApiController
{
public string GetVersion()
{
return "1.0.0";
}
}
}

如下图所示:

小提示

动态方法自定义路由如果以 / 开头,则不会合并控制器路由。

推荐配置

自定义路由如果需要用到 控制器/动作方法名称,推荐使用 [controller][action] 占位符,因为该占位符已经自动处理了 前后缀、版本号、模块名称等。

5.8.10 多路由随意组合

Fur 框架提供了非常灵活的各种路由组合方式,支持一对多,多对多路由组合:

using Fur.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
+
namespace Fur.Application
{
[Route("api/[controller]")]
[Route("api/[controller]/second")]
[Route("api/[controller]/three")]
public class FurAppService : IDynamicApiController
{
[HttpGet]
[HttpGet("get/[action]")]
[HttpPost]
[HttpPost("post/cus-version")]
public string GetVersion()
{
return "1.0.0";
}
}
}

如下图所示:

特别注意

动作方法不能同时贴 [Route][HttpMethod] 特性,只能二取一。

5.8.11 支持版本控制

using Fur.DynamicApiController;
namespace Fur.Application
{
public class FurAppServiceV1 : IDynamicApiController
{
public string Get()
{
return nameof(Fur);
}
}
public class FurAppServiceV1_2 : IDynamicApiController
{
public string Get()
{
return nameof(Fur);
}
}
-
public class FurAppServiceV1_2_1 : IDynamicApiController
{
public string Get()
{
return nameof(Fur);
}
}
}

如下图所示:

版本生成原理

V[0-9_] 结尾的命名自动解析成版本号,如 FurAppServiceV2 -> Fur@2

版本复写

除了通过特定后缀方式以外,版本还直接通过 [ApiDescriptionSettings] 进行复写。如:

[ApiDescriptionSettings(Version = "4.0")]
public string GetV1()
{
return nameof(Fur);
}

这时,生成版本将采用 4.0 替代 1

5.8.12 不公开控制器或动作方法

有些时候,我们无需导出某个动作方法或控制器,只需要添加 [ApiDescriptionSettings(false)][ApiExplorerSettings(IgnoreApi = true)]即可。

另外动作方法还支持 [NonAction] 标记。

推荐使用

推荐控制器或动作方法设置不导出使用 [ApiDescriptionSettings(false)] 特性。该特性默认继承自 ApiExplorerSettingsAttribute 类。

5.9 [ApiDescriptionSettings]

除了上述 ASP.NET Core 提供的配置外,Fur 框架还提供了非常强大且灵活的 [ApiDescriptionSettings] 特性。

5.9.1 内置配置

  • Name:自定义控制器/动作方法名称,string,默认 null
  • KeepName:是否保持原有名称不处理,bool,默认 false
  • SplitCamelCase:切割骆驼命名,bool,默认 true
  • KeepVerb:是否保留动作方法请求谓词,bool,默认 false
  • Enabled:是否导出接口,bool,默认 true
  • Module:模块名,string,默认 null
  • Version:版本号,string,默认 null
  • Groups:接口分组,可结合 Swagger 一起使用,string[],默认 null
  • Tags:接口标签,可结合 Swagger 一起使用,string[],默认 null
  • AuthPolicies:授权策略,可结合 授权,JWT 一起使用,string[],默认 null

5.9.2 Name 配置

Name 参数可以覆盖动态 WebAPI 自动生成的控制器或动作方法名称。如:

using Fur.DynamicApiController;
-
namespace Fur.Application
{
[ApiDescriptionSettings(Name = "MyFur")]
public class FurAppService : IDynamicApiController
{
[ApiDescriptionSettings(Name = "MyGet")]
public string Get()
{
return nameof(Fur);
}
}
}

如下图所示:

5.9.3 KeepName 配置

KeepName 参数可以保留原有的控制器或动作方法名称。如:

using Fur.DynamicApiController;
-
namespace Fur.Application
{
[ApiDescriptionSettings(KeepName = true)]
public class FurAppService : IDynamicApiController
{
[ApiDescriptionSettings(KeepName = true)]
public string Get()
{
return nameof(Fur);
}
}
}

如下图所示:

5.9.4 SplitCamelCase 配置

SplitCamelCase 参数默认将骆驼命名切割成多个单词并通过指定 占位符 连接起来。默认 占位符-。默认为 true。如:

using Fur.DynamicApiController;
-
namespace Fur.Application
{
[ApiDescriptionSettings(SplitCamelCase = false)]
public class MyFurAppService : IDynamicApiController
{
[ApiDescriptionSettings(SplitCamelCase = true)]
public string ChangeUserName()
{
return nameof(Fur);
}
}
}

如下图所示:

特别注意

KeepName 优先级高于 SplitCamelCase,也就是 KeepName 设置为 true,则不会处理 SplitCamelCase 参数。

5.9.5 KeepVerb 配置

KeepVerb 参数作用于动作方法,标识是否保留动作谓词。如:

using Fur.DynamicApiController;
-
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
[ApiDescriptionSettings(KeepVerb = true)]
public string GetVersion()
{
return nameof(Fur);
}
}
}

如下图所示:

5.9.6 Enabled 配置

Enabled 参数配置接口是否导出。通常用于动作方法,如果用于控制器实际作用不大。

using Fur.DynamicApiController;
+
public class FurAppServiceV1_2_1 : IDynamicApiController
{
public string Get()
{
return nameof(Fur);
}
}
}

如下图所示:

版本生成原理

V[0-9_] 结尾的命名自动解析成版本号,如 FurAppServiceV2 -> Fur@2

版本复写

除了通过特定后缀方式以外,版本还直接通过 [ApiDescriptionSettings] 进行复写。如:

[ApiDescriptionSettings(Version = "4.0")]
public string GetV1()
{
return nameof(Fur);
}

这时,生成版本将采用 4.0 替代 1

5.8.12 不公开控制器或动作方法

有些时候,我们无需导出某个动作方法或控制器,只需要添加 [ApiDescriptionSettings(false)][ApiExplorerSettings(IgnoreApi = true)]即可。

另外动作方法还支持 [NonAction] 标记。

推荐使用

推荐控制器或动作方法设置不导出使用 [ApiDescriptionSettings(false)] 特性。该特性默认继承自 ApiExplorerSettingsAttribute 类。

5.9 [ApiDescriptionSettings]

除了上述 ASP.NET Core 提供的配置外,Fur 框架还提供了非常强大且灵活的 [ApiDescriptionSettings] 特性。

5.9.1 内置配置

  • Name:自定义控制器/动作方法名称,string,默认 null
  • KeepName:是否保持原有名称不处理,bool,默认 false
  • SplitCamelCase:切割骆驼命名,bool,默认 true
  • KeepVerb:是否保留动作方法请求谓词,bool,默认 false
  • Enabled:是否导出接口,bool,默认 true
  • Module:模块名,string,默认 null
  • Version:版本号,string,默认 null
  • Groups:接口分组,可结合 Swagger 一起使用,string[],默认 null
  • Tags:接口标签,可结合 Swagger 一起使用,string[],默认 null
  • AuthPolicies:授权策略,可结合 授权,JWT 一起使用,string[],默认 null

5.9.2 Name 配置

Name 参数可以覆盖动态 WebAPI 自动生成的控制器或动作方法名称。如:

using Fur.DynamicApiController;
+
namespace Fur.Application
{
[ApiDescriptionSettings(Name = "MyFur")]
public class FurAppService : IDynamicApiController
{
[ApiDescriptionSettings(Name = "MyGet")]
public string Get()
{
return nameof(Fur);
}
}
}

如下图所示:

5.9.3 KeepName 配置

KeepName 参数可以保留原有的控制器或动作方法名称。如:

using Fur.DynamicApiController;
+
namespace Fur.Application
{
[ApiDescriptionSettings(KeepName = true)]
public class FurAppService : IDynamicApiController
{
[ApiDescriptionSettings(KeepName = true)]
public string Get()
{
return nameof(Fur);
}
}
}

如下图所示:

5.9.4 SplitCamelCase 配置

SplitCamelCase 参数默认将骆驼命名切割成多个单词并通过指定 占位符 连接起来。默认 占位符-。默认为 true。如:

using Fur.DynamicApiController;
+
namespace Fur.Application
{
[ApiDescriptionSettings(SplitCamelCase = false)]
public class MyFurAppService : IDynamicApiController
{
[ApiDescriptionSettings(SplitCamelCase = true)]
public string ChangeUserName()
{
return nameof(Fur);
}
}
}

如下图所示:

特别注意

KeepName 优先级高于 SplitCamelCase,也就是 KeepName 设置为 true,则不会处理 SplitCamelCase 参数。

5.9.5 KeepVerb 配置

KeepVerb 参数作用于动作方法,标识是否保留动作谓词。如:

using Fur.DynamicApiController;
+
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
[ApiDescriptionSettings(KeepVerb = true)]
public string GetVersion()
{
return nameof(Fur);
}
}
}

如下图所示:

5.9.6 Enabled 配置

Enabled 参数配置接口是否导出。通常用于动作方法,如果用于控制器实际作用不大。

using Fur.DynamicApiController;
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public string GetVersion()
{
return nameof(Fur);
}
-
[ApiDescriptionSettings(false)]
public string NoExport()
{
return nameof(Fur);
}
}
}

如下图所示:

5.9.7 Module 配置

Module 参数可以配置路由分离,类似于 Mvc 区域 的作用。

using Fur.DynamicApiController;
-
namespace Fur.Application
{
[ApiDescriptionSettings(Module = "mobile")]
public class FurAppService : IDynamicApiController
{
[ApiDescriptionSettings(Module = "user")]
public string GetVersion()
{
return nameof(Fur);
}
}
}

如下图所示:

5.9.8 Version 配置

Version 参数可以配置接口版本,同时又可以复写特殊版本命名配置。默认版本号分隔符为 @。如:

using Fur.DynamicApiController;
-
namespace Fur.Application
{
[ApiDescriptionSettings(Version = "1.0")]
public class FurAppService : IDynamicApiController
{
// V2.0.0 被复写成 V2.1.1
[ApiDescriptionSettings(Version = "2.1.1")]
public string GetVersionV2_0_0()
{
return nameof(Fur);
}
}
}

如下图所示:

5.9.9 Groups 配置

Groups 配置主要用于配置 Swagger 分组信息。

通过配置 Groups 参数可以将控制器和动作方法 进行归类和多个分组直接共享。可通过 [ApiDescriptionSettings(params Groups)] 构造函数传入或指定 Groups 参数配置接口是否导出。通常用于动作方法,如果用于控制器实际作用不大。

using Fur.DynamicApiController;
+
[ApiDescriptionSettings(false)]
public string NoExport()
{
return nameof(Fur);
}
}
}

如下图所示:

5.9.7 Module 配置

Module 参数可以配置路由分离,类似于 Mvc 区域 的作用。

using Fur.DynamicApiController;
+
namespace Fur.Application
{
[ApiDescriptionSettings(Module = "mobile")]
public class FurAppService : IDynamicApiController
{
[ApiDescriptionSettings(Module = "user")]
public string GetVersion()
{
return nameof(Fur);
}
}
}

如下图所示:

5.9.8 Version 配置

Version 参数可以配置接口版本,同时又可以复写特殊版本命名配置。默认版本号分隔符为 @。如:

using Fur.DynamicApiController;
+
namespace Fur.Application
{
[ApiDescriptionSettings(Version = "1.0")]
public class FurAppService : IDynamicApiController
{
// V2.0.0 被复写成 V2.1.1
[ApiDescriptionSettings(Version = "2.1.1")]
public string GetVersionV2_0_0()
{
return nameof(Fur);
}
}
}

如下图所示:

5.9.9 Groups 配置

Groups 配置主要用于配置 Swagger 分组信息。

通过配置 Groups 参数可以将控制器和动作方法 进行归类和多个分组直接共享。可通过 [ApiDescriptionSettings(params Groups)] 构造函数传入或指定 Groups 参数配置接口是否导出。通常用于动作方法,如果用于控制器实际作用不大。

using Fur.DynamicApiController;
namespace Fur.Application
{
[ApiDescriptionSettings("Default", "Common")]
public class FurAppService : IDynamicApiController
{
public string Get()
{
return nameof(Fur);
}
-
[ApiDescriptionSettings("Custom")]
public int Get(int id)
{
return id;
}
}
}

如下图所示:

5.9.10 Tag 配置

Tag 配置主要用于配置 Swagger 标签分组信息及合并标签。也就是 组中组:

未贴标签之前

using Fur.DynamicApiController;
+
[ApiDescriptionSettings("Custom")]
public int Get(int id)
{
return id;
}
}
}

如下图所示:

5.9.10 Tag 配置

Tag 配置主要用于配置 Swagger 标签分组信息及合并标签。也就是 组中组:

未贴标签之前

using Fur.DynamicApiController;
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public string Get()
{
return nameof(Fur);
}
public int Get(int id)
{
return id;
}
}
public class TestAppService : IDynamicApiController
{
public string Get()
{
return nameof(Fur);
}
@@ -63,19 +63,19 @@
namespace Fur.Application
{
[ApiDescriptionSettings(Tag = "分组一")]
public class FurAppService : IDynamicApiController
{
public string Get()
{
return nameof(Fur);
}
public int Get(int id)
{
return id;
}
}
[ApiDescriptionSettings(Tag = "分组二")]
public class TestAppService : IDynamicApiController
{
public string Get()
{
return nameof(Fur);
}
-
public int Get(int id)
{
return id;
}
}
}

如下图所示:

小知识

如果 Tag 名字一样,则会自动合并,否则只是命名。

5.10 DynamicApiControllerSettings 配置

Fur 还提供动态 WebAPI 接口一些全局配置选项,如:

  • DefaultRoutePrefix:默认路由前缀,string,默认 api
  • DefaultHttpMethod:默认请求谓词,string,默认:POST
  • DefaultModule:默认模块名称(区域),可用作接口版本,string,默认:v1
  • LowercaseRoute:小写路由格式,bool,默认:true
  • KeepVerb:是否保留动作谓词,bool,默认:false
  • CamelCaseSeparator:骆驼命名分隔符,string,默认:-
  • VersionSeparator:版本分隔符,string,默认:@
  • ModelToQueryGET/HEAD 请求将 类类型参数转查询参数bool,默认 false
  • SupportedMvcController:是否支持 Mvc Controller 动态配置,bool,默认 false
  • AbandonControllerAffixes:默认去除控制器名称前后缀列表名,string[],默认:
    • AppServices
    • AppService
    • ApiController
    • Controller
    • Services
    • Service
  • AbandonActionAffixes:默认去除动作方法名称前后缀列表名,string[],默认:
    • Async

5.10.1 支持 Mvc 控制器 动态配置

默认情况下,Fur 动态 WebAPI 接口不对 ControllerBase 类型进行任何处理。当然,我们也可以手动启用 ControllerBase 支持。

Fur.Web.Entry/appsettings.json
{
"AppSettings": {
"DynamicApiControllerSettings": {
"SupportedMvcController": true
}
}
}

设置 SupportedMvcController: true 后,Mvc ControllerBase 类型也能和动态 WebAPI 一样的灵活了。代码如下:

using Microsoft.AspNetCore.Mvc;
+
public int Get(int id)
{
return id;
}
}
}

如下图所示:

小知识

如果 Tag 名字一样,则会自动合并,否则只是命名。

5.10 DynamicApiControllerSettings 配置

Fur 还提供动态 WebAPI 接口一些全局配置选项,如:

  • DefaultRoutePrefix:默认路由前缀,string,默认 api
  • DefaultHttpMethod:默认请求谓词,string,默认:POST
  • DefaultModule:默认模块名称(区域),可用作接口版本,string,默认:v1
  • LowercaseRoute:小写路由格式,bool,默认:true
  • KeepVerb:是否保留动作谓词,bool,默认:false
  • CamelCaseSeparator:骆驼命名分隔符,string,默认:-
  • VersionSeparator:版本分隔符,string,默认:@
  • ModelToQueryGET/HEAD 请求将 类类型参数转查询参数bool,默认 false
  • SupportedMvcController:是否支持 Mvc Controller 动态配置,bool,默认 false
  • AbandonControllerAffixes:默认去除控制器名称前后缀列表名,string[],默认:
    • AppServices
    • AppService
    • ApiController
    • Controller
    • Services
    • Service
  • AbandonActionAffixes:默认去除动作方法名称前后缀列表名,string[],默认:
    • Async

5.10.1 支持 Mvc 控制器 动态配置

默认情况下,Fur 动态 WebAPI 接口不对 ControllerBase 类型进行任何处理。当然,我们也可以手动启用 ControllerBase 支持。

Fur.Web.Entry/appsettings.json
{
"AppSettings": {
"DynamicApiControllerSettings": {
"SupportedMvcController": true
}
}
}

设置 SupportedMvcController: true 后,Mvc ControllerBase 类型也能和动态 WebAPI 一样的灵活了。代码如下:

using Microsoft.AspNetCore.Mvc;
namespace Fur.Web.Entry.Controllers
{
public class MvcController : ControllerBase
{
public string Get()
{
return nameof(Fur);
}
}
}
-
注意事项

启用该配置后,如果 Mvc 控制器 没有任何 [Route] 特性,但是贴了 [ApiController] 特性将会报错。原因是 [ApiController] 特性内部做了路由特性检测。所以建议使用 [ApiDataValidation] 代替。

查看 ASP.NET Core - ApiBehaviorApplicationModelProvider 源码

5.11 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
注意事项

启用该配置后,如果 Mvc 控制器 没有任何 [Route] 特性,但是贴了 [ApiController] 特性将会报错。原因是 [ApiController] 特性内部做了路由特性检测。所以建议使用 [ApiDataValidation] 代替。

查看 ASP.NET Core - ApiBehaviorApplicationModelProvider 源码

5.11 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/entity/index.html b/handbook/build/docs/entity/index.html index df1379251ce..066c2d98fa7 100644 --- a/handbook/build/docs/entity/index.html +++ b/handbook/build/docs/entity/index.html @@ -4,22 +4,22 @@ -9.3 数据库实体 | Fur - - - - - - - - - - - +9.3 数据库实体 | Fur + + + + + + + + + + +
-

9.3 数据库实体

9.3.1 数据库实体

在面向对象开发思想中,最重要尤为对象二字,在 .NET 开发过去,操作数据库往往采用 DataTableDataSet 来接收数据库返回结果集,而操作数据库也离不开手写 sql 语句。

在过去面向过程和应用不发达的时代,这些操作确实好使。然后随着中国互联网网民的激增,电子化时代的到来,各行各业对应用需求也达到了前所未有的量级。

所以,在过去手写 sql 的时代各种问题显露无疑:

  • 程序员能力参差不齐,写出的 sql 性能自然也天差地别
  • sql 属于字符串硬编程,后期维护难上加难
  • 许多单表甚至多表结构一致,出现大量重复 sql 代码
  • sql 本身在不同的数据库提供器中写法有差,后续迁移头痛不已

当然,sql 是时代的产物,我们也离不开 sql,但对于大多数程序员和项目来说,sql 未必能够带给他们多大的效益。

所以,ORM 就诞生了,所谓的 ORM 就是对象关系映射,英文:Object Relational Mapping,简单点说,ORM 根据特有的 POCO 贫血模型 规则生成 sql 语句。大大避免了重复 sqlsql 能力参差不齐等问题。(当然 ORM 作者 sql 能力也会影响最终性能)

上面所说的 POCO 贫血模型正是我们本章节的 数据库实体

简单来说,数据库实体就是数据库表的类表现,通过一定的规则使这个类能够一一对应表结构。通常这样的类也称为:POCO 贫血模型,也就是只有定义,没有行为。

9.3.2 如何定义实体

Fur 框架提供多种定义实体的接口依赖:

  • IEntity:实体基接口,是所有实体的基接口
  • IEntityNotKey:无键实体接口,也就是视图、存储过程、函数依赖接口
  • EntityBase:实体基抽象类,内置了 IdTenantId 字段
  • Entity:实体通用抽象类,继承自 EntityBase,同时内置 CreatedTimeUpdatedTimeIsDeleted 字段
  • EntityNotKey:无键实体抽象类,视图、存储过程、函数依赖抽象类
实体定义位置

Fur 框架中有约定,实体统一定义在 Fur.Core 层。

9.3.2.1 实体继承选用原则

  • 如果你不需要 Fur 为实体添加任何内置特性,选用 IEntity,无键实体选用 IEntityNotKey
  • 如果你只需要 Id 属性,选用 EntityBase
  • 如果你需要 Fur 为你自动添加常用字段,则选用 Entity
  • 如果你需要视图、存储过程、函数可以通过 DbSet 操作,则继承 EntityNotKey

9.3.2.2 IEntity 示范:

using Fur.DatabaseAccessor;
+

9.3 数据库实体

9.3.1 数据库实体

在面向对象开发思想中,最重要尤为对象二字,在 .NET 开发过去,操作数据库往往采用 DataTableDataSet 来接收数据库返回结果集,而操作数据库也离不开手写 sql 语句。

在过去面向过程和应用不发达的时代,这些操作确实好使。然后随着中国互联网网民的激增,电子化时代的到来,各行各业对应用需求也达到了前所未有的量级。

所以,在过去手写 sql 的时代各种问题显露无疑:

  • 程序员能力参差不齐,写出的 sql 性能自然也天差地别
  • sql 属于字符串硬编程,后期维护难上加难
  • 许多单表甚至多表结构一致,出现大量重复 sql 代码
  • sql 本身在不同的数据库提供器中写法有差,后续迁移头痛不已

当然,sql 是时代的产物,我们也离不开 sql,但对于大多数程序员和项目来说,sql 未必能够带给他们多大的效益。

所以,ORM 就诞生了,所谓的 ORM 就是对象关系映射,英文:Object Relational Mapping,简单点说,ORM 根据特有的 POCO 贫血模型 规则生成 sql 语句。大大避免了重复 sqlsql 能力参差不齐等问题。(当然 ORM 作者 sql 能力也会影响最终性能)

上面所说的 POCO 贫血模型正是我们本章节的 数据库实体

简单来说,数据库实体就是数据库表的类表现,通过一定的规则使这个类能够一一对应表结构。通常这样的类也称为:POCO 贫血模型,也就是只有定义,没有行为。

9.3.2 如何定义实体

Fur 框架提供多种定义实体的接口依赖:

  • IEntity:实体基接口,是所有实体的基接口
  • IEntityNotKey:无键实体接口,也就是视图、存储过程、函数依赖接口
  • EntityBase:实体基抽象类,内置了 IdTenantId 字段
  • Entity:实体通用抽象类,继承自 EntityBase,同时内置 CreatedTimeUpdatedTimeIsDeleted 字段
  • EntityNotKey:无键实体抽象类,视图、存储过程、函数依赖抽象类
实体定义位置

Fur 框架中有约定,实体统一定义在 Fur.Core 层。

9.3.2.1 实体继承选用原则

  • 如果你不需要 Fur 为实体添加任何内置特性,选用 IEntity,无键实体选用 IEntityNotKey
  • 如果你只需要 Id 属性,选用 EntityBase
  • 如果你需要 Fur 为你自动添加常用字段,则选用 Entity
  • 如果你需要视图、存储过程、函数可以通过 DbSet 操作,则继承 EntityNotKey

9.3.2.2 IEntity 示范:

using Fur.DatabaseAccessor;
namespace Fur.Core
{
public class User : IEntity
{
/// <summary>
/// 手工定义 Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
}
}

9.3.2.2 EntityBase 示范:

using Fur.DatabaseAccessor;
namespace Fur.Core
{
public class User : EntityBase
{
// 无需定义 Id 属性
@@ -32,17 +32,17 @@
namespace Fur.Core
{
public class User : Entity, IEntityTypeBuilder<User>
{
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
// 配置数据库实体
public void Configure(EntityTypeBuilder<User> entityBuilder, DbContext dbContext, Type dbContextLocator)
{
entityBuilder.HasKey(u => u.Id);
entityBuilder.HasIndex(u => u.Name);
}
}
}

9.3.3.2 在任何实例类中配置

using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
-
namespace Fur.Core
{
public class SomeClass : IEntityTypeBuilder<User>
{
public void Configure(EntityTypeBuilder<User> entityBuilder, DbContext dbContext, Type dbContextLocator)
{
entityBuilder.HasKey(u => u.Id);
entityBuilder.HasIndex(u => u.Name);
}
}
}

如,上面例子,通过 SomeClass 配置 User 数据库实体。

9.3.4 数据库实体配置说明

Fur 框架会自动扫描所有继承 IEntity 接口的类进行 DbSet<TEntity> 注册,也就是实现自动配置 DbContextOnModelCreating

如果需要跳过自动注册,只需要贴 [NonAutomatic][SkipScan] 特性即可。一旦贴了次特性,那么就需要手动配置 DbContextOnModelCreating

9.3.5 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
namespace Fur.Core
{
public class SomeClass : IEntityTypeBuilder<User>
{
public void Configure(EntityTypeBuilder<User> entityBuilder, DbContext dbContext, Type dbContextLocator)
{
entityBuilder.HasKey(u => u.Id);
entityBuilder.HasIndex(u => u.Name);
}
}
}

如,上面例子,通过 SomeClass 配置 User 数据库实体。

9.3.4 数据库实体配置说明

Fur 框架会自动扫描所有继承 IEntity 接口的类进行 DbSet<TEntity> 注册,也就是实现自动配置 DbContextOnModelCreating

如果需要跳过自动注册,只需要贴 [NonAutomatic][SkipScan] 特性即可。一旦贴了次特性,那么就需要手动配置 DbContextOnModelCreating

9.3.5 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/errors/index.html b/handbook/build/docs/errors/index.html index 7484704b70d..42cfa4ff1e4 100644 --- a/handbook/build/docs/errors/index.html +++ b/handbook/build/docs/errors/index.html @@ -4,32 +4,32 @@ -29.2 常见错误 | Fur - - - - - - - - - - - +29.2 常见错误 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/event-bus/index.html b/handbook/build/docs/event-bus/index.html index 9e71a3d5e5c..49824ae94f9 100644 --- a/handbook/build/docs/event-bus/index.html +++ b/handbook/build/docs/event-bus/index.html @@ -4,32 +4,32 @@ -18. 事件总线 | Fur - - - - - - - - - - - +18. 事件总线 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/friendly-exception/index.html b/handbook/build/docs/friendly-exception/index.html index cd6b9131e79..037bbae6e5f 100644 --- a/handbook/build/docs/friendly-exception/index.html +++ b/handbook/build/docs/friendly-exception/index.html @@ -4,27 +4,27 @@ -7. 友好异常处理 | Fur - - - - - - - - - - - +7. 友好异常处理 | Fur + + + + + + + + + + +
-

7. 友好异常处理

7.1 什么是异常

异常一般是指运行期(此处特指 Exception 类)会发生的导致程序意外中止的问题,是一种对问题的描述后的封装对象。

在过去开发中,通常异常由系统运行时出错抛出,但现在的开发过程中,我们应在程序开发中合理的抛出异常,比如更新一条不存在的实体,或查询一个不存在的数据等等。

7.2 处理异常方式

  • 不处理,直接中断程序执行(不推荐)
  • 通过 try catch finally 处理(不推荐)
  • 全局统一处理,并记录异常信息(推荐)
  • 异常注解方式处理,支持本地化 (推荐)

7.3 什么是友好异常处理

7.3.1 非友好异常处理

在了解友好异常处理之前可以看看非友好异常处理:

  • 对终端用户抛出 500状态码 堆栈信息
  • 大量的 try catch 代码,污染正常业务逻辑
  • 没有规范化的异常状态码和异常消息管理
  • 没有异常日志收集记录
  • 不支持异常消息本地化处理
  • 不支持异常策略,失败后程序立即终止
  • 不支持分布式事务 CAP
  • 不支持异常传播
  • 返回的异常格式杂乱

7.3.2 友好异常处理

  • 对终端用户提示友好
  • 对后端开发人员提供详细的异常堆栈
  • 不干扰正常业务逻辑代码,如 没有 try catch 代码
  • 支持异常状态码多方设置
  • 支持异常消息本地化
  • 异常信息统一配置管理
  • 支持异常策略,如重试
  • 支持异常日志收集记录
  • 支持 CAP 分布式事务关联
  • 支持内部异常外部传播
  • 支持返回统一的异常格式数据

7.4 友好异常处理使用示例

Fur 框架提供了非常灵活的友好异常处理方式。

7.4.1 注册友好异常服务

Fur.Web.Core\FurWebCoreStartup.cs
using Microsoft.Extensions.DependencyInjection;
+

7. 友好异常处理

7.1 什么是异常

异常一般是指运行期(此处特指 Exception 类)会发生的导致程序意外中止的问题,是一种对问题的描述后的封装对象。

在过去开发中,通常异常由系统运行时出错抛出,但现在的开发过程中,我们应在程序开发中合理的抛出异常,比如更新一条不存在的实体,或查询一个不存在的数据等等。

7.2 处理异常方式

  • 不处理,直接中断程序执行(不推荐)
  • 通过 try catch finally 处理(不推荐)
  • 全局统一处理,并记录异常信息(推荐)
  • 异常注解方式处理,支持本地化 (推荐)

7.3 什么是友好异常处理

7.3.1 非友好异常处理

在了解友好异常处理之前可以看看非友好异常处理:

  • 对终端用户抛出 500状态码 堆栈信息
  • 大量的 try catch 代码,污染正常业务逻辑
  • 没有规范化的异常状态码和异常消息管理
  • 没有异常日志收集记录
  • 不支持异常消息本地化处理
  • 不支持异常策略,失败后程序立即终止
  • 不支持分布式事务 CAP
  • 不支持异常传播
  • 返回的异常格式杂乱

7.3.2 友好异常处理

  • 对终端用户提示友好
  • 对后端开发人员提供详细的异常堆栈
  • 不干扰正常业务逻辑代码,如 没有 try catch 代码
  • 支持异常状态码多方设置
  • 支持异常消息本地化
  • 异常信息统一配置管理
  • 支持异常策略,如重试
  • 支持异常日志收集记录
  • 支持 CAP 分布式事务关联
  • 支持内部异常外部传播
  • 支持返回统一的异常格式数据

7.4 友好异常处理使用示例

Fur 框架提供了非常灵活的友好异常处理方式。

7.4.1 注册友好异常服务

Fur.Web.Core\FurWebCoreStartup.cs
using Microsoft.Extensions.DependencyInjection;
namespace Fur.Web.Core
{
[AppStartup(800)]
public sealed class FurWebCoreStartup : AppStartup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers()
.AddFriendlyException();
}
}
}
特别注意

.AddFriendlyException() 需在 services.AddControllers() 之后注册。

7.4.2 两个例子

简单抛个异常

using Fur.DynamicApiController;
using Fur.FriendlyException;
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public int Get(int id)
{
if (id < 3)
{
throw Oops.Oh($"{id} 不能小于3");
}
-
return id;
}
}
}

如下图所示:

抛出特定类型异常

using Fur.DynamicApiController;
using Fur.FriendlyException;
using System;
+
return id;
}
}
}

如下图所示:

抛出特定类型异常

using Fur.DynamicApiController;
using Fur.FriendlyException;
using System;
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public int Get(int id)
{
if (id < 3)
{
throw Oops.Oh($"{id} 不能小于3。", typeof(InvalidOperationException));
}
-
return id;
}
}
}

如下图所示:

7.5 关于 Oops.Oh

通过上面的例子可以看出,Oops.Oh(errorMessage) 可以结合 throw 抛出异常。对于熟悉C#的人员来说,throw 后面只能 Exception 实例。Oops.Oh(...) 方法返回正是 Exception 实例。

7.6.1 为什么起这个名字?

这个名字来源于一个英语句子:Oh, Oops!,意思是 噢(哎),出错了!,所以就有了 Oops.Oh

7.6.2 Oops.Oh 重载方法

using System;
+
return id;
}
}
}

如下图所示:

7.5 关于 Oops.Oh

通过上面的例子可以看出,Oops.Oh(errorMessage) 可以结合 throw 抛出异常。对于熟悉C#的人员来说,throw 后面只能 Exception 实例。Oops.Oh(...) 方法返回正是 Exception 实例。

7.6.1 为什么起这个名字?

这个名字来源于一个英语句子:Oh, Oops!,意思是 噢(哎),出错了!,所以就有了 Oops.Oh

7.6.2 Oops.Oh 重载方法

using System;
namespace Fur.FriendlyException
{
public static class Oops
{
/// <summary>
/// 抛出字符串异常
/// </summary>
/// <param name="errorMessage">异常消息</param>
/// <param name="args">String.Format 参数</param>
/// <returns>异常实例</returns>
public static Exception Oh(string errorMessage, params object[] args);
/// <summary>
/// 抛出字符串异常
/// </summary>
/// <param name="errorMessage">异常消息</param>
/// <param name="exceptionType">具体异常类型</param>
/// <param name="args">String.Format 参数</param>
/// <returns>异常实例</returns>
public static Exception Oh(string errorMessage, Type exceptionType, params object[] args);
/// <summary>
/// 抛出错误码异常
/// </summary>
/// <param name="errorCode">错误码</param>
/// <param name="args">String.Format 参数</param>
/// <returns>异常实例</returns>
public static Exception Oh(object errorCode, params object[] args);
@@ -34,7 +34,7 @@
[ErrorCodeItemMetadata("{0} 发现 {1} 个异常", "百小僧", 2)]
x1001,
[ErrorCodeItemMetadata("服务器运行异常", ErrorCode = "Error")]
SERVER_ERROR
}
}
important

Fur 框架提供了 [ErrorCodeType] 特性和 IErrorCodeTypeProvider 提供器接口来提供异常信息扫描,这里用的是 [ErrorCodeType] 特性类。

7.6.2 关于 [ErrorCodeItemMetadata]

Fur 框架提供了[ErrorCodeItemMetadata] 特性用来标识枚举字段异常元数据,该特性支持传入 消息内容格式化参数。最终会使用 String.Format(消息内容,格式化参数) 进行格式化。

如果消息内容中包含格式化占位符但未指定格式化参数,那么会查找异常所在方法是否贴有 [IfException] 特性且含有格式化参数,接着就会查找 Oops.Oh 中指定的 格式化参数

7.6.3 静态异常类使用

using Fur.DynamicApiController;
using Fur.FriendlyException;
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public int Get(int id)
{
if (id < 3)
{
throw Oops.Oh(ErrorCodes.z1000, id, 3);
}
-
return id;
}
}
}

如下图所示:

7.6.4 更多例子

throw Oops.Oh(1000);
throw Oops.Oh(ErrorCodes.x1000);
throw Oops.Oh("哈哈哈哈");
throw Oops.Oh(errorCode: "x1001");
throw Oops.Oh(1000, typeof(Exception));

7.7 多个异常信息类型

using Fur.FriendlyException;
+
return id;
}
}
}

如下图所示:

7.6.4 更多例子

throw Oops.Oh(1000);
throw Oops.Oh(ErrorCodes.x1000);
throw Oops.Oh("哈哈哈哈");
throw Oops.Oh(errorCode: "x1001");
throw Oops.Oh(1000, typeof(Exception));

7.7 多个异常信息类型

using Fur.FriendlyException;
namespace Fur.Application
{
[ErrorCodeType]
public enum ErrorCodes
{
[ErrorCodeItemMetadata("{0} 不能小于 {1}")]
z1000,
[ErrorCodeItemMetadata("数据不存在")]
x1000,
[ErrorCodeItemMetadata("{0} 发现 {1} 个异常", "百小僧", 2)]
x1001,
@@ -46,23 +46,23 @@
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public int Get(int id)
{
if (id < 3)
{
throw Oops.Oh(5000, id, 3); // 可以将 5000作为常量配置起来
}
return id;
}
}
}
小知识

[ErrorCodeType]IErrorCodeTypeProviderappsettings.json 可以同时使用。

7.10 [IfException] 使用

Fur 框架提供了 [IfException] 特性可以覆盖默认消息配置。也就是覆盖 异常消息类型appsettings.json 中的配置。

特别注意

[IfException] 只能贴在方法上,支持多个,而且该方法所在的类类型必须是 ControllerBase 子类 或 实现 IDynamicApiController 接口。

7.10.1 使用示例

  • 异常消息类定义
[ErrorCodeType]
public static class ErrorCodes
{
[ErrorCodeItemMetadata("{0} 不能小于 {1}")]
z1000
}
  • 覆盖默认配置
using Fur.DynamicApiController;
using Fur.FriendlyException;
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
[IfException(ErrorCodes.z1000, ErrorMessage = "我覆盖了默认的:{0} 不能小于 {1}")]
public int Get(int id)
{
if (id < 3)
{
throw Oops.Oh(ErrorCodes.z1000, id, 3);
}
-
return id;
}
}
}

如下图所示:

7.10.2 更多例子

using Fur.DynamicApiController;
using Fur.FriendlyException;
+
return id;
}
}
}

如下图所示:

7.10.2 更多例子

using Fur.DynamicApiController;
using Fur.FriendlyException;
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
[IfException(ErrorCodes.z1000, ErrorMessage = "我覆盖了默认的:{0} 不能小于 {1}")]
[IfException(ErrorCodes.x1001, "格式化参数1", "格式化参数2", ErrorMessage = "我覆盖了默认的:{0} 不能小于 {1}")]
[IfException(ErrorCodes.x1000, "格式化参数1", "格式化参数2")]
[IfException(ErrorCodes.SERVER_ERROR, "格式化参数1", "格式化参数2")]
public int Get(int id)
{
if (id < 3)
{
throw Oops.Oh(ErrorCodes.z1000, id, 3);
}
return id;
}
}
}
格式化流程

如果消息内容中包含格式化占位符但未指定格式化参数,那么会查找异常所在方法是否贴有 [IfException] 特性且含有格式化参数,接着就会查找 Oops.Oh 中指定的 格式化参数

7.11 异常消息优先级

[ErrorCodeItemMetadata] -> appsettings.json -> [IfException](低 -> 高)

  • [IfException] 会覆盖 appsettings.json 定义的状态码消息。
  • appsettings.json 会覆盖 [ErrorCodeItemMetadata] 定义的消息。

7.12 多语言支持

文档整理中...

7.13 异常模型提供器

Fur 框架提供 规范化结果 功能,可以通过实现 IUnifyResultProvider 提供器实现异常返回值定制,如:RESTfulResultProvider

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using System.Collections.Generic;
namespace Fur.UnifyResult
{
/// <summary>
/// RESTful 风格返回值
/// </summary>
public class RESTfulResultProvider : IUnifyResultProvider
{
/// <summary>
/// 异常返回值
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public IActionResult OnException(ExceptionContext context)
{
return new JsonResult(new RESTfulResult
{
StatusCode = StatusCodes.Status500InternalServerError,
Successed = false,
Data = null,
Errors = context.Exception.Message
});
}
/// <summary>
/// 成功返回值
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public IActionResult OnSuccessed(ActionExecutedContext context)
{
object data;
// 处理内容结果
if (context.Result is ContentResult contentResult) data = contentResult.Content;
// 处理对象结果
else if (context.Result is ObjectResult objectResult) data = objectResult.Value;
else return null;
return new JsonResult(new RESTfulResult
{
StatusCode = context.Result is EmptyResult ? StatusCodes.Status204NoContent : StatusCodes.Status200OK,
Successed = true,
Data = data,
Errors = null
});
}
-
/// <summary>
/// 验证失败返回值
/// </summary>
/// <param name="context"></param>
/// <param name="modelStates"></param>
/// <param name="validationResults"></param>
/// <param name="validateFaildMessage"></param>
/// <returns></returns>
public IActionResult OnValidateFailed(ActionExecutingContext context, ModelStateDictionary modelStates, Dictionary<string, IEnumerable<string>> validationResults, string validateFaildMessage)
{
return new JsonResult(new RESTfulResult
{
StatusCode = StatusCodes.Status400BadRequest,
Successed = false,
Data = null,
Errors = validationResults
});
}
}
}

之后在 Startup.cs 中注册即可:

services.AddControllers().AddUnifyResult<RESTfulResult, RESTfulResultProvider>();

7.14 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
/// <summary>
/// 验证失败返回值
/// </summary>
/// <param name="context"></param>
/// <param name="modelStates"></param>
/// <param name="validationResults"></param>
/// <param name="validateFaildMessage"></param>
/// <returns></returns>
public IActionResult OnValidateFailed(ActionExecutingContext context, ModelStateDictionary modelStates, Dictionary<string, IEnumerable<string>> validationResults, string validateFaildMessage)
{
return new JsonResult(new RESTfulResult
{
StatusCode = StatusCodes.Status400BadRequest,
Successed = false,
Data = null,
Errors = validationResults
});
}
}
}

之后在 Startup.cs 中注册即可:

services.AddControllers().AddUnifyResult<RESTfulResult, RESTfulResultProvider>();

7.14 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/get-start/index.html b/handbook/build/docs/get-start/index.html index cb63da29673..5d65f4aa329 100644 --- a/handbook/build/docs/get-start/index.html +++ b/handbook/build/docs/get-start/index.html @@ -4,29 +4,29 @@ -2. 一分钟入门 | Fur - - - - - - - - - - - +2. 一分钟入门 | Fur + + + + + + + + + + +
-

2. 一分钟入门

2.1 Hello Fur

2.1.1 创建 FurService

设置 Fur.Web.Entry 为启动项,并在 Fur.Application 中创建 FurService 类,并输入以下内容:

using Fur.DynamicApiController;
-
namespace Fur.Application
{
[DynamicApiController] // 这里使用特性方式
public class FurService /*: IDynamicApiController*/ // 也可以使用接口方式
{
/// <summary>
/// 向世界问好
/// </summary>
/// <returns></returns>
public string SayHello()
{
return $"Hello {nameof(Fur)}";
}
}
}

2.1.2 在浏览器中查看效果

Fur.Web.Entry 项目中选择 wwwroot 右键选择在 浏览器中查看

效果如下:

2.2 添加数据库支持

2.2.1 添加 Person 实体类

Fur.Core 中新建 Person 实体类,代码如下:

using Fur.DatabaseAccessor;
using System;
using System.ComponentModel.DataAnnotations;
+

2. 一分钟入门

2.1 Hello Fur

2.1.1 创建 FurService

设置 Fur.Web.Entry 为启动项,并在 Fur.Application 中创建 FurService 类,并输入以下内容:

using Fur.DynamicApiController;
+
namespace Fur.Application
{
[DynamicApiController] // 这里使用特性方式
public class FurService /*: IDynamicApiController*/ // 也可以使用接口方式
{
/// <summary>
/// 向世界问好
/// </summary>
/// <returns></returns>
public string SayHello()
{
return $"Hello {nameof(Fur)}";
}
}
}

2.1.2 在浏览器中查看效果

Fur.Web.Entry 项目中选择 wwwroot 右键选择在 浏览器中查看

效果如下:

2.2 添加数据库支持

2.2.1 添加 Person 实体类

Fur.Core 中新建 Person 实体类,代码如下:

using Fur.DatabaseAccessor;
using System;
using System.ComponentModel.DataAnnotations;
namespace Fur.Core
{
public class Person : Entity // 继承自 Entity 抽象类
{
/// <summary>
/// 构造函数
/// </summary>
public Person()
{
CreatedTime = DateTime.Now;
IsDeleted = false;
}
/// <summary>
/// 姓名
/// </summary>
[MaxLength(32)]
public string Name { get; set; }
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
/// <summary>
/// 住址
/// </summary>
public string Address { get; set; }
}
}

2.2.2 创建数据库上下文

Fur.EntityFramework.Core 中添加 FurDbContext 数据库上下文,代码如下:

using Fur.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
namespace Fur.EntityFramework.Core
{
[AppDbContext("Data Source=./Fur.db")] // 配置连接字符串
public class FurDbContext : AppDbContext<FurDbContext> // 继承 AppDbContext<> 类
{
/// <summary>
/// 继承父类构造函数
/// </summary>
/// <param name="options"></param>
public FurDbContext(DbContextOptions<FurDbContext> options) : base(options)
{
}
}
}

2.2.3 配置数据库上下文

Fur.EntityFramework.CoreFurEntityFrameworkCoreStartup 中配置数据库上下文,代码如下:

Fur\framework\Fur.EntityFramework.Core\FurEntityFrameworkCoreStartup.cs
using Fur.DatabaseAccessor;
using Microsoft.Extensions.DependencyInjection;
-
namespace Fur.EntityFramework.Core
{
[AppStartup(600)]
public sealed class FurEntityFrameworkCoreStartup : AppStartup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddDatabaseAccessor(options =>
{
options.AddDbPool<FurDbContext>(DbProvider.Sqlite);
});
}
}
}
特别说明

Fur 演示示例中,默认已经在 Fur.EntityFramework.Core 层安装了 Microsoft.EntityFrameworkCore.Sqlite 包。

如果你需要安装对应的数据库版本,可以查阅 【9.18 多数据库操作】 章节。

2.2.4 通过命令创建数据库表

打开 程序包管理控制台,如下图所示:

选择 默认项目为Fur.Database.Migrations,如下图所示:

输入以下命令

Add-Migration v0.0.1

提交到数据库更改

Update-Database

2.3 增删查改分页例子

using Fur.Core;
using Fur.DatabaseAccessor;
using Fur.DynamicApiController;
using Mapster;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Threading.Tasks;
+
namespace Fur.EntityFramework.Core
{
[AppStartup(600)]
public sealed class FurEntityFrameworkCoreStartup : AppStartup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddDatabaseAccessor(options =>
{
options.AddDbPool<FurDbContext>(DbProvider.Sqlite);
});
}
}
}
特别说明

Fur 演示示例中,默认已经在 Fur.EntityFramework.Core 层安装了 Microsoft.EntityFrameworkCore.Sqlite 包。

如果你需要安装对应的数据库版本,可以查阅 【9.18 多数据库操作】 章节。

2.2.4 通过命令创建数据库表

打开 程序包管理控制台,如下图所示:

选择 默认项目为Fur.Database.Migrations,如下图所示:

输入以下命令

Add-Migration v0.0.1

提交到数据库更改

Update-Database

2.3 增删查改分页例子

using Fur.Core;
using Fur.DatabaseAccessor;
using Fur.DynamicApiController;
using Mapster;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Fur.Application
{
[DynamicApiController] // 这里使用特性方式
public class FurService /*: IDynamicApiController*/ // 也可以使用接口方式
{
// 初始化仓储
private readonly IRepository<Person> _personRepository;
public FurService(IRepository<Person> personRepository)
{
_personRepository = personRepository;
}
/// <summary>
/// 新增一条
/// </summary>
public async Task<int> Insert(PersonDto personDto)
{
// 如果不需要返回自增Id,使用 InsertAsync即可
var newEntity = await _personRepository.InsertNowAsync(personDto.Adapt<Person>());
return newEntity.Entity.Id;
// 还可以直接操作
// await personDto.Adapt<Person>().InsertNowAsync();
}
@@ -35,20 +35,20 @@
/// <summary>
/// 删除一条
/// </summary>
/// <param name="id"></param>
public async Task Delete(int id)
{
await _personRepository.DeleteAsync(id);
}
/// <summary>
/// 查询一条
/// </summary>
/// <param name="id"></param>
public async Task<PersonDto> Find(int id)
{
var person = await _personRepository.FindAsync(id);
return person.Adapt<PersonDto>();
}
/// <summary>
/// 查询所有
/// </summary>
/// <returns></returns>
public async Task<List<PersonDto>> GetAll()
{
var persons = await _personRepository.AsAsyncEnumerable();
return persons.Adapt<List<PersonDto>>();
}
-
/// <summary>
/// 分页查询
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
public async Task<PagedList<PersonDto>> GetAllByPage(int pageIndex = 1, int pageSize = 10)
{
var pageResult = await _personRepository.AsQueryable().ToPagedListAsync(pageIndex, pageSize);
return pageResult.Adapt<PagedList<PersonDto>>();
}
}
}

附上 PersonDto

using System.ComponentModel.DataAnnotations;
+
/// <summary>
/// 分页查询
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
public async Task<PagedList<PersonDto>> GetAllByPage(int pageIndex = 1, int pageSize = 10)
{
var pageResult = await _personRepository.AsQueryable().ToPagedListAsync(pageIndex, pageSize);
return pageResult.Adapt<PagedList<PersonDto>>();
}
}
}

附上 PersonDto

using System.ComponentModel.DataAnnotations;
namespace Fur.Application
{
public class PersonDto
{
/// <summary>
/// Id
/// </summary>
public int? Id { get; set; }
/// <summary>
/// 姓名
/// </summary>
[StringLength(32, MinimumLength = 2)]
public string Name { get; set; }
-
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
}
}

说好一分钟入门,你们用了多长时间。😁

- - - - - - - - - - - +
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
}
}

说好一分钟入门,你们用了多长时间。😁

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/gooduse/index.html b/handbook/build/docs/gooduse/index.html index e3d0c5a2358..9cdc1c9ab4f 100644 --- a/handbook/build/docs/gooduse/index.html +++ b/handbook/build/docs/gooduse/index.html @@ -4,32 +4,32 @@ -29.3 最佳实践 | Fur - - - - - - - - - - - +29.3 最佳实践 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/grpc/index.html b/handbook/build/docs/grpc/index.html index 17c3497507d..484505193c1 100644 --- a/handbook/build/docs/grpc/index.html +++ b/handbook/build/docs/grpc/index.html @@ -4,32 +4,32 @@ -24. Grpc 服务 | Fur - - - - - - - - - - - +24. Grpc 服务 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/http/index.html b/handbook/build/docs/http/index.html index 6bcdf482032..9f047535544 100644 --- a/handbook/build/docs/http/index.html +++ b/handbook/build/docs/http/index.html @@ -4,32 +4,32 @@ -20. 网络请求 | Fur - - - - - - - - - - - +20. 网络请求 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/index.html b/handbook/build/docs/index.html index 8b7b64b9adc..ab5dadd3faa 100644 --- a/handbook/build/docs/index.html +++ b/handbook/build/docs/index.html @@ -4,32 +4,32 @@ -1.1 介绍 | Fur - - - - - - - - - - - +1.1 介绍 | Fur + + + + + + + + + + +
-

1.1 介绍

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

🌭 开源地址

🍿 Docker 镜像

  • Docker Hub 线上镜像
docker run --name fur -p 5000:80 monksoul/fur:v1.0.0-2020.10.14
  • 手动 打包镜像

打开 CMD/Shell/PowerShell 进入 Fur 项目根目录打包 Fur 镜像:

docker build -t fur:v1.0.0-2020.10.14 .

打包成功后,直接 docker run

docker run --name fur -p 5000:80 fur:v1.0.0-2020.10.14

🥞 架构设计

正在整理中...

🥝 功能模块

🥐 框架依赖

Fur 为了追求极速入门,极致性能,尽可能的不使用或减少第三方依赖。目前 Fur 仅集成了以下三个依赖:

麻雀虽小五脏俱全。Fur 即使只集成了这三个依赖,但是主流的 依赖注入/控制反转AOP 面向切面编程,事件总线数据验证数据库操作 等等一个都不少。

🥗 环境要求

  • Visual Studio 2019 Preview 16.8 +
  • .NET 5 SDK +
  • .Net Standard 2.1 +

🥪 支持平台

  • 运行环境
    • Windows
    • Linux
    • MacOS
    • Docker/K8S/K3S/Rancher
    • Xamarin/MAUI
  • 数据库
    • SqlServer
    • Sqlite
    • Azure Cosmos
    • MySql
    • PostgreSQL
    • InMemoryDatabase
    • Oracle
    • Firebird
    • 达梦数据库
  • 应用部署
    • Kestrel
    • Nginx
    • Jexus
    • IIS
    • Apache
    • PM2
    • Supervisor
    • 单文件
    • 容器(Docker/K8S/K3S/Rancher)

🍖 关于性能

Fur 目前采用 Visual Studio 2019 Preview 16.8 自带性能测试和 JMeter 进行测试,由于篇幅有限,只贴部分测试图,测试结果如下:


🍚 关于作者

一个拥有 12 年开发经验 .NETer。喜欢分享,喜欢新技术,在互联网多个技术领域皆有涉猎。

🍤 项目成员

🎈 欢迎更多的开发者加入 Fur 大家庭。

🍝 他们都在用

  • 百签科技(广东)有限公司
  • 码为科技(广州)有限公司
  • 广州启顺国际货运代理有限公司
  • 森丰供应链服务(广州)有限公司
  • 中山赢友网络科技有限公司
  • 中山模思软件科技有限公司
  • 珠海市恒泰新软件有限责任公司
  • 珠海思诺锐创软件有限公司
  • 深圳市易胜科技有限公司
  • 重庆虫儿飞科技有限公司
  • 重庆林木森科技有限公司
  • 深圳市品立方科技有限公司

如果您的项目使用到 Fur 开发,可以告诉我们。

🍻 贡献代码

Fur 遵循 Apache-2.0 开源协议,欢迎大家提交 PRIssue

如果要为项目做出贡献,请查看贡献指南。

🍍 捐赠列表

注:排序按捐赠顺序书写

捐赠人昵称捐赠金额(元)附语
🤴 爱吃油麦菜100感谢您的开源项目!
👳‍♂️ 麦壳饼200感谢您的开源项目!
👨 Sun100感谢您的开源项目!
👶 d61761720感谢您的开源项目!
👦 Diqiguoji00816.66见贤思齐
👲 nodyang100感谢您的开源项目!
👳‍♀️ mictxd100吹过的牛都实现。
🧓 欧流全10希望将来超越 Spring
👨‍⚕️ lionkon10...看了框架感觉拿来学习是很不错的...
😤 好人!10...Nice 的小僧,我们的 dotnetchina 马上火起来了...
😮 木木 Woody10感谢您的开源项目!

非常感谢您们的支持,正是因为您们,中国开源才可以越走越远,Fur 越走越远。

🥔 QQ 交流群

🧆 友情链接

👉 Fur 👉 SqlSugar 👉 Layx 👉 t-io 👉 ThinkPHP 👉 Hutool 👉 BootstrapAdmin 👉 BootstrapBlazor

- - - - - - - - - - - +

1.1 介绍

star fork GitHub stars GitHub forks GitHub license nuget

Fur.NET 5 平台下极易入门、极速开发的 Web 应用框架。

🍕 名字的由来

故事是这样子的:

起初,想开发一个极易入门、极易维护的框架,开发理念为:一切从简,只为了更懒

所以自然而然想到了:Lazier,也就是 更懒 的意思。但是 更懒更烂 读音相近且中文名没有特色,对此换名问题我苦恼了好几天。

刚好有一次我在博客园中帮一个博友解答问题,解决后博友赞扬我对 .NET Core 颇有了解,我就顺嘴回答了一句:“略懂皮毛”

就这时,脑瓜子灵机一动,干脆起名为:“皮毛”?英文单词 Fur [fɜː(r)]”,单词又短而且中文读音既俗气又顺口。😄😎

所以,Fur 就诞生了。

之后就有了 “小僧不才,略懂皮毛(Fur)。” 广告语 和 chinadot.net 域名。

🍔 关于 LOGO

Fur LOGO 设计由 F U R 三个单词组成:

我相信很多人看到 Fur 的 LOGO 时都会问:“为什么选择奶牛?”,因为 那些年吹过的牛逼都实现了 🐮

之所以选择 奶牛 是因为 具有脚踏实地,任劳任怨的做事风格,同时 奶牛 意味着丰富的营养价值,正如 Fur 所能带给你的。

🍟 文档地址

🌭 开源地址

🍿 Docker 镜像

  • Docker Hub 线上镜像
docker run --name fur -p 5000:80 monksoul/fur:v1.0.0-2020.10.14
  • 手动 打包镜像

打开 CMD/Shell/PowerShell 进入 Fur 项目根目录打包 Fur 镜像:

docker build -t fur:v1.0.0-2020.10.14 .

打包成功后,直接 docker run

docker run --name fur -p 5000:80 fur:v1.0.0-2020.10.14

🥞 架构设计

正在整理中...

🥝 功能模块

🥐 框架依赖

Fur 为了追求极速入门,极致性能,尽可能的不使用或减少第三方依赖。目前 Fur 仅集成了以下三个依赖:

麻雀虽小五脏俱全。Fur 即使只集成了这三个依赖,但是主流的 依赖注入/控制反转AOP 面向切面编程,事件总线数据验证数据库操作 等等一个都不少。

🥗 环境要求

  • Visual Studio 2019 Preview 16.8 +
  • .NET 5 SDK +
  • .Net Standard 2.1 +

🥪 支持平台

  • 运行环境
    • Windows
    • Linux
    • MacOS
    • Docker/K8S/K3S/Rancher
    • Xamarin/MAUI
  • 数据库
    • SqlServer
    • Sqlite
    • Azure Cosmos
    • MySql
    • PostgreSQL
    • InMemoryDatabase
    • Oracle
    • Firebird
    • 达梦数据库
  • 应用部署
    • Kestrel
    • Nginx
    • Jexus
    • IIS
    • Apache
    • PM2
    • Supervisor
    • 单文件
    • 容器(Docker/K8S/K3S/Rancher)

🍖 关于性能

Fur 目前采用 Visual Studio 2019 Preview 16.8 自带性能测试和 JMeter 进行测试,由于篇幅有限,只贴部分测试图,测试结果如下:


🍚 关于作者

一个拥有 12 年开发经验 .NETer。喜欢分享,喜欢新技术,在互联网多个技术领域皆有涉猎。

🍤 项目成员

🎈 欢迎更多的开发者加入 Fur 大家庭。

🍝 他们都在用

  • 百签科技(广东)有限公司
  • 码为科技(广州)有限公司
  • 广州启顺国际货运代理有限公司
  • 森丰供应链服务(广州)有限公司
  • 中山赢友网络科技有限公司
  • 中山模思软件科技有限公司
  • 珠海市恒泰新软件有限责任公司
  • 珠海思诺锐创软件有限公司
  • 深圳市易胜科技有限公司
  • 重庆虫儿飞科技有限公司
  • 重庆林木森科技有限公司
  • 深圳市品立方科技有限公司

如果您的项目使用到 Fur 开发,可以告诉我们。

🍻 贡献代码

Fur 遵循 Apache-2.0 开源协议,欢迎大家提交 PRIssue

如果要为项目做出贡献,请查看贡献指南。

🍍 捐赠列表

注:排序按捐赠顺序书写

捐赠人昵称捐赠金额(元)附语
🤴 爱吃油麦菜100感谢您的开源项目!
👳‍♂️ 麦壳饼200感谢您的开源项目!
👨 Sun100感谢您的开源项目!
👶 d61761720感谢您的开源项目!
👦 Diqiguoji00816.66见贤思齐
👲 nodyang100感谢您的开源项目!
👳‍♀️ mictxd100吹过的牛都实现。
🧓 欧流全10希望将来超越 Spring
👨‍⚕️ lionkon10...看了框架感觉拿来学习是很不错的...
😤 好人!10...Nice 的小僧,我们的 dotnetchina 马上火起来了...
😮 木木 Woody10感谢您的开源项目!

非常感谢您们的支持,正是因为您们,中国开源才可以越走越远,Fur 越走越远。

🥔 QQ 交流群

🧆 友情链接

👉 Fur 👉 SqlSugar 👉 Layx 👉 t-io 👉 ThinkPHP 👉 Hutool 👉 BootstrapAdmin 👉 BootstrapBlazor

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/job/index.html b/handbook/build/docs/job/index.html index aac4a156c95..bb020492302 100644 --- a/handbook/build/docs/job/index.html +++ b/handbook/build/docs/job/index.html @@ -4,32 +4,32 @@ -22. 任务调度 | Fur - - - - - - - - - - - +22. 任务调度 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/local-language/index.html b/handbook/build/docs/local-language/index.html index d02648a2b27..df4c9ed2589 100644 --- a/handbook/build/docs/local-language/index.html +++ b/handbook/build/docs/local-language/index.html @@ -4,32 +4,32 @@ -16. 多语言处理 | Fur - - - - - - - - - - - +16. 多语言处理 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/logging/index.html b/handbook/build/docs/logging/index.html index 1bdb9180f80..ba58e6d7b7f 100644 --- a/handbook/build/docs/logging/index.html +++ b/handbook/build/docs/logging/index.html @@ -4,32 +4,32 @@ -19. 日志记录 | Fur - - - - - - - - - - - +19. 日志记录 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/object-mapper/index.html b/handbook/build/docs/object-mapper/index.html index 1c96a4a9052..59f6593ca1f 100644 --- a/handbook/build/docs/object-mapper/index.html +++ b/handbook/build/docs/object-mapper/index.html @@ -4,33 +4,33 @@ -12. 对象数据映射 | Fur - - - - - - - - - - - +12. 对象数据映射 | Fur + + + + + + + + + + +
-

12. 对象数据映射

12.1 对象映射

简单来说,就是将一个对象的数据根据特定规则批量映射到另一个对象中,减少手工操作和降低人为出错率。如将 DTO 对象映射到 Entity 实体中,反之亦然。

12.2 先看例子

在过去,我们需要将一个对象的值转换到另一个对象中,我们需要这样做,如:

var entity = repository.Find(1);
-
var dto = new Dto();
dto.Id = entity.Id;
dto.Name = entity.Name;
dto.Age = entity.Age;
dto.Address = entity.Address;
dto.FullName = entity.FirstName + entity.LastName;
dto.IdCard = entity.IdCard.Replace("1234", "****");

上面的例子似乎没有任何问题,但是如果很多地方需要这样的赋值操作、或者相同的赋值操作在多个地方使用,又或者一个类中含有非常多的属性或自定义赋值操作。

那么这样的操作效率极低,容易出错,且代码非常臃肿和冗余。

所以,实现自动映射赋值和支持特殊配置的需求就有了。

目前 C# 平台有两个优秀的对象映射工具:MapsterAutoMapper,在 Fur 框架中,默认集成的是 MapsterMapster 是一款极易使用且超高性能的对象映射框架。

- - - - - - - - - - - +

12. 对象数据映射

12.1 对象映射

简单来说,就是将一个对象的数据根据特定规则批量映射到另一个对象中,减少手工操作和降低人为出错率。如将 DTO 对象映射到 Entity 实体中,反之亦然。

12.2 先看例子

在过去,我们需要将一个对象的值转换到另一个对象中,我们需要这样做,如:

var entity = repository.Find(1);
+
var dto = new Dto();
dto.Id = entity.Id;
dto.Name = entity.Name;
dto.Age = entity.Age;
dto.Address = entity.Address;
dto.FullName = entity.FirstName + entity.LastName;
dto.IdCard = entity.IdCard.Replace("1234", "****");

上面的例子似乎没有任何问题,但是如果很多地方需要这样的赋值操作、或者相同的赋值操作在多个地方使用,又或者一个类中含有非常多的属性或自定义赋值操作。

那么这样的操作效率极低,容易出错,且代码非常臃肿和冗余。

所以,实现自动映射赋值和支持特殊配置的需求就有了。

目前 C# 平台有两个优秀的对象映射工具:MapsterAutoMapper,在 Fur 框架中,默认集成的是 MapsterMapster 是一款极易使用且超高性能的对象映射框架。

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/options/index.html b/handbook/build/docs/options/index.html index b2e9f146f2e..3f24f22d5b3 100644 --- a/handbook/build/docs/options/index.html +++ b/handbook/build/docs/options/index.html @@ -4,44 +4,44 @@ -4.2 选项 | Fur - - - - - - - - - - - +4.2 选项 | Fur + + + + + + + + + + +
-

4.2 选项

4.2.1 什么是选项

选项是 ASP.NET Core 推荐的动态读取配置的方式,这种方式将配置文件数据用一个强类型来托管,能够实现配置验证、默认值配置、实时读取等功能。

4.2.2 与配置的区别

选项实际上也是配置,但在后者的基础上添加了配置验证、默认值/后期配置设定及提供了多种接口读取配置信息,同时还支持供配置更改通知等强大灵活功能。

所以,除了一次性读取使用的配置以外,都应该选用 选项 替换 配置

知识导航

有关配置说明可查看《4.1 配置》 章节。

4.2.3 选项的使用

假设我们需要在系统运行时获取系统名称、版本号及版权信息,这些信息可能随时变化而且需要在多个地方使用。这时就需要将这些信息配置起来。具体步骤如下:

4.2.3.1 配置 appsettings.json 信息

{
"AppInfo": {
"Name": "Fur",
"Version": "1.0.0",
"Company": "Baiqian"
}
}

4.2.3.2 创建 AppInfoOptions 强类型类

using Fur.ConfigurableOptions;
+

4.2 选项

4.2.1 什么是选项

选项是 ASP.NET Core 推荐的动态读取配置的方式,这种方式将配置文件数据用一个强类型来托管,能够实现配置验证、默认值配置、实时读取等功能。

4.2.2 与配置的区别

选项实际上也是配置,但在后者的基础上添加了配置验证、默认值/后期配置设定及提供了多种接口读取配置信息,同时还支持供配置更改通知等强大灵活功能。

所以,除了一次性读取使用的配置以外,都应该选用 选项 替换 配置

知识导航

有关配置说明可查看《4.1 配置》 章节。

4.2.3 选项的使用

假设我们需要在系统运行时获取系统名称、版本号及版权信息,这些信息可能随时变化而且需要在多个地方使用。这时就需要将这些信息配置起来。具体步骤如下:

4.2.3.1 配置 appsettings.json 信息

{
"AppInfo": {
"Name": "Fur",
"Version": "1.0.0",
"Company": "Baiqian"
}
}

4.2.3.2 创建 AppInfoOptions 强类型类

using Fur.ConfigurableOptions;
namespace Fur.Application
{
public class AppInfoOptions : IConfigurableOptions
{
public string Name { get; set; }
public string Version { get; set; }
public string Company { get; set; }
}
}
温馨提示

建议所有选项类都应该以 Options 命名结尾。

另外,Fur 框架提供了非常灵活的注册选项服务的方法,只需要继承 IConfigurableOptions 接口即可,该接口位于 Fur.ConfigurableOptions 命名空间下。

4.2.3.3 注册 AppInfoOptions 服务

选项不同于配置,需在应用启动时注册

Fur.Web.Core\FurWebCoreStartup.cs
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace Fur.Web.Core
{
[AppStartup(800)]
public sealed class FurWebCoreStartup : AppStartup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddConfigurableOptions<AppInfoOptions>();
}
}
}

4.2.3.4 读取 AppInfoOptions 信息

Fur 框架中,提供了多种读取方式:

  • 通过 App.GetOptions<TOptions>(jsonKey) 读取(不推荐
  • 通过依赖注入以下实例读取:
    • IOptions<TOptions>
    • IOptionsSnapshot<TOptions>
    • IOptionsMonitor<TOptions>
  • 通过 App 静态类提供的静态方法获取:
    • App.GetOptions<TOptions>()
    • App.GetOptionsMonitor<TOptions>()
    • App.GetOptionsSnapshot<TOptions>()
using Fur.Application;
using Microsoft.AspNetCore.Mvc;
namespace Fur.Web.Entry.Controllers
{
[Route("api/[controller]")]
public class DefaultController : ControllerBase
{
[HttpGet]
public string Get()
{
// 不推荐采用此方式读取
var appInfo = App.GetOptions<AppInfoOptions>("AppInfo");
return $@"名称:{appInfo.Name},
版本:{appInfo.Version},
公司:{appInfo.Company}";
}
}
}
特别注意

App.GetOptions<TOptions>(jsonKey) 静态方法 区别于没有参数的 App.GetOptions<TOptions>() 静态方法,前者实际上还是 配置,只不过做了强类型解析,后者则通过 IOptions<TOptions> 解析。

两者源码如下:

Fur/App/App.cs
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace Fur
{
/// <summary>
/// 全局应用类
/// </summary>
public static class App
{
/// <summary>
/// 获取选项
/// </summary>
/// <typeparam name="TOptions">强类型选项类</typeparam>
/// <param name="jsonKey">配置中对应的Key</param>
/// <returns></returns>
public static TOptions GetOptions<TOptions>(string jsonKey)
where TOptions : class
=> Configuration.GetSection(jsonKey).Get<TOptions>();
/// <summary>
/// 获取选项
/// </summary>
/// <typeparam name="TOptions">强类型选项类</typeparam>
/// <returns></returns>
public static TOptions GetOptions<TOptions>()
where TOptions : class
=> ServiceProvider.GetService<IOptions<TOptions>>().Value;
-
// Other Codes...
}
}

通过上述代码得知,为什么不推荐使用 App.GetOptions<TOptions>(jsonKey) 读取,因为这种方式无法应用选项验证、默认配置、更改通知等功能。

4.2.3.5 如何选择读取方式

  • 如果选项需要在多个地方使用,则无论任何时候都不推荐使用 App.GetOptions<TOptions>(jsonKey)
  • 在可依赖注入类中,依赖注入 IOptions[Snapshot|Monitor]<TOptions> 读取
  • 在静态类/非依赖注入类中,选择 App.GetOptions[Snapshot|Monitor]<TOptions>() 读取

4.2.4 选项接口说明

ASP.NET Core 应用提供了多种读取选项的接口:

  • IOptions<TOptions>
    • 不支持:
      • 在应用启动后读取配置数据
      • 命名选项
    • 注册为单一实例且可以注入到任何服务生存期
  • IOptionsSnapshot<TOptions>
    • 在每次请求时应重新计算选项的方案中有用
    • 注册为范围内,因此无法注入到单一实例服务
    • 支持命名选项
  • IOptionsMonitor<TOptions>
    • 用于检索选项并管理 TOptions 实例的选项通知。
    • 注册为单一实例且可以注入到任何服务生存期。
    • 支持:
      • 更改通知
      • 命名选项
      • 可重载配置
      • 选择性选项失效 (IOptionsMonitorCache<TOptions>)
了解更多

想了解更多 选项接口 知识可查阅 ASP.NET Core - 选项 - 选项接口 小节。

4.2.5 选项自定义配置

我们知道,选项实际上需要和配置文件特定键值挂钩,那 Fur 是如何准确的找到配置文件中的键值的呢?

4.2.5.1 选项查找键流程

  • 没有贴 [OptionsSettings] 特性
    • Options 结尾,则去除 Options 字符串
    • 否则返回 类名称
  • 贴了 [OptionsSettings] 特性
    • 如果配置了 JsonKey 属性,则返回 JsonKey 的值
    • 否则返回 类名称
  • Options 结尾,则键名为:AppInfo
public class AppInfoOptions : IConfigurableOptions
{
public string Name { get; set; }
public string Version { get; set; }
public string Company { get; set; }
}
  • 不以 Options 结尾,则键名为:AppInfoSettings
public class AppInfoSettings : IConfigurableOptions
{
public string Name { get; set; }
public string Version { get; set; }
public string Company { get; set; }
}

4.2.6 [OptionsSettings] 说明

选项类可以通过 [OptionsSettings] 来配置查找路径值。

4.2.7 选项验证

选项支持验证配置有效性,在 Fur 框架中,通过 services.AddConfigurableOptions<TOptions>() 注册选项默认启用了验证支持。

包括:

  • 特性方式 DataAnnotations
  • 自定义复杂验证 IValidateOptions<TOptions>
using Fur.ConfigurableOptions;
using System.ComponentModel.DataAnnotations;
+
// Other Codes...
}
}

通过上述代码得知,为什么不推荐使用 App.GetOptions<TOptions>(jsonKey) 读取,因为这种方式无法应用选项验证、默认配置、更改通知等功能。

4.2.3.5 如何选择读取方式

  • 如果选项需要在多个地方使用,则无论任何时候都不推荐使用 App.GetOptions<TOptions>(jsonKey)
  • 在可依赖注入类中,依赖注入 IOptions[Snapshot|Monitor]<TOptions> 读取
  • 在静态类/非依赖注入类中,选择 App.GetOptions[Snapshot|Monitor]<TOptions>() 读取

4.2.4 选项接口说明

ASP.NET Core 应用提供了多种读取选项的接口:

  • IOptions<TOptions>
    • 不支持:
      • 在应用启动后读取配置数据
      • 命名选项
    • 注册为单一实例且可以注入到任何服务生存期
  • IOptionsSnapshot<TOptions>
    • 在每次请求时应重新计算选项的方案中有用
    • 注册为范围内,因此无法注入到单一实例服务
    • 支持命名选项
  • IOptionsMonitor<TOptions>
    • 用于检索选项并管理 TOptions 实例的选项通知。
    • 注册为单一实例且可以注入到任何服务生存期。
    • 支持:
      • 更改通知
      • 命名选项
      • 可重载配置
      • 选择性选项失效 (IOptionsMonitorCache<TOptions>)
了解更多

想了解更多 选项接口 知识可查阅 ASP.NET Core - 选项 - 选项接口 小节。

4.2.5 选项自定义配置

我们知道,选项实际上需要和配置文件特定键值挂钩,那 Fur 是如何准确的找到配置文件中的键值的呢?

4.2.5.1 选项查找键流程

  • 没有贴 [OptionsSettings] 特性
    • Options 结尾,则去除 Options 字符串
    • 否则返回 类名称
  • 贴了 [OptionsSettings] 特性
    • 如果配置了 JsonKey 属性,则返回 JsonKey 的值
    • 否则返回 类名称
  • Options 结尾,则键名为:AppInfo
public class AppInfoOptions : IConfigurableOptions
{
public string Name { get; set; }
public string Version { get; set; }
public string Company { get; set; }
}
  • 不以 Options 结尾,则键名为:AppInfoSettings
public class AppInfoSettings : IConfigurableOptions
{
public string Name { get; set; }
public string Version { get; set; }
public string Company { get; set; }
}

4.2.6 [OptionsSettings] 说明

选项类可以通过 [OptionsSettings] 来配置查找路径值。

4.2.7 选项验证

选项支持验证配置有效性,在 Fur 框架中,通过 services.AddConfigurableOptions<TOptions>() 注册选项默认启用了验证支持。

包括:

  • 特性方式 DataAnnotations
  • 自定义复杂验证 IValidateOptions<TOptions>
using Fur.ConfigurableOptions;
using System.ComponentModel.DataAnnotations;
namespace Fur.Application
{
public class AppInfoOptions : IConfigurableOptions
{
[Required(ErrorMessage = "名称不能为空")]
public string Name { get; set; }
[Required, RegularExpression(@"^[0-9][0-9\.]+[0-9]$", ErrorMessage = "不是有效的版本号")]
public string Version { get; set; }
[Required, MaxLength(100)]
public string Company { get; set; }
}
}
特别说明

IConfigurableOptions<TOptions, TOptionsValidation> 继承自 IConfigurableOptions<TOptions>,也就是自定义复杂验证默认具有 PostConfigure(TOptions options) 选项后期配置方法。关于《4.3.7 选项后期配置》将在下一小节说明。

4.2.8 选项后期配置

选项后期配置通俗一点来说,可以在运行时解析值或设定默认值/后期配置等。

Fur 框架中,配置选项后期配置很简单,只需要继承 IConfigurableOptions<TOptions 接口并实现 PostConfigure(TOptions options) 方法。

using Fur.ConfigurableOptions;
using Microsoft.Extensions.Configuration;
using System.ComponentModel.DataAnnotations;
namespace Fur.Application
{
public class AppInfoOptions : IConfigurableOptions<AppInfoOptions>
{
[Required(ErrorMessage = "名称不能为空")]
public string Name { get; set; }
[Required]
public string Version { get; set; }
[Required, MaxLength(100)]
public string Company { get; set; }
public void PostConfigure(AppInfoOptions options, IConfiguration configuration)
{
options.Name ??= "Fur";
options.Version ??= "1.0.0";
options.Version ??= "Baiqian";
}
}
}
特别说明

IConfigurableOptions<TOptions, TOptionsValidation> 继承自 IConfigurableOptions<TOptions>,也就是自定义复杂验证默认具有 PostConfigure(TOptions options, IConfiguration configuration) 选项后期配置方法。

4.2.9 选项更改通知(热更新

Fur 框架提供了非常简单且灵活的方式监听选项更改,也就是 appsettings.json 或 自定义配置文件发生任何更改都会触发处理方法

使用非常简单,只需要继承 IConfigurableOptionsListener<TOptions> 接口并实现 void OnListener(TOptions options, IConfiguration configuration) 方法即可。

using Fur.ConfigurableOptions;
namespace Fur.Application
{
public class AppInfoOptions : IConfigurableOptionsListener<AppInfoOptions>
{
public string Name { get; set; }
public string Version { get; set; }
public string Company { get; set; }
}
public void OnListener(AppInfoOptions options, IConfiguration configuration)
{
var name = options.Name; // 实时的最新值
var version = options.Version; // 实时的最新值
}
-
public void PostConfigure(AppInfoOptions options, IConfiguration configuration)
{
}
}
特别说明

IConfigurableOptionsListener<TOptions> 继承自 IConfigurableOptions<TOptions>

4.2.10 选项的优缺点

  • 优点

    • 强类型配置
    • 提供多种读取方式
    • 支持热加载
    • 支持设置默认值/后期配置
    • 支持在运行环境中动态配置
    • 支持验证配置有效性
    • 支持更改通知
    • 支持命名选项
  • 缺点

    • 需要定义对应类型
    • 需要在启动时注册

4.2.11 反馈与建议

与我们交流

给 Fur 提 Issue


了解更多

想了解更多 选项 知识可查阅 ASP.NET Core - 选项 章节。

- - - - - - - - - - - +
public void PostConfigure(AppInfoOptions options, IConfiguration configuration)
{
}
}
特别说明

IConfigurableOptionsListener<TOptions> 继承自 IConfigurableOptions<TOptions>

4.2.10 选项的优缺点

  • 优点

    • 强类型配置
    • 提供多种读取方式
    • 支持热加载
    • 支持设置默认值/后期配置
    • 支持在运行环境中动态配置
    • 支持验证配置有效性
    • 支持更改通知
    • 支持命名选项
  • 缺点

    • 需要定义对应类型
    • 需要在启动时注册

4.2.11 反馈与建议

与我们交流

给 Fur 提 Issue


了解更多

想了解更多 选项 知识可查阅 ASP.NET Core - 选项 章节。

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/performance/index.html b/handbook/build/docs/performance/index.html index 42ffdd97674..680eb72817a 100644 --- a/handbook/build/docs/performance/index.html +++ b/handbook/build/docs/performance/index.html @@ -4,32 +4,32 @@ -27.2 性能测试 | Fur - - - - - - - - - - - +27.2 性能测试 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/process-service/index.html b/handbook/build/docs/process-service/index.html index f0e636610bb..a927569826e 100644 --- a/handbook/build/docs/process-service/index.html +++ b/handbook/build/docs/process-service/index.html @@ -4,32 +4,32 @@ -21. 进程服务 | Fur - - - - - - - - - - - +21. 进程服务 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/reference/index.html b/handbook/build/docs/reference/index.html index ea751b4fe7c..77000f6a8d8 100644 --- a/handbook/build/docs/reference/index.html +++ b/handbook/build/docs/reference/index.html @@ -4,38 +4,38 @@ -1.4 项目引用 | Fur - - - - - - - - - - - +1.4 项目引用 | Fur + + + + + + + + + + +
-

1.4 项目引用

1.4.1 关于项目引用

Fur 框架默认采用多层项目设计架构,每一个项目层的依赖分别是:

  • Fur:核心层,无项目依赖
  • Fur.Application:添加 Fur.Core 引用
  • Fur.Core:添加 Fur 引用
  • Fur.Database.Migrations:添加 Fur.EntityFramework.Core 引用
  • Fur.EntityFramework.Core:添加 Fur.Core 引用
  • Fur.Web.Core:添加 Fur.ApplicationFur.Database.Migrations 引用
  • Fur.Web.Entry:添加 Fur.Web.Core 引用 和 Microsoft.EntityFrameworkCore.Tools

1.4.2 创建项目注意事项

Fur 框架采用最新的 .NET 5 共享包设计方式,所以,所有新建的 项目 都需要修改 .csproj 文件,并添加以下代码:

Fur.Core\Fur.Core.csproj
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

完整代码如下:

<Project Sdk="Microsoft.NET.Sdk">
+

1.4 项目引用

1.4.1 关于项目引用

Fur 框架默认采用多层项目设计架构,每一个项目层的依赖分别是:

  • Fur:核心层,无项目依赖
  • Fur.Application:添加 Fur.Core 引用
  • Fur.Core:添加 Fur 引用
  • Fur.Database.Migrations:添加 Fur.EntityFramework.Core 引用
  • Fur.EntityFramework.Core:添加 Fur.Core 引用
  • Fur.Web.Core:添加 Fur.ApplicationFur.Database.Migrations 引用
  • Fur.Web.Entry:添加 Fur.Web.Core 引用 和 Microsoft.EntityFrameworkCore.Tools

1.4.2 创建项目注意事项

Fur 框架采用最新的 .NET 5 共享包设计方式,所以,所有新建的 项目 都需要修改 .csproj 文件,并添加以下代码:

Fur.Core\Fur.Core.csproj
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

完整代码如下:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<NoWarn>1701;1702;1591</NoWarn>
<DocumentationFile>Fur.Core.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<None Remove="Fur.Core.xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Fur\Fur.csproj" />
</ItemGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>
-

所有新建项目都需添加 上述高亮代码,方可使用 Fur 全部功能。

1.4.3 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +

所有新建项目都需添加 上述高亮代码,方可使用 Fur 全部功能。

1.4.3 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/saas/index.html b/handbook/build/docs/saas/index.html index 21e03a41985..d3a66397529 100644 --- a/handbook/build/docs/saas/index.html +++ b/handbook/build/docs/saas/index.html @@ -4,22 +4,22 @@ -10. SaaS 多租户 | Fur - - - - - - - - - - - +10. SaaS 多租户 | Fur + + + + + + + + + + +
-

10. SaaS 多租户

10.1 什么是 SaaS

SaaS 是 Software-as-a-Service(软件即服务)的简称,随着互联网技术的发展和应用软件的成熟, 在 21 世纪开始兴起的一种完全创新的软件应用模式。它与“on-demand software”,the application service provider(ASP,应用服务提供商),hosted software(托管软件)所具有相似的含义。

它是一种通过 Internet 提供软件的模式,厂商将应用软件统一部署在自己的服务器上,客户可以根据自己实际需求,通过互联网向厂商定购所需的应用软件服务,按定购的服务多少和时间长短向厂商支付费用,并通过互联网获得厂商提供的服务。用户不用再购买软件,而改用向提供商租用基于 Web 的软件,来管理企业经营活动,且无需对软件进行维护,服务提供商会全权管理和维护软件,软件厂商在向客户提供互联网应用的同时,也提供软件的离线操作和本地数据存储,让用户随时随地都可以使用其定购的软件和服务。

对于许多小型企业来说,SaaS 是采用先进技术的最好途径,它消除了企业购买、构建和维护基础设施和应用程序的需要。

10.2 什么是多租户

多租户技术或称多重租赁技术,简称 SaaS,是一种软件架构技术,是实现如何在多用户环境下(此处的多用户一般是面向企业用户)共用相同的系统或程序组件,并且可确保各用户间数据的隔离性。

简单讲:在一台服务器上运行单个应用实例,它为多个租户(客户)提供服务。从定义中我们可以理解:多租户是一种架构,目的是为了让多用户环境下使用同一套程序,且保证用户间数据隔离。那么重点就很浅显易懂了,多租户的重点就是同一套程序下实现多用户数据的隔离。

10.3 实现多租户方案

10.3.1 独立数据库(基于 Database 的方式)

这是第一种方案,即一个租户一个数据库,这种方案的用户数据隔离级别最高,安全性最好,但成本较高。

  • 优点: +

    10. SaaS 多租户

    10.1 什么是 SaaS

    SaaS 是 Software-as-a-Service(软件即服务)的简称,随着互联网技术的发展和应用软件的成熟, 在 21 世纪开始兴起的一种完全创新的软件应用模式。它与“on-demand software”,the application service provider(ASP,应用服务提供商),hosted software(托管软件)所具有相似的含义。

    它是一种通过 Internet 提供软件的模式,厂商将应用软件统一部署在自己的服务器上,客户可以根据自己实际需求,通过互联网向厂商定购所需的应用软件服务,按定购的服务多少和时间长短向厂商支付费用,并通过互联网获得厂商提供的服务。用户不用再购买软件,而改用向提供商租用基于 Web 的软件,来管理企业经营活动,且无需对软件进行维护,服务提供商会全权管理和维护软件,软件厂商在向客户提供互联网应用的同时,也提供软件的离线操作和本地数据存储,让用户随时随地都可以使用其定购的软件和服务。

    对于许多小型企业来说,SaaS 是采用先进技术的最好途径,它消除了企业购买、构建和维护基础设施和应用程序的需要。

    10.2 什么是多租户

    多租户技术或称多重租赁技术,简称 SaaS,是一种软件架构技术,是实现如何在多用户环境下(此处的多用户一般是面向企业用户)共用相同的系统或程序组件,并且可确保各用户间数据的隔离性。

    简单讲:在一台服务器上运行单个应用实例,它为多个租户(客户)提供服务。从定义中我们可以理解:多租户是一种架构,目的是为了让多用户环境下使用同一套程序,且保证用户间数据隔离。那么重点就很浅显易懂了,多租户的重点就是同一套程序下实现多用户数据的隔离。

    10.3 实现多租户方案

    10.3.1 独立数据库(基于 Database 的方式)

    这是第一种方案,即一个租户一个数据库,这种方案的用户数据隔离级别最高,安全性最好,但成本较高。

    • 优点: 为不同的租户提供独立的数据库,有助于简化数据模型的扩展设计,满足不同租户的独特需求;如果出现故障,恢复数据比较简单。

    • 缺点: 增多了数据库的安装数量,随之带来维护成本和购置成本的增加。 这种方案与传统的一个客户、一套数据、一套部署类似,差别只在于软件统一部署在运营商那里。如果面对的是银行、医院等需要非常高数据隔离级别的租户,可以选择这种模式,提高租用的定价。如果定价较低,产品走低价路线,这种方案一般对运营商来说是无法承受的。

    10.3.2 共享数据库,独立 Schema (基于 Schema 的方式)

    这是第二种方案,即多个或所有租户共享 Database,但是每个租户一个 Schema(也可叫做一个 user)。底层库比如是:SqlServerOracle 等,一个数据库下可以有多个 Schema

    • 优点: 为安全性要求较高的租户提供了一定程度的逻辑数据隔离,并不是完全隔离;每个数据库可支持更多的租户数量。

    • 缺点: @@ -39,7 +39,7 @@

    public void OnCreating(ModelBuilder modelBuilder, EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)
    {
    entityBuilder.HasQueryFilter(TenantIdQueryFilterExpression(entityBuilder, GetTenantId().Value));
    }
    protected override void SavingChangesEvent(object sender, SavingChangesEventArgs e)
    {
    // 获取当前事件对应上下文
    var dbContext = sender as FurDbContext;
    // 获取所有新增和更新的实体
    var entities = dbContext.ChangeTracker.Entries().Where(u => u.State == EntityState.Added || u.State == EntityState.Modified);
    -
    foreach (var entity in entities)
    {
    switch (entity.State)
    {
    // 自动设置租户Id
    case EntityState.Added:
    entity.Property(nameof(Entity.TenantId)).CurrentValue = GetTenantId();
    break;
    // 排除租户Id
    case EntityState.Modified:
    entity.Property(nameof(Entity.TenantId)).IsModified = false;
    break;
    }
    }
    }
    }
    }

    10.6 基于 Database 的方式

    此方式在中大型企业系统中最为常用,一个租户(客户)一个独立的数据库。

    10.6.1 创建租户数据库上下文

    Fur.EntityFramework.Core\DbContexts\MultiTenantDbContext.cs
    using Fur.DatabaseAccessor;
    using Microsoft.EntityFrameworkCore;
    +
    foreach (var entity in entities)
    {
    switch (entity.State)
    {
    // 自动设置租户Id
    case EntityState.Added:
    entity.Property(nameof(Entity.TenantId)).CurrentValue = GetTenantId();
    break;
    // 排除租户Id
    case EntityState.Modified:
    entity.Property(nameof(Entity.TenantId)).IsModified = false;
    break;
    }
    }
    }
    }
    }

    10.6 基于 Database 的方式

    此方式在中大型企业系统中最为常用,一个租户(客户)一个独立的数据库。

    10.6.1 创建租户数据库上下文

    Fur.EntityFramework.Core\DbContexts\MultiTenantDbContext.cs
    using Fur.DatabaseAccessor;
    using Microsoft.EntityFrameworkCore;
    namespace Fur.EntityFramework.Core
    {
    [AppDbContext("Sqlite3ConnectionString")]
    public class MultiTenantDbContext : AppDbContext<MultiTenantDbContext, MultiTenantDbContextLocator>
    {
    public MultiTenantDbContext(DbContextOptions<MultiTenantDbContext> options) : base(options)
    {
    }
    }
    }
    特别注意

    多租户操作建议单独一个数据库上下文,而且需指定 MultiTenantDbContextLocator 数据库上下文定位器。

    10.6.2 注册多租户数据库上下文

    using Fur.DatabaseAccessor;
    using Microsoft.Extensions.DependencyInjection;
    namespace Fur.EntityFramework.Core
    {
    [AppStartup(600)]
    public sealed class FurEntityFrameworkCoreStartup : AppStartup
    {
    public void ConfigureServices(IServiceCollection services)
    {
    services.AddDatabaseAccessor(options =>
    {
    options.AddDb<FurDbContext>(DbProvider.Sqlite);
    options.AddDbPool<MultiTenantDbContext, MultiTenantDbContextLocator>(DbProvider.Sqlite);
    });
    }
    }
    }
    特别注意

    需要 Database 多租户方案的数据库上下文需要采用 AddDb 注册,而不是 AddDbPool。原因是 AddDbPool 方式注册后续不支持 OnConfiguring 重写!!!

    10.6.3 添加 Tenant 种子数据

    Fur.EntityFramework.Core\SeedDatas\TenantSeedData.cs
    using Fur.DatabaseAccessor;
    using Microsoft.EntityFrameworkCore;
    using System;
    using System.Collections.Generic;
    namespace Fur.EntityFramework.Core
    {
    public class TenantSeedData : IEntitySeedData<Tenant, MultiTenantDbContextLocator>
    {
    public IEnumerable<Tenant> HasData(DbContext dbContext, Type dbContextLocator)
    {
    return new List<Tenant>
    {
    new Tenant
    {
    TenantId=Guid.Parse("383AFB88-F519-FFF8-B364-6D563BF3687F"),
    Name="默认租户",
    Host="localhost:44313",
    CreatedTime=DateTime.Parse("2020-10-06 20:19:07"),
    ConnectionString="Data Source=./Fur.db" // 配置连接字符串
    },
    new Tenant
    {
    TenantId=Guid.Parse("C5798CB6-16D6-0F42-EB56-59C695353BC0"),
    Name="其他租户",
    Host="localhost:5000",
    CreatedTime=DateTime.Parse("2020-10-06 20:20:32"),
    ConnectionString="Data Source=./Fur2.db" // 配置连接字符串
    }
    };
    }
    }
    }
    特别说明

    该步骤只在 Code First 方式执行,Database First 无需配置种子数据。

    10.6.4 根据模型创建 Tenant

    Add-Migration add_tenant_table -Context MultiTenantDbContext
    Update-Database -Context MultiTenantDbContext

    10.6.5 实现 IMultiTenantOnDatabase 接口

    在需要多租户的数据库上下文中实现 IMultiTenantOnDatabase 接口,如:

    using Fur.DatabaseAccessor;
    using Microsoft.EntityFrameworkCore;
    @@ -48,22 +48,22 @@
    namespace Fur.EntityFramework.Core
    {
    public class FurDbContext : AppDbContext<FurDbContext>, IMultiTenantOnDatabase
    {
    public FurDbContext(DbContextOptions<FurDbContext> options) : base(options)
    {
    }
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
    optionsBuilder.UseSqlite(GetDatabaseConnectionString());
    base.OnConfiguring(optionsBuilder);
    }
    -
    public string GetDatabaseConnectionString()
    {
    return base.Tenant?.ConnectionString;
    }
    }
    }

    10.7 基于 Schema 的方式

    此方式在中小型企业系统中也不少见,一个租户(客户)共享数据库且不同 Schema

    10.7.1 创建租户数据库上下文

    Fur.EntityFramework.Core\DbContexts\MultiTenantDbContext.cs
    using Fur.DatabaseAccessor;
    using Microsoft.EntityFrameworkCore;
    +
    public string GetDatabaseConnectionString()
    {
    return base.Tenant?.ConnectionString;
    }
    }
    }

    10.7 基于 Schema 的方式

    此方式在中小型企业系统中也不少见,一个租户(客户)共享数据库且不同 Schema

    10.7.1 创建租户数据库上下文

    Fur.EntityFramework.Core\DbContexts\MultiTenantDbContext.cs
    using Fur.DatabaseAccessor;
    using Microsoft.EntityFrameworkCore;
    namespace Fur.EntityFramework.Core
    {
    [AppDbContext("Sqlite3ConnectionString")]
    public class MultiTenantDbContext : AppDbContext<MultiTenantDbContext, MultiTenantDbContextLocator>
    {
    public MultiTenantDbContext(DbContextOptions<MultiTenantDbContext> options) : base(options)
    {
    }
    }
    }
    特别注意

    多租户操作建议单独一个数据库上下文,而且需指定 MultiTenantDbContextLocator 数据库上下文定位器。

    10.7.2 注册多租户数据库上下文

    using Fur.DatabaseAccessor;
    using Microsoft.Extensions.DependencyInjection;
    namespace Fur.EntityFramework.Core
    {
    [AppStartup(600)]
    public sealed class FurEntityFrameworkCoreStartup : AppStartup
    {
    public void ConfigureServices(IServiceCollection services)
    {
    services.AddDatabaseAccessor(options =>
    {
    options.AddDbPool<FurDbContext>(DbProvider.Sqlite);
    options.AddDbPool<MultiTenantDbContext, MultiTenantDbContextLocator>(DbProvider.Sqlite);
    });
    }
    }
    }

    10.7.3 添加 Tenant 种子数据

    Fur.EntityFramework.Core\SeedDatas\TenantSeedData.cs
    using Fur.DatabaseAccessor;
    using Microsoft.EntityFrameworkCore;
    using System;
    using System.Collections.Generic;
    namespace Fur.EntityFramework.Core
    {
    public class TenantSeedData : IEntitySeedData<Tenant, MultiTenantDbContextLocator>
    {
    public IEnumerable<Tenant> HasData(DbContext dbContext, Type dbContextLocator)
    {
    return new List<Tenant>
    {
    new Tenant
    {
    TenantId=Guid.Parse("383AFB88-F519-FFF8-B364-6D563BF3687F"),
    Name="默认租户",
    Host="localhost:44313",
    CreatedTime=DateTime.Parse("2020-10-06 20:19:07"),
    Schema="dbo" // Schema
    },
    new Tenant
    {
    TenantId=Guid.Parse("C5798CB6-16D6-0F42-EB56-59C695353BC0"),
    Name="其他租户",
    Host="localhost:5000",
    CreatedTime=DateTime.Parse("2020-10-06 20:20:32"),
    Schema="fur" // Schema
    }
    };
    }
    }
    }
    特别说明

    该步骤只在 Code First 方式执行,Database First 无需配置种子数据。

    10.7.4 根据模型创建 Tenant

    Add-Migration add_tenant_table -Context MultiTenantDbContext
    Update-Database -Context MultiTenantDbContext

    10.7.5 实现 IMultiTenantOnSchema 接口

    在需要多租户的数据库上下文中实现 IMultiTenantOnSchema 接口,如:

    using Fur.DatabaseAccessor;
    using Microsoft.EntityFrameworkCore;
    namespace Fur.EntityFramework.Core
    {
    [AppDbContext("Sqlite3ConnectionString")]
    public class FurDbContext : AppDbContext<FurDbContext>, IMultiTenantOnSchema
    {
    public FurDbContext(DbContextOptions<FurDbContext> options) : base(options)
    {
    }
    -
    public string GetSchemaName()
    {
    return base.Tenant?.Schema;
    }
    }
    }

    10.7.6 关于 Code First 数据迁移

    基于 Schema 方式比较特别,生成数据迁移的时候没办法获取租户信息,所以建议分开多次迁移,如:

    public string GetSchemaName()
    {
    return base.Tenant?.Schema?? "租户一Schema";
    }
    public string GetSchemaName()
    {
    return base.Tenant?.Schema?? "租户二Schema";
    }

    这样就可以在迁移的时候生成多次迁移了。

    10.8 反馈与建议

    与我们交流

    给 Fur 提 Issue

- - - - - - - - - - - +
public string GetSchemaName()
{
return base.Tenant?.Schema;
}
}
}

10.7.6 关于 Code First 数据迁移

基于 Schema 方式比较特别,生成数据迁移的时候没办法获取租户信息,所以建议分开多次迁移,如:

public string GetSchemaName()
{
return base.Tenant?.Schema?? "租户一Schema";
}
public string GetSchemaName()
{
return base.Tenant?.Schema?? "租户二Schema";
}

这样就可以在迁移的时候生成多次迁移了。

10.8 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/signalr/index.html b/handbook/build/docs/signalr/index.html index 6adac8defff..37b0e83628c 100644 --- a/handbook/build/docs/signalr/index.html +++ b/handbook/build/docs/signalr/index.html @@ -4,32 +4,32 @@ -23. 即时通讯 | Fur - - - - - - - - - - - +23. 即时通讯 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/source/index.html b/handbook/build/docs/source/index.html index 4345d81181d..ac159a7fd6f 100644 --- a/handbook/build/docs/source/index.html +++ b/handbook/build/docs/source/index.html @@ -4,22 +4,22 @@ -1.3 源码结构 | Fur - - - - - - - - - - - +1.3 源码结构 | Fur + + + + + + + + + + +
-

1.3 源码结构

1.2.1 源码架构

Fur 创建采用多层分层设计,主要设计是 自动抽象工厂DDD 领域驱动设计 相结合。

Fur 框架项目结构如下:

  • Fur.Tests:测试层
  • Solution Items:解决方案配置层
  • Fur:框架核心层
  • Fur.Application:业务应用层
  • Fur.Core:仓储实体层
  • Fur.Database.Migrations:架构维护层
  • Fur.EntityFramework.Core:EF Core 配置层
  • Fur.Web.Core:Web 核心层
  • Fur.Web.Entry:Web 入口层/启动层

1.2.2 Fur.Tests 测试层

Fur.Tests 是项目的测试层,目前还未整理完成。

1.2.3 Solution Items 解决方案配置层

源码结构:

Solution Items
└.editorconfig

Solution Items 是用来配置解决方案中一些全局配置的,如每个文件的顶部版权信息,如:

// -----------------------------------------------------------------------------
// Fur 是 .NET 5 平台下极易入门、极速开发的 Web 应用框架。
// Copyright © 2020 Fur, Baiqian Co.,Ltd.
//
// 框架名称:Fur
// 框架作者:百小僧
// 框架版本:1.0.0
// 源码地址:Gitee:https://gitee.com/monksoul/Fur
// Github:https://github.com/monksoul/Fur
// 开源协议:Apache-2.0(http://www.apache.org/licenses/LICENSE-2.0)
// -----------------------------------------------------------------------------

相关配置在 .editorconfig 最后面一行,如:

# Rules in this file were initially inferred by Visual Studio IntelliCode from the D:\MONK\Fur\framework codebase based on best match to current usage at 2020/9/2
# You can modify the rules from these initially generated values to suit your own policies
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
[*.cs]
+

1.3 源码结构

1.2.1 源码架构

Fur 创建采用多层分层设计,主要设计是 自动抽象工厂DDD 领域驱动设计 相结合。

Fur 框架项目结构如下:

  • Fur.Tests:测试层
  • Solution Items:解决方案配置层
  • Fur:框架核心层
  • Fur.Application:业务应用层
  • Fur.Core:仓储实体层
  • Fur.Database.Migrations:架构维护层
  • Fur.EntityFramework.Core:EF Core 配置层
  • Fur.Web.Core:Web 核心层
  • Fur.Web.Entry:Web 入口层/启动层

1.2.2 Fur.Tests 测试层

Fur.Tests 是项目的测试层,目前还未整理完成。

1.2.3 Solution Items 解决方案配置层

源码结构:

Solution Items
└.editorconfig

Solution Items 是用来配置解决方案中一些全局配置的,如每个文件的顶部版权信息,如:

// -----------------------------------------------------------------------------
// Fur 是 .NET 5 平台下极易入门、极速开发的 Web 应用框架。
// Copyright © 2020 Fur, Baiqian Co.,Ltd.
//
// 框架名称:Fur
// 框架作者:百小僧
// 框架版本:1.0.0
// 源码地址:Gitee:https://gitee.com/monksoul/Fur
// Github:https://github.com/monksoul/Fur
// 开源协议:Apache-2.0(http://www.apache.org/licenses/LICENSE-2.0)
// -----------------------------------------------------------------------------

相关配置在 .editorconfig 最后面一行,如:

# Rules in this file were initially inferred by Visual Studio IntelliCode from the D:\MONK\Fur\framework codebase based on best match to current usage at 2020/9/2
# You can modify the rules from these initially generated values to suit your own policies
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
[*.cs]
#Core editorconfig formatting - indentation
#use soft tabs (spaces) for indentation
indent_style = space
@@ -51,17 +51,17 @@
#when this rule is set to a list of modifiers, prefer the specified ordering.
csharp_preferred_modifier_order = public,private,internal,protected,virtual,static,async,abstract,readonly,sealed,override:suggestion
#Style - qualification options
#prefer fields not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_field = false:suggestion
#prefer methods not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_method = false:suggestion
#prefer properties not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_property = false:suggestion
-
# Add file header
file_header_template = -----------------------------------------------------------------------------\nFur 是 .NET 5 平台下极易入门、极速开发的 Web 应用框架。\nCopyright © 2020 Fur, Baiqian Co.,Ltd.\n\n框架名称:Fur\n框架作者:百小僧\n框架版本:1.0.0\n源码地址:Gitee:https://gitee.com/monksoul/Fur \n Github:https://github.com/monksoul/Fur \n开源协议:Apache-2.0(http://www.apache.org/licenses/LICENSE-2.0)\n-----------------------------------------------------------------------------

1.2.4 Fur 核心层

Fur 核心层是 Fur 框架的中心,也是 Fur 能够支撑起来的必备层。

源码结构:

Fur
├─Fur.csproj
├─Fur.csproj.user
├─FurStartup.cs
├─ViewEngine
| ├─IViewEngine.cs
| ├─ViewEngine.cs
| ├─Templates
| | ├─IViewEngineCompiledTemplate.cs
| | ├─IViewEngineTemplate.cs
| | ├─ViewEngineCompiledTemplate.cs
| | └ViewEngineTemplate.cs
| ├─Options
| | └ViewEngineCompilationOptions.cs
| ├─Models
| | └AnonymousTypeWrapper.cs
| ├─Exceptions
| | ├─ViewEngineCompilationException.cs
| | └ViewEngineException.cs
| ├─Compilations
| | ├─IViewEngineCompilationOptionsBuilder.cs
| | └ViewEngineCompilationOptionsBuilder.cs
├─UnifyResult
| ├─Providers
| | ├─IUnifyResultProvider.cs
| | └RESTfulResultProvider.cs
| ├─Models
| | └RESTfulResult.cs
| ├─Filters
| | └SuccessUnifyResultFilter.cs
| ├─Extensions
| | └UnifyResultServiceCollectionExtensions.cs
├─SpecificationDocument
| ├─Options
| | └SpecificationDocumentSettingsOptions.cs
| ├─Models
| | ├─GroupOrder.cs
| | ├─SpecificationOpenApiInfo.cs
| | ├─SpecificationOpenApiSecurityRequirementItem.cs
| | └SpecificationOpenApiSecurityScheme.cs
| ├─Extensions
| | ├─SpecificationDocumentApplicationBuilderExtensions.cs
| | └SpecificationDocumentServiceCollectionExtensions.cs
| ├─Builders
| | └SpecificationDocumentBuilder.cs
| ├─Assets
| | └index-mini-profiler.html
├─ObjectMapper
| ├─Extensions
| | └ObjectMapperServiceCollectionExtensions.cs
| ├─Dependencies
| | └IObjectMapper.cs
├─LinqBuilder
| ├─Visitors
| | └ParameterReplaceExpressionVisitor.cs
| ├─Extensions
| | └LinqExtensions.cs
| ├─Builders
| | └LinqExpression.cs
├─FriendlyException
| ├─Oops.cs
| ├─Providers
| | └IErrorCodeTypeProvider.cs
| ├─Options
| | └ErrorCodeMessageSettingsOptions.cs
| ├─Models
| | └MethodIfException.cs
| ├─Filters
| | └FriendlyExceptionFilter.cs
| ├─Extensions
| | └FriendlyExceptionServiceCollectionExtensions.cs
| ├─Attributes
| | ├─ErrorCodeItemMetadataAttribute.cs
| | ├─ErrorCodeTypeAttribute.cs
| | └IfExceptionAttribute.cs
├─DynamicApiController
| ├─Penetrates.cs
| ├─Providers
| | └DynamicApiControllerFeatureProvider.cs
| ├─Options
| | └DynamicApiControllerSettingsOptions.cs
| ├─Models
| | └ParameterRouteTemplate.cs
| ├─Extensions
| | └DynamicApiControllerServiceCollectionExtensions.cs
| ├─Enums
| | └ApiSeats.cs
| ├─Dependencies
| | └IDynamicApiController.cs
| ├─Conventions
| | └DynamicApiControllerApplicationModelConvention.cs
| ├─Attributes
| | ├─ApiDescriptionSettingsAttribute.cs
| | ├─ApiSeatAttribute.cs
| | └DynamicApiControllerAttribute.cs
├─DependencyInjection
| ├─Options
| | └DependencyInjectionSettingsOptions.cs
| ├─Models
| | └ExternalService.cs
| ├─Extensions
| | └DependencyInjectionServiceCollectionExtensions.cs
| ├─Enums
| | ├─InjectionActions.cs
| | ├─InjectionPatterns.cs
| | └RegisterType.cs
| ├─Dependencies
| | ├─IPrivateDependency.cs
| | ├─IScoped.cs
| | ├─ISingleton.cs
| | ├─ITransient.cs
| | ├─Proxies
| | | └IDispatchProxy.cs
| ├─Attributes
| | ├─InjectionAttribute.cs
| | └SkipScanAttribute.cs
├─DataValidation
| ├─Validators
| | └DataValidator.cs
| ├─Providers
| | └IValidationMessageTypeProvider.cs
| ├─Options
| | └ValidationTypeMessageSettingsOptions.cs
| ├─Models
| | └DataValidationResult.cs
| ├─Filters
| | └DataValidationFilter.cs
| ├─Extensions
| | ├─DataValidationExtensions.cs
| | └DataValidationServiceCollectionExtensions.cs
| ├─Enums
| | ├─ValidationPattern.cs
| | └ValidationTypes.cs
| ├─Attributes
| | ├─DataValidationAttribute.cs
| | ├─NonValidationAttribute.cs
| | ├─ValidationItemMetadataAttribute.cs
| | ├─ValidationMessageAttribute.cs
| | ├─ValidationMessageTypeAttribute.cs
| | └ValidationTypeAttribute.cs
├─DataEncryption
| ├─AESEncryption.cs
| ├─DESCEncryption.cs
| └MD5Encryption.cs
├─DatabaseAccessor
| ├─UnitOfWork
| | ├─Filters
| | | └UnitOfWorkFilter.cs
| | ├─Attributes
| | | ├─NonTransactAttribute.cs
| | | └UnitOfWorkAttribute.cs
| ├─Repositories
| | ├─EFCoreRepository.cs
| | ├─IMSRepository.cs
| | ├─IRepository.cs
| | ├─ISqlRepository.cs
| | ├─MSRepository.cs
| | ├─SqlRepository.cs
| | ├─Implantations
| | | ├─DeletableRepository.cs
| | | ├─InsertableRepository.cs
| | | ├─OperableRepository.cs
| | | ├─ReadableRepository.cs
| | | ├─SqlExecutableRepository.cs
| | | ├─SqlReaderRepository.cs
| | | ├─UpdateableRepository.cs
| | | └WritableRepository.cs
| | ├─Dependencies
| | | ├─IDeletableRepository.cs
| | | ├─IInsertableRepository.cs
| | | ├─IOperableRepository.cs
| | | ├─IReadableRepository.cs
| | | ├─IRepositoryDependency.cs
| | | ├─ISqlExecutableRepository.cs
| | | ├─ISqlReaderRepository.cs
| | | ├─IUpdateableRepository.cs
| | | └IWritableRepository.cs
| ├─Pools
| | ├─DbContextPool.cs
| | └IDbContextPool.cs
| ├─MultiTenants
| | ├─Locators
| | | └MultiTenantDbContextLocator.cs
| | ├─Enums
| | | └MultiTenantOptions.cs
| | ├─Entities
| | | └Tenant.cs
| | ├─Dependencies
| | | ├─IMultiTenantOnDatabase.cs
| | | ├─IMultiTenantOnSchema.cs
| | | ├─IMultiTenantOnTable.cs
| | | └IPrivateMultiTenant.cs
| ├─Models
| | ├─DbProvider.cs
| | ├─PagedList.cs
| | ├─ProcedureOutputResult.cs
| | ├─ProcedureOutputValue.cs
| | ├─SqlTemplate.cs
| | └SqlTemplateParameter.cs
| ├─Locators
| | ├─IDbContextLocator.cs
| | └MasterDbContextLocator.cs
| ├─Interceptors
| | ├─DbContextSaveChangesInterceptor.cs
| | ├─SqlCommandProfilerInterceptor.cs
| | └SqlConnectionProfilerInterceptor.cs
| ├─Helpers
| | └DbHelpers.cs
| ├─Extensions
| | ├─DatabaseAccessorServiceCollectionExtensions.cs
| | ├─PagedQueryableExtensions.cs
| | ├─Repositories
| | | ├─IEntityExtensions.cs
| | | ├─IEntityWithDbContextLocatorExtensions.cs
| | | └SqlExtensions.cs
| | ├─DatabaseProvider
| | | ├─DatabaseProviderServiceCollectionExtensions.cs
| | | └Penetrates.cs
| | ├─DatabaseFacade
| | | ├─DbDataConvertExtensions.cs
| | | ├─DbObjectExtensions.cs
| | | └SqlAdoNetExtensions.cs
| ├─Enums
| | ├─DbFunctionType.cs
| | ├─EFCoreErrorCodes.cs
| | └ManualOptions.cs
| ├─Entities
| | ├─Dependencies
| | | ├─Entity.cs
| | | ├─EntityBase.cs
| | | ├─EntityNotKey.cs
| | | ├─IEntity.cs
| | | └IEntityNotKey.cs
| | ├─Configures
| | | ├─IEntitySeedData.cs
| | | ├─IEntityTypeBuilder.cs
| | | ├─IModelBuilderFilter.cs
| | | └IPrivateModelBuilder.cs
| | ├─Attributes
| | | ├─FakeDeleteAttribute.cs
| | | ├─NonAutomaticAttribute.cs
| | | └QueryableFunctionAttribute.cs
| ├─DynamicModels
| | ├─DynamicModelCacheKeyFactory.cs
| | └IEntityMutableTable.cs
| ├─Contexts
| | ├─AppDbContext.cs
| | ├─Builders
| | | ├─AppDbContextBuilder.cs
| | | ├─Models
| | | | └DbContextCorrelationType.cs
| | ├─Attributes
| | | └AppDbContextAttribute.cs
| ├─Attributes
| | └DbParameterAttribute.cs
| ├─Advances
| | ├─Proxies
| | | └SqlDispatchProxy.cs
| | ├─Models
| | | └SqlProxyMethod.cs
| | ├─Dependencies
| | | └ISqlDispatchProxy.cs
| | ├─Attributes
| | | ├─SqlExecuteAttribute.cs
| | | ├─SqlFunctionAttribute.cs
| | | ├─SqlProcedureAttribute.cs
| | | ├─Basics
| | | | ├─SqlObjectProxyAttribute.cs
| | | | ├─SqlProxyAttribute.cs
| | | | └SqlSentenceProxyAttribute.cs
├─CorsAccessor
| ├─Options
| | └CorsAccessorSettingsOptions.cs
| ├─Extensions
| | ├─CorsAccessorApplicationBuilderExtensions.cs
| | └CorsAccessorServiceCollectionExtensions.cs
├─ConfigurableOptions
| ├─Options
| | └IConfigurableOptions.cs
| ├─Extensions
| | └ConfigurableOptionsServiceCollectionExtensions.cs
| ├─Attributes
| | └OptionsSettingsAttribute.cs
├─Authorization
| ├─Penetrates.cs
| ├─Requirements
| | └AuthorizePolicyRequirement.cs
| ├─Providers
| | └AuthorizePolicyProvider.cs
| ├─Options
| | └JWTSettingsOptions.cs
| ├─Handlers
| | └AuthorizePolicyHandler.cs
| ├─Extensions
| | └PolicyAuthorizationServiceCollectionExtensions.cs
| ├─Attributes
| | └AuthorizePolicyAttribute.cs
├─App
| ├─App.cs
| ├─Startups
| | ├─AppStartup.cs
| | └HostingStartup.cs
| ├─Options
| | └AppSettingsOptions.cs
| ├─Filters
| | └StartupFilter.cs
| ├─Extensions
| | ├─AppApplicationBuilderExtensions.cs
| | ├─AppServiceCollectionExtensions.cs
| | ├─WebHostBuilderExtensions.cs
| | ├─Types
| | | └ObjectExtensions.cs
| ├─Attributes
| | └AppStartupAttribute.cs

1.2.5 Fur.Application 业务应用层

Fur.Application 业务应用层是最常用的层,几乎所有的业务代码都在这个层中编写。

源码结构:

Fur.Application
├─Fur.Application.Core.csproj
├─Fur.Application.Core.xml
└FurApplicationStartup.cs

1.2.6 Fur.Core 仓储实体层

Fur.Core 主要是存储自定义仓储和定义实体的层。

源码结构:

Fur.Core
├─Fur.Core.csproj
└FurCoreStartup.cs

1.2.7 Fur.Database.Migrations 数据库架构维护层

Fur.Database.Migrations 主要是用来存放 Database FirstCode First 生成的维护文件。

源码结构:

Fur.Database.Migrations
└Fur.Database.Migrations.csproj

1.2.8 Fur.EntityFramework.Core 数据库上下文配置层

Fur.EntityFramework.Core 主要是用来配置数据库上下文和其他数据库相关配置信息的。

源码结构:

Fur.EntityFramework.Core
└Fur.EntityFramework.Core.csproj

1.2.9 Fur.Web.Core 应用核心层

Fur.Web.Core 主要是用来配置 Web 入口一些代码,如 FilterMiddlewares 等。

源码结构:

Fur.Web.Core
├─Fur.Web.Core.xml
└FurWebCoreStartup.cs

1.2.10 Fur.Web.Entry 应用入口层

Fur.Web.Entry 是我们的应用层,也就是我们的 Web 项目层,发布层。

源码结构:

Fur.Web.Entry
├─appsettings.Development.json
├─appsettings.json
├─Fur.Web.Entry.csproj
├─Fur.Web.Entry.csproj.user
├─Fur.Web.Entry.xml
├─Program.cs
├─Startup.cs
├─wwwroot
| └README.md
├─Properties
| └launchSettings.json
├─Controllers
- - - - - - - - - - - +
# Add file header
file_header_template = -----------------------------------------------------------------------------\nFur 是 .NET 5 平台下极易入门、极速开发的 Web 应用框架。\nCopyright © 2020 Fur, Baiqian Co.,Ltd.\n\n框架名称:Fur\n框架作者:百小僧\n框架版本:1.0.0\n源码地址:Gitee:https://gitee.com/monksoul/Fur \n Github:https://github.com/monksoul/Fur \n开源协议:Apache-2.0(http://www.apache.org/licenses/LICENSE-2.0)\n-----------------------------------------------------------------------------

1.2.4 Fur 核心层

Fur 核心层是 Fur 框架的中心,也是 Fur 能够支撑起来的必备层。

源码结构:

Fur
├─Fur.csproj
├─Fur.csproj.user
├─FurStartup.cs
├─ViewEngine
| ├─IViewEngine.cs
| ├─ViewEngine.cs
| ├─Templates
| | ├─IViewEngineCompiledTemplate.cs
| | ├─IViewEngineTemplate.cs
| | ├─ViewEngineCompiledTemplate.cs
| | └ViewEngineTemplate.cs
| ├─Options
| | └ViewEngineCompilationOptions.cs
| ├─Models
| | └AnonymousTypeWrapper.cs
| ├─Exceptions
| | ├─ViewEngineCompilationException.cs
| | └ViewEngineException.cs
| ├─Compilations
| | ├─IViewEngineCompilationOptionsBuilder.cs
| | └ViewEngineCompilationOptionsBuilder.cs
├─UnifyResult
| ├─Providers
| | ├─IUnifyResultProvider.cs
| | └RESTfulResultProvider.cs
| ├─Models
| | └RESTfulResult.cs
| ├─Filters
| | └SuccessUnifyResultFilter.cs
| ├─Extensions
| | └UnifyResultServiceCollectionExtensions.cs
├─SpecificationDocument
| ├─Options
| | └SpecificationDocumentSettingsOptions.cs
| ├─Models
| | ├─GroupOrder.cs
| | ├─SpecificationOpenApiInfo.cs
| | ├─SpecificationOpenApiSecurityRequirementItem.cs
| | └SpecificationOpenApiSecurityScheme.cs
| ├─Extensions
| | ├─SpecificationDocumentApplicationBuilderExtensions.cs
| | └SpecificationDocumentServiceCollectionExtensions.cs
| ├─Builders
| | └SpecificationDocumentBuilder.cs
| ├─Assets
| | └index-mini-profiler.html
├─ObjectMapper
| ├─Extensions
| | └ObjectMapperServiceCollectionExtensions.cs
| ├─Dependencies
| | └IObjectMapper.cs
├─LinqBuilder
| ├─Visitors
| | └ParameterReplaceExpressionVisitor.cs
| ├─Extensions
| | └LinqExtensions.cs
| ├─Builders
| | └LinqExpression.cs
├─FriendlyException
| ├─Oops.cs
| ├─Providers
| | └IErrorCodeTypeProvider.cs
| ├─Options
| | └ErrorCodeMessageSettingsOptions.cs
| ├─Models
| | └MethodIfException.cs
| ├─Filters
| | └FriendlyExceptionFilter.cs
| ├─Extensions
| | └FriendlyExceptionServiceCollectionExtensions.cs
| ├─Attributes
| | ├─ErrorCodeItemMetadataAttribute.cs
| | ├─ErrorCodeTypeAttribute.cs
| | └IfExceptionAttribute.cs
├─DynamicApiController
| ├─Penetrates.cs
| ├─Providers
| | └DynamicApiControllerFeatureProvider.cs
| ├─Options
| | └DynamicApiControllerSettingsOptions.cs
| ├─Models
| | └ParameterRouteTemplate.cs
| ├─Extensions
| | └DynamicApiControllerServiceCollectionExtensions.cs
| ├─Enums
| | └ApiSeats.cs
| ├─Dependencies
| | └IDynamicApiController.cs
| ├─Conventions
| | └DynamicApiControllerApplicationModelConvention.cs
| ├─Attributes
| | ├─ApiDescriptionSettingsAttribute.cs
| | ├─ApiSeatAttribute.cs
| | └DynamicApiControllerAttribute.cs
├─DependencyInjection
| ├─Options
| | └DependencyInjectionSettingsOptions.cs
| ├─Models
| | └ExternalService.cs
| ├─Extensions
| | └DependencyInjectionServiceCollectionExtensions.cs
| ├─Enums
| | ├─InjectionActions.cs
| | ├─InjectionPatterns.cs
| | └RegisterType.cs
| ├─Dependencies
| | ├─IPrivateDependency.cs
| | ├─IScoped.cs
| | ├─ISingleton.cs
| | ├─ITransient.cs
| | ├─Proxies
| | | └IDispatchProxy.cs
| ├─Attributes
| | ├─InjectionAttribute.cs
| | └SkipScanAttribute.cs
├─DataValidation
| ├─Validators
| | └DataValidator.cs
| ├─Providers
| | └IValidationMessageTypeProvider.cs
| ├─Options
| | └ValidationTypeMessageSettingsOptions.cs
| ├─Models
| | └DataValidationResult.cs
| ├─Filters
| | └DataValidationFilter.cs
| ├─Extensions
| | ├─DataValidationExtensions.cs
| | └DataValidationServiceCollectionExtensions.cs
| ├─Enums
| | ├─ValidationPattern.cs
| | └ValidationTypes.cs
| ├─Attributes
| | ├─DataValidationAttribute.cs
| | ├─NonValidationAttribute.cs
| | ├─ValidationItemMetadataAttribute.cs
| | ├─ValidationMessageAttribute.cs
| | ├─ValidationMessageTypeAttribute.cs
| | └ValidationTypeAttribute.cs
├─DataEncryption
| ├─AESEncryption.cs
| ├─DESCEncryption.cs
| └MD5Encryption.cs
├─DatabaseAccessor
| ├─UnitOfWork
| | ├─Filters
| | | └UnitOfWorkFilter.cs
| | ├─Attributes
| | | ├─NonTransactAttribute.cs
| | | └UnitOfWorkAttribute.cs
| ├─Repositories
| | ├─EFCoreRepository.cs
| | ├─IMSRepository.cs
| | ├─IRepository.cs
| | ├─ISqlRepository.cs
| | ├─MSRepository.cs
| | ├─SqlRepository.cs
| | ├─Implantations
| | | ├─DeletableRepository.cs
| | | ├─InsertableRepository.cs
| | | ├─OperableRepository.cs
| | | ├─ReadableRepository.cs
| | | ├─SqlExecutableRepository.cs
| | | ├─SqlReaderRepository.cs
| | | ├─UpdateableRepository.cs
| | | └WritableRepository.cs
| | ├─Dependencies
| | | ├─IDeletableRepository.cs
| | | ├─IInsertableRepository.cs
| | | ├─IOperableRepository.cs
| | | ├─IReadableRepository.cs
| | | ├─IRepositoryDependency.cs
| | | ├─ISqlExecutableRepository.cs
| | | ├─ISqlReaderRepository.cs
| | | ├─IUpdateableRepository.cs
| | | └IWritableRepository.cs
| ├─Pools
| | ├─DbContextPool.cs
| | └IDbContextPool.cs
| ├─MultiTenants
| | ├─Locators
| | | └MultiTenantDbContextLocator.cs
| | ├─Enums
| | | └MultiTenantOptions.cs
| | ├─Entities
| | | └Tenant.cs
| | ├─Dependencies
| | | ├─IMultiTenantOnDatabase.cs
| | | ├─IMultiTenantOnSchema.cs
| | | ├─IMultiTenantOnTable.cs
| | | └IPrivateMultiTenant.cs
| ├─Models
| | ├─DbProvider.cs
| | ├─PagedList.cs
| | ├─ProcedureOutputResult.cs
| | ├─ProcedureOutputValue.cs
| | ├─SqlTemplate.cs
| | └SqlTemplateParameter.cs
| ├─Locators
| | ├─IDbContextLocator.cs
| | └MasterDbContextLocator.cs
| ├─Interceptors
| | ├─DbContextSaveChangesInterceptor.cs
| | ├─SqlCommandProfilerInterceptor.cs
| | └SqlConnectionProfilerInterceptor.cs
| ├─Helpers
| | └DbHelpers.cs
| ├─Extensions
| | ├─DatabaseAccessorServiceCollectionExtensions.cs
| | ├─PagedQueryableExtensions.cs
| | ├─Repositories
| | | ├─IEntityExtensions.cs
| | | ├─IEntityWithDbContextLocatorExtensions.cs
| | | └SqlExtensions.cs
| | ├─DatabaseProvider
| | | ├─DatabaseProviderServiceCollectionExtensions.cs
| | | └Penetrates.cs
| | ├─DatabaseFacade
| | | ├─DbDataConvertExtensions.cs
| | | ├─DbObjectExtensions.cs
| | | └SqlAdoNetExtensions.cs
| ├─Enums
| | ├─DbFunctionType.cs
| | ├─EFCoreErrorCodes.cs
| | └ManualOptions.cs
| ├─Entities
| | ├─Dependencies
| | | ├─Entity.cs
| | | ├─EntityBase.cs
| | | ├─EntityNotKey.cs
| | | ├─IEntity.cs
| | | └IEntityNotKey.cs
| | ├─Configures
| | | ├─IEntitySeedData.cs
| | | ├─IEntityTypeBuilder.cs
| | | ├─IModelBuilderFilter.cs
| | | └IPrivateModelBuilder.cs
| | ├─Attributes
| | | ├─FakeDeleteAttribute.cs
| | | ├─NonAutomaticAttribute.cs
| | | └QueryableFunctionAttribute.cs
| ├─DynamicModels
| | ├─DynamicModelCacheKeyFactory.cs
| | └IEntityMutableTable.cs
| ├─Contexts
| | ├─AppDbContext.cs
| | ├─Builders
| | | ├─AppDbContextBuilder.cs
| | | ├─Models
| | | | └DbContextCorrelationType.cs
| | ├─Attributes
| | | └AppDbContextAttribute.cs
| ├─Attributes
| | └DbParameterAttribute.cs
| ├─Advances
| | ├─Proxies
| | | └SqlDispatchProxy.cs
| | ├─Models
| | | └SqlProxyMethod.cs
| | ├─Dependencies
| | | └ISqlDispatchProxy.cs
| | ├─Attributes
| | | ├─SqlExecuteAttribute.cs
| | | ├─SqlFunctionAttribute.cs
| | | ├─SqlProcedureAttribute.cs
| | | ├─Basics
| | | | ├─SqlObjectProxyAttribute.cs
| | | | ├─SqlProxyAttribute.cs
| | | | └SqlSentenceProxyAttribute.cs
├─CorsAccessor
| ├─Options
| | └CorsAccessorSettingsOptions.cs
| ├─Extensions
| | ├─CorsAccessorApplicationBuilderExtensions.cs
| | └CorsAccessorServiceCollectionExtensions.cs
├─ConfigurableOptions
| ├─Options
| | └IConfigurableOptions.cs
| ├─Extensions
| | └ConfigurableOptionsServiceCollectionExtensions.cs
| ├─Attributes
| | └OptionsSettingsAttribute.cs
├─Authorization
| ├─Penetrates.cs
| ├─Requirements
| | └AuthorizePolicyRequirement.cs
| ├─Providers
| | └AuthorizePolicyProvider.cs
| ├─Options
| | └JWTSettingsOptions.cs
| ├─Handlers
| | └AuthorizePolicyHandler.cs
| ├─Extensions
| | └PolicyAuthorizationServiceCollectionExtensions.cs
| ├─Attributes
| | └AuthorizePolicyAttribute.cs
├─App
| ├─App.cs
| ├─Startups
| | ├─AppStartup.cs
| | └HostingStartup.cs
| ├─Options
| | └AppSettingsOptions.cs
| ├─Filters
| | └StartupFilter.cs
| ├─Extensions
| | ├─AppApplicationBuilderExtensions.cs
| | ├─AppServiceCollectionExtensions.cs
| | ├─WebHostBuilderExtensions.cs
| | ├─Types
| | | └ObjectExtensions.cs
| ├─Attributes
| | └AppStartupAttribute.cs

1.2.5 Fur.Application 业务应用层

Fur.Application 业务应用层是最常用的层,几乎所有的业务代码都在这个层中编写。

源码结构:

Fur.Application
├─Fur.Application.Core.csproj
├─Fur.Application.Core.xml
└FurApplicationStartup.cs

1.2.6 Fur.Core 仓储实体层

Fur.Core 主要是存储自定义仓储和定义实体的层。

源码结构:

Fur.Core
├─Fur.Core.csproj
└FurCoreStartup.cs

1.2.7 Fur.Database.Migrations 数据库架构维护层

Fur.Database.Migrations 主要是用来存放 Database FirstCode First 生成的维护文件。

源码结构:

Fur.Database.Migrations
└Fur.Database.Migrations.csproj

1.2.8 Fur.EntityFramework.Core 数据库上下文配置层

Fur.EntityFramework.Core 主要是用来配置数据库上下文和其他数据库相关配置信息的。

源码结构:

Fur.EntityFramework.Core
└Fur.EntityFramework.Core.csproj

1.2.9 Fur.Web.Core 应用核心层

Fur.Web.Core 主要是用来配置 Web 入口一些代码,如 FilterMiddlewares 等。

源码结构:

Fur.Web.Core
├─Fur.Web.Core.xml
└FurWebCoreStartup.cs

1.2.10 Fur.Web.Entry 应用入口层

Fur.Web.Entry 是我们的应用层,也就是我们的 Web 项目层,发布层。

源码结构:

Fur.Web.Entry
├─appsettings.Development.json
├─appsettings.json
├─Fur.Web.Entry.csproj
├─Fur.Web.Entry.csproj.user
├─Fur.Web.Entry.xml
├─Program.cs
├─Startup.cs
├─wwwroot
| └README.md
├─Properties
| └launchSettings.json
├─Controllers
+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/specification-document/index.html b/handbook/build/docs/specification-document/index.html index b7e4b078665..f584569e4a8 100644 --- a/handbook/build/docs/specification-document/index.html +++ b/handbook/build/docs/specification-document/index.html @@ -4,34 +4,34 @@ -6. 规范化接口文档 | Fur - - - - - - - - - - - +6. 规范化接口文档 | Fur + + + + + + + + + + +
-

6. 规范化接口文档

6.1 什么是接口文档

在现在移动为王、多端互辅、前端百花齐放的开放时代,不再是一人包揽式开发,大家各司其职,后端工程师负责接口开发,前端负责接口联调,也就是互联网现在流行的前后端分离架构。

所以就需要由前后端工程师共同定义接口,编写接口文档,之后大家按照这个接口文档进行开发、维护及开放给第三方。

6.2 为什么要写接口文档

  • 能够让前端开发与后台开发人员更好的配合,提高工作效率
  • 项目迭代或者项目人员更迭时,方便后期人员查看和维护
  • 方便测试人员进行接口测试

6.3 为什么需要规范化文档

由于每个公司后端人员技术参差不齐,技术文档能力也不例外,导致接口定义及文档五花八门,不同项目或不同公司对接极其困难,而且体验糟糕。所以,无规矩不成方圆,为了开发人员间更好的配合,迫切需要整理出一套规范。

通常接口规范分为六个部分:

6.3.1 协议规范

为了确保不同系统/模块间的数据交互,需要事先约定好通讯协议,如:TCP、HTTP、HTTPS 协议。为了确保数据交互安全,建议使用 HTTPS 协议

6.3.2 接口路径规范

作为接口路径,为了方便清晰的区分来自不同的系统,可以采用不同系统/模块名作为接口路径前缀,如:支付模块:/pay/xxx,订单模块:/order/xxx

6.3.3 版本控制规范

为了便于后期接口的升级和维护,建议在接口路径中加入版本号,便于管理,实现接口多版本的可维护性。如:接口路径中添加类似"v1"、"v2"等版本号

6.3.4 接口命名规范

和 C# 命名规范一样,好的、统一的接口命名规范,不仅可以增强其可读性,而且还会减少很多不必要的口头/书面上的解释。,可使用"驼峰命名法"按照实现接口的业务类型、业务场景等命名,有必要时可采取多级目录命名,但目录不宜过长,两级目录较为适宜

  • 常见命名方式:
    • 接口名称动词前/后缀化: 接口名称以接口数据操作的动词为前/后缀,常见动词有:Add、Delete、Update、Query、Get、Send、Save、Detail、List等,如:新建用户 AddUser、查询订单详情 QueryOrderDetail
    • 接口名称动词 + 请求方式:接口路径中包含具体接口名称的名词,接口数据操作动作以 HTTP 请求方式来区分。常用的 HTTP 请求方式有:
      • GET:从服务器取出资源(一项或多项)
      • POST:在服务器新建一个资源
      • PUT:在服务器更新资源(客户端提供改变后的完整资源)
      • PATCH:在服务器更新资源(客户端提供改变的属性)
      • DELETE:从服务器删除资源

6.3.5 请求参数规范

  • 请求方式:按照 GET、POST、PUT 等含义定义,避免出现不一致现象,对人造成误解、歧义
    • 请求头:请求头根据项目需求添加配置参数。如:请求数据格式,accept=application/json 等。如有需要,请求头可根据项目需求要求传入用户 token、唯一验签码等加密数据
    • 请求参数/请求体: 请求参数字段,尽可能与数据库表字段、对象属性名等保持一致,因为保持一致最省事,最舒服的一件事

6.3.6 返回数据规范

统一规范返回数据的格式,对己对彼都有好处,此处以 json 格式为例。返回数据应包含:返回状态码、返回状态信息、具体数据返回数据中的状态码、状态信息,常指具体的业务状态,不建议和 HTTP 状态码混在一起。HTTP 状态,是用来体现 HTTP 链路状态情况,如:404-Not Found。HTTP 状态码和 json 结果中的状态码,并存尚可,用于体现不同维度的状态。

6.4 什么是 Swagger

相信无论是前端还是后端开发,都或多或少地被接口文档折磨过。前端经常抱怨后端给的接口文档与实际情况不一致。后端又觉得编写及维护接口文档会耗费不少精力,经常来不及更新。

其实无论是前端调用后端,还是后端调用后端,都期望有一个好的接口文档。但是这个接口文档对于程序员来说,就跟注释一样,经常会抱怨别人写的代码没有写注释,然而自己写起代码起来,最讨厌的,也是写注释。所以仅仅只通过强制来规范大家是不够的,随着时间推移,版本迭代,接口文档往往很容易就跟不上代码了。

发现了痛点就要去找解决方案。解决方案用的人多了,就成了标准的规范,这就是 Swagger 的由来

通过这套规范,你只需要按照它的规范去定义接口及接口相关的信息。再通过 Swagger 衍生出来的一系列项目和工具,就可以做到生成各种格式的接口文档,生成多种语言的客户端和服务端的代码,以及在线接口调试页面等等。

这样,如果按照新的开发模式,在开发新版本或者迭代版本的时候,只需要更新 Swagger 描述文件,就可以自动生成接口文档和客户端服务端代码,做到调用端代码、服务端代码以及接口文档的一致性。

所以,Swagger 是一个规范和完整的框架,用于生成、描述、调用和可视化RESTful 风格的 Web 服务。

总体目标是使客户端和文件系统作为服务器以同样的速度来更新。文件的方法、参数和模型紧密集成到服务器端的代码,允许 API 来始终保持同步。Swagger 让部署管理和使用功能强大的 API 从未如此简单。

6.5 Swagger 使用

Fur 框架提供了非常方便且灵活的 Swagger 配置,无需增加额外学习成本。

6.5.1 注册服务

Fur.Web.Core\FurWebCoreStartup.cs
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
+

6. 规范化接口文档

6.1 什么是接口文档

在现在移动为王、多端互辅、前端百花齐放的开放时代,不再是一人包揽式开发,大家各司其职,后端工程师负责接口开发,前端负责接口联调,也就是互联网现在流行的前后端分离架构。

所以就需要由前后端工程师共同定义接口,编写接口文档,之后大家按照这个接口文档进行开发、维护及开放给第三方。

6.2 为什么要写接口文档

  • 能够让前端开发与后台开发人员更好的配合,提高工作效率
  • 项目迭代或者项目人员更迭时,方便后期人员查看和维护
  • 方便测试人员进行接口测试

6.3 为什么需要规范化文档

由于每个公司后端人员技术参差不齐,技术文档能力也不例外,导致接口定义及文档五花八门,不同项目或不同公司对接极其困难,而且体验糟糕。所以,无规矩不成方圆,为了开发人员间更好的配合,迫切需要整理出一套规范。

通常接口规范分为六个部分:

6.3.1 协议规范

为了确保不同系统/模块间的数据交互,需要事先约定好通讯协议,如:TCP、HTTP、HTTPS 协议。为了确保数据交互安全,建议使用 HTTPS 协议

6.3.2 接口路径规范

作为接口路径,为了方便清晰的区分来自不同的系统,可以采用不同系统/模块名作为接口路径前缀,如:支付模块:/pay/xxx,订单模块:/order/xxx

6.3.3 版本控制规范

为了便于后期接口的升级和维护,建议在接口路径中加入版本号,便于管理,实现接口多版本的可维护性。如:接口路径中添加类似"v1"、"v2"等版本号

6.3.4 接口命名规范

和 C# 命名规范一样,好的、统一的接口命名规范,不仅可以增强其可读性,而且还会减少很多不必要的口头/书面上的解释。,可使用"驼峰命名法"按照实现接口的业务类型、业务场景等命名,有必要时可采取多级目录命名,但目录不宜过长,两级目录较为适宜

  • 常见命名方式:
    • 接口名称动词前/后缀化: 接口名称以接口数据操作的动词为前/后缀,常见动词有:Add、Delete、Update、Query、Get、Send、Save、Detail、List等,如:新建用户 AddUser、查询订单详情 QueryOrderDetail
    • 接口名称动词 + 请求方式:接口路径中包含具体接口名称的名词,接口数据操作动作以 HTTP 请求方式来区分。常用的 HTTP 请求方式有:
      • GET:从服务器取出资源(一项或多项)
      • POST:在服务器新建一个资源
      • PUT:在服务器更新资源(客户端提供改变后的完整资源)
      • PATCH:在服务器更新资源(客户端提供改变的属性)
      • DELETE:从服务器删除资源

6.3.5 请求参数规范

  • 请求方式:按照 GET、POST、PUT 等含义定义,避免出现不一致现象,对人造成误解、歧义
    • 请求头:请求头根据项目需求添加配置参数。如:请求数据格式,accept=application/json 等。如有需要,请求头可根据项目需求要求传入用户 token、唯一验签码等加密数据
    • 请求参数/请求体: 请求参数字段,尽可能与数据库表字段、对象属性名等保持一致,因为保持一致最省事,最舒服的一件事

6.3.6 返回数据规范

统一规范返回数据的格式,对己对彼都有好处,此处以 json 格式为例。返回数据应包含:返回状态码、返回状态信息、具体数据返回数据中的状态码、状态信息,常指具体的业务状态,不建议和 HTTP 状态码混在一起。HTTP 状态,是用来体现 HTTP 链路状态情况,如:404-Not Found。HTTP 状态码和 json 结果中的状态码,并存尚可,用于体现不同维度的状态。

6.4 什么是 Swagger

相信无论是前端还是后端开发,都或多或少地被接口文档折磨过。前端经常抱怨后端给的接口文档与实际情况不一致。后端又觉得编写及维护接口文档会耗费不少精力,经常来不及更新。

其实无论是前端调用后端,还是后端调用后端,都期望有一个好的接口文档。但是这个接口文档对于程序员来说,就跟注释一样,经常会抱怨别人写的代码没有写注释,然而自己写起代码起来,最讨厌的,也是写注释。所以仅仅只通过强制来规范大家是不够的,随着时间推移,版本迭代,接口文档往往很容易就跟不上代码了。

发现了痛点就要去找解决方案。解决方案用的人多了,就成了标准的规范,这就是 Swagger 的由来

通过这套规范,你只需要按照它的规范去定义接口及接口相关的信息。再通过 Swagger 衍生出来的一系列项目和工具,就可以做到生成各种格式的接口文档,生成多种语言的客户端和服务端的代码,以及在线接口调试页面等等。

这样,如果按照新的开发模式,在开发新版本或者迭代版本的时候,只需要更新 Swagger 描述文件,就可以自动生成接口文档和客户端服务端代码,做到调用端代码、服务端代码以及接口文档的一致性。

所以,Swagger 是一个规范和完整的框架,用于生成、描述、调用和可视化RESTful 风格的 Web 服务。

总体目标是使客户端和文件系统作为服务器以同样的速度来更新。文件的方法、参数和模型紧密集成到服务器端的代码,允许 API 来始终保持同步。Swagger 让部署管理和使用功能强大的 API 从未如此简单。

6.5 Swagger 使用

Fur 框架提供了非常方便且灵活的 Swagger 配置,无需增加额外学习成本。

6.5.1 注册服务

Fur.Web.Core\FurWebCoreStartup.cs
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Fur.Web.Core
{
[AppStartup(800)]
public sealed class FurWebCoreStartup : AppStartup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddSpecificationDocuments();
services.AddControllers();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
// Other Codes
app.UseSpecificationDocuments();
-
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
小知识

services.AddSpecificationDocuments() 通常和 .AddDynamicApiControllers() 成对出现。

6.5.2 默认地址

Fur 框架中,默认 规范化文档 地址为主机根目录,支持自定义配置

如下图所示:

6.5.3 默认分组

Fur 框架中默认分组名为 Default支持自定义配置

6.5.4 文档注释

规范化文档默认扫描 Fur.ApplicationFur.Web.CoreFur.Web.Entry 三个程序集.xml 注释文件,支持自定义配置

只支持 /// 标识的注释语法,如:类、方法、属性、参数、返回值、验证特性

using Fur.DynamicApiController;
+
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
小知识

services.AddSpecificationDocuments() 通常和 .AddDynamicApiControllers() 成对出现。

6.5.2 默认地址

Fur 框架中,默认 规范化文档 地址为主机根目录,支持自定义配置

如下图所示:

6.5.3 默认分组

Fur 框架中默认分组名为 Default支持自定义配置

6.5.4 文档注释

规范化文档默认扫描 Fur.ApplicationFur.Web.CoreFur.Web.Entry 三个程序集.xml 注释文件,支持自定义配置

只支持 /// 标识的注释语法,如:类、方法、属性、参数、返回值、验证特性

using Fur.DynamicApiController;
namespace Fur.Application
{
/// <summary>
/// 类注释
/// </summary>
public class FurAppService : IDynamicApiController
{
/// <summary>
/// 方法注释
/// </summary>
/// <returns></returns>
public string Get()
{
return nameof(Fur);
}
-
/// <summary>
/// 带 ID 参数的方法注释
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public int Get(int id)
{
return id;
}
}
}

如下图所示:

6.5.5 多分组支持

多分组是一个系统中必备功能,我们可以将系统划分为多个模块,每个模块都独立的 api 配置。在 Fur 框架中,实现多分组非常简单。如:

using Fur.DynamicApiController;
+
/// <summary>
/// 带 ID 参数的方法注释
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public int Get(int id)
{
return id;
}
}
}

如下图所示:

6.5.5 多分组支持

多分组是一个系统中必备功能,我们可以将系统划分为多个模块,每个模块都独立的 api 配置。在 Fur 框架中,实现多分组非常简单。如:

using Fur.DynamicApiController;
namespace Fur.Application
{
[ApiDescriptionSettings("Group1")]
public class FurAppService : IDynamicApiController
{
/// <summary>
/// 随父类 Group1 分组
/// </summary>
/// <returns></returns>
public string Post()
{
return nameof(Fur);
}
/// <summary>
/// 在 Group1、Group3 都有我
/// </summary>
/// <returns></returns>
[ApiDescriptionSettings("Group1", "Group3")]
public string Get()
{
return nameof(Fur);
}
-
/// <summary>
/// 我只在 Group2 出现
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[ApiDescriptionSettings("Group2")]
public int Get(int id)
{
return id;
}
}
}

如下图所示:

6.5.6 多分组排序

通过分组名称添加 @整数 进行排序

using Fur.DynamicApiController;
+
/// <summary>
/// 我只在 Group2 出现
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[ApiDescriptionSettings("Group2")]
public int Get(int id)
{
return id;
}
}
}

如下图所示:

6.5.6 多分组排序

通过分组名称添加 @整数 进行排序

using Fur.DynamicApiController;
namespace Fur.Application
{
[ApiDescriptionSettings("Group1@1")]
public class FurAppService : IDynamicApiController
{
public string Post()
{
return nameof(Fur);
}
[ApiDescriptionSettings("Group1", "Group3")]
public string Get()
{
return nameof(Fur);
}
-
[ApiDescriptionSettings("Group@2")]
public int Get(int id)
{
return id;
}
}
}

可以通过在分组名后面添加 @整数 进行排序,整数 越大排前面。如果分组名称多次指定且多次指定了 @整数 ,则自动取该分组最大的整数进行排序。

如下图所示:

排序说明

分组默认排序 Order0。如果同时配置了 @整数appsettings.json 配置文件,那么优先采用 appsettings.json 中的 Order

6.5.7 多分组信息配置

Fur 框架提供了可通过 appsetting.json 配置分组信息:

Fur.Web.Entry/appsettings.json
{
"AppSettings": {
"SpecificationDocumentSettings": {
"GroupOpenApiInfos": [
{
"Group": "Group1",
"Title": "分组标题",
"Description": "这里是分组描述",
"Version": "版本号",
"TermsOfService": "https://chinadot.net",
"Contact": {
"Name": "百小僧",
"Url": "https://gitee.com/monksoul",
"Email": "monksoul@outlook.com"
},
"License": {
"Name": "Apache-2.0",
"Url": "https://gitee.com/monksoul/Fur/blob/alpha/LICENSE"
}
}
]
}
}
}

如下图所示:

6.5.8 组中组(标签)

Tag 配置主要用于配置 Swagger 标签分组信息及合并标签。也就是 组中组:

未贴标签之前

using Fur.DynamicApiController;
+
[ApiDescriptionSettings("Group@2")]
public int Get(int id)
{
return id;
}
}
}

可以通过在分组名后面添加 @整数 进行排序,整数 越大排前面。如果分组名称多次指定且多次指定了 @整数 ,则自动取该分组最大的整数进行排序。

如下图所示:

排序说明

分组默认排序 Order0。如果同时配置了 @整数appsettings.json 配置文件,那么优先采用 appsettings.json 中的 Order

6.5.7 多分组信息配置

Fur 框架提供了可通过 appsetting.json 配置分组信息:

Fur.Web.Entry/appsettings.json
{
"AppSettings": {
"SpecificationDocumentSettings": {
"GroupOpenApiInfos": [
{
"Group": "Group1",
"Title": "分组标题",
"Description": "这里是分组描述",
"Version": "版本号",
"TermsOfService": "https://chinadot.net",
"Contact": {
"Name": "百小僧",
"Url": "https://gitee.com/monksoul",
"Email": "monksoul@outlook.com"
},
"License": {
"Name": "Apache-2.0",
"Url": "https://gitee.com/monksoul/Fur/blob/alpha/LICENSE"
}
}
]
}
}
}

如下图所示:

6.5.8 组中组(标签)

Tag 配置主要用于配置 Swagger 标签分组信息及合并标签。也就是 组中组:

未贴标签之前

using Fur.DynamicApiController;
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
public string Get()
{
return nameof(Fur);
}
public int Get(int id)
{
return id;
}
}
public class TestAppService : IDynamicApiController
{
public string Get()
{
return nameof(Fur);
}
@@ -39,24 +39,24 @@
namespace Fur.Application
{
[ApiDescriptionSettings(Tag = "分组一")]
public class FurAppService : IDynamicApiController
{
public string Get()
{
return nameof(Fur);
}
public int Get(int id)
{
return id;
}
}
[ApiDescriptionSettings(Tag = "分组二")]
public class TestAppService : IDynamicApiController
{
public string Get()
{
return nameof(Fur);
}
-
public int Get(int id)
{
return id;
}
}
}

如下图所示:

小知识

如果 Tag 名字一样,则会自动合并,否则只是命名。

6.5.9 默认展开所有文档

Fur.Web.Entry/appsettings.json
{
"AppSettings": {
"SpecificationDocumentSettings": {
"DocExpansionState": "Full"
}
}
}

如下图所示:

DocExpansionState 配置说明:

  • List:列表式(展开子类),默认值
  • Full:完全展开
  • None:列表式(不展开子类)

6.5.10 配置文档标题

Fur.Web.Entry/appsettings.json
{
"AppSettings": {
"SpecificationDocumentSettings": {
"DocumentTitle": "我是自定义标题"
}
}
}

如下图所示:

6.5.11 授权控制

待整理...

Fur.Web.Entry/appsettings.json
{
"AppSettings": {
"SpecificationDocumentSettings": {
"EnableAuthorized": true,
+
public int Get(int id)
{
return id;
}
}
}

如下图所示:

小知识

如果 Tag 名字一样,则会自动合并,否则只是命名。

6.5.9 默认展开所有文档

Fur.Web.Entry/appsettings.json
{
"AppSettings": {
"SpecificationDocumentSettings": {
"DocExpansionState": "Full"
}
}
}

如下图所示:

DocExpansionState 配置说明:

  • List:列表式(展开子类),默认值
  • Full:完全展开
  • None:列表式(不展开子类)

6.5.10 配置文档标题

Fur.Web.Entry/appsettings.json
{
"AppSettings": {
"SpecificationDocumentSettings": {
"DocumentTitle": "我是自定义标题"
}
}
}

如下图所示:

6.5.11 授权控制

待整理...

Fur.Web.Entry/appsettings.json
{
"AppSettings": {
"SpecificationDocumentSettings": {
"EnableAuthorized": true,
"SecurityDefinitions": [
{
"Id": "Bearer",
"Type": "Http",
"Name": "Authorization",
"Description": "JWT Authorization header using the Bearer scheme.",
"BearerFormat": "JWT",
"Scheme": "bearer",
"In": "Header",
-
"Requirement": {
"Scheme": {
"Reference": {
"Id": "Bearer",
"Type": "SecurityScheme"
},
"Accesses": null
}
}
}
]
}
}
}

6.5.12 在线测试

如下图所示:

6.5.13 性能监视 MiniProfiler

规范化文档默认集成了 MiniProfiler 第三方性能组件,通过该组件可以方便查看请求性能、异常堆栈、数据库操作等信息。默认在 Swagger 首页左上角显示。

如下图所示:

小提示

也可以通过 appsetting.jsonAppSettings:InjectMiniProfiler 设为 false 关闭。

6.5.14 定义接口输出类型

using Fur.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
-
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
[ProducesResponseType(201, Type = typeof(TestDto))]
[ProducesResponseType(400)]
public string Get()
{
return nameof(Fur);
}
}
}

如下图所示:

6.6 SpecificationDocumentSettings 配置

除了上述例子外,Fur 提供了一些配置选项,如:

  • DocumentTitle:文档标题,string,默认 Specification Api Document
  • DefaultGroupName:默认分组名,string,默认 Default
  • EnableAuthorized:是否启用权限控制,bool,默认 true
  • FormatAsV2:采用 Swagger 2.0 版本,bool,默认 false
  • RoutePrefix:规范化文档地址,string,默认 string
  • DocExpansionState:文档显示方式,DocExpansion,默认 List,取值:
    • List:列表式(展开子类),默认值
    • Full:完全展开
    • None:列表式(不展开子类)
  • XmlComments:程序集注释描述文件名(可带 .xmlstring,默认 Fur.Application, Fur.Web.Entry, Fur.Web.Core
  • GroupOpenApiInfos:分组信息配置,SpecificationOpenApiInfo[],默认 { 'Group': 'Default'}
  • SecurityDefinitions:安全策略定义配置,SpecificationOpenApiSecurityScheme[],默认 []

6.7 统一返回值模型

Fur 框架提供 规范化结果 功能,可以通过实现 IUnifyResultProvider 提供器实现统一规范化返回值定制,如:RESTfulResultProvider

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using System.Collections.Generic;
+
"Requirement": {
"Scheme": {
"Reference": {
"Id": "Bearer",
"Type": "SecurityScheme"
},
"Accesses": null
}
}
}
]
}
}
}

6.5.12 在线测试

如下图所示:

6.5.13 性能监视 MiniProfiler

规范化文档默认集成了 MiniProfiler 第三方性能组件,通过该组件可以方便查看请求性能、异常堆栈、数据库操作等信息。默认在 Swagger 首页左上角显示。

如下图所示:

小提示

也可以通过 appsetting.jsonAppSettings:InjectMiniProfiler 设为 false 关闭。

6.5.14 定义接口输出类型

using Fur.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
+
namespace Fur.Application
{
public class FurAppService : IDynamicApiController
{
[ProducesResponseType(201, Type = typeof(TestDto))]
[ProducesResponseType(400)]
public string Get()
{
return nameof(Fur);
}
}
}

如下图所示:

6.6 SpecificationDocumentSettings 配置

除了上述例子外,Fur 提供了一些配置选项,如:

  • DocumentTitle:文档标题,string,默认 Specification Api Document
  • DefaultGroupName:默认分组名,string,默认 Default
  • EnableAuthorized:是否启用权限控制,bool,默认 true
  • FormatAsV2:采用 Swagger 2.0 版本,bool,默认 false
  • RoutePrefix:规范化文档地址,string,默认 string
  • DocExpansionState:文档显示方式,DocExpansion,默认 List,取值:
    • List:列表式(展开子类),默认值
    • Full:完全展开
    • None:列表式(不展开子类)
  • XmlComments:程序集注释描述文件名(可带 .xmlstring,默认 Fur.Application, Fur.Web.Entry, Fur.Web.Core
  • GroupOpenApiInfos:分组信息配置,SpecificationOpenApiInfo[],默认 { 'Group': 'Default'}
  • SecurityDefinitions:安全策略定义配置,SpecificationOpenApiSecurityScheme[],默认 []

6.7 统一返回值模型

Fur 框架提供 规范化结果 功能,可以通过实现 IUnifyResultProvider 提供器实现统一规范化返回值定制,如:RESTfulResultProvider

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using System.Collections.Generic;
namespace Fur.UnifyResult
{
/// <summary>
/// RESTful 风格返回值
/// </summary>
public class RESTfulResultProvider : IUnifyResultProvider
{
/// <summary>
/// 异常返回值
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public IActionResult OnException(ExceptionContext context)
{
return new JsonResult(new RESTfulResult
{
StatusCode = StatusCodes.Status500InternalServerError,
Successed = false,
Data = null,
Errors = context.Exception.Message
});
}
/// <summary>
/// 成功返回值
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public IActionResult OnSuccessed(ActionExecutedContext context)
{
object data;
// 处理内容结果
if (context.Result is ContentResult contentResult) data = contentResult.Content;
// 处理对象结果
else if (context.Result is ObjectResult objectResult) data = objectResult.Value;
else return null;
return new JsonResult(new RESTfulResult
{
StatusCode = context.Result is EmptyResult ? StatusCodes.Status204NoContent : StatusCodes.Status200OK,
Successed = true,
Data = data,
Errors = null
});
}
-
/// <summary>
/// 验证失败返回值
/// </summary>
/// <param name="context"></param>
/// <param name="modelStates"></param>
/// <param name="validationResults"></param>
/// <param name="validateFaildMessage"></param>
/// <returns></returns>
public IActionResult OnValidateFailed(ActionExecutingContext context, ModelStateDictionary modelStates, Dictionary<string, IEnumerable<string>> validationResults, string validateFaildMessage)
{
return new JsonResult(new RESTfulResult
{
StatusCode = StatusCodes.Status400BadRequest,
Successed = false,
Data = null,
Errors = validationResults
});
}
}
}

之后在 Startup.cs 中注册即可:

services.AddControllers().AddUnifyResult<RESTfulResult, RESTfulResultProvider>();

6.8 反馈与建议

与我们交流

给 Fur 提 Issue

- - - - - - - - - - - +
/// <summary>
/// 验证失败返回值
/// </summary>
/// <param name="context"></param>
/// <param name="modelStates"></param>
/// <param name="validationResults"></param>
/// <param name="validateFaildMessage"></param>
/// <returns></returns>
public IActionResult OnValidateFailed(ActionExecutingContext context, ModelStateDictionary modelStates, Dictionary<string, IEnumerable<string>> validationResults, string validateFaildMessage)
{
return new JsonResult(new RESTfulResult
{
StatusCode = StatusCodes.Status400BadRequest,
Successed = false,
Data = null,
Errors = validationResults
});
}
}
}

之后在 Startup.cs 中注册即可:

services.AddControllers().AddUnifyResult<RESTfulResult, RESTfulResultProvider>();

6.8 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/split-db/index.html b/handbook/build/docs/split-db/index.html index 83df14778ef..508b26cd731 100644 --- a/handbook/build/docs/split-db/index.html +++ b/handbook/build/docs/split-db/index.html @@ -4,36 +4,36 @@ -9.27 分表分库 | Fur - - - - - - - - - - - +9.27 分表分库 | Fur + + + + + + + + + + +
-

9.27 分表分库

特此声明

本章 9.27.29.27.5 小节挪用博主:雨点的名字分库分表 - 理论 博客内容。特此声明。

9.27.1 应用场景

数据库中的数据量不一定是可控的,在未进行分库分表的情况下,随着时间和业务的发展,库中的表会越来越多,表中的数据量也会越来越大,相应地,数据操作增删改查的开销也会越来越大。

另外,由于无法进行分布式式部署,而一台服务器的资源(CPU、磁盘、内存、IO 等)是有限的,最终数据库所能承载的数据量、数据处理能力都将遭遇瓶颈。

这个时候就需要对数据库或数据表进行拆分。

数据切分可以分为:垂直切分水平切分

9.27.2 垂直切分

垂直切分又可以分为: 垂直分库和垂直分表。

9.27.2.1 垂直分库

根据业务耦合性,将关联度低的不同表存储在不同的数据库。做法与大系统拆分为多个小系统类似,按业务分类进行独立划分。与"微服务治理"的做法相似,每个微服务使用单独的一个数据库。

说明

一开始我们是单体服务,所以只有一个数据库,所有的表都在这个库里。

后来因为业务需求,单体服务变成微服务治理。所以将之前的一个商品库,拆分成多个数据库。每个微服务对于一个数据库。

9.27.2.2 垂直分表

把一个表的多个字段分别拆成多个表,一般按字段的冷热拆分,热字段一个表,冷字段一个表。从而提升了数据库性能。

说明

一开始商品表中包含商品的所有字段,但是我们发现:

1.商品详情和商品属性字段较长。2.商品列表的时候我们是不需要显示商品详情和商品属性信息,只有在点进商品商品的时候才会展示商品详情信息。

所以可以考虑把商品详情和商品属性单独切分一张表,提高查询效率。

9.27.2.3 优缺点

  • 优点

    • 解决业务系统层面的耦合,业务清晰
    • 与微服务的治理类似,也能对不同业务的数据进行分级管理、维护、监控、扩展等
    • 高并发场景下,垂直切分一定程度的提升 IO、数据库连接数、单机硬件资源的瓶颈
  • 缺点

    • 分库后无法 Join,只能通过接口聚合方式解决,提升了开发的复杂度
    • 分库后分布式事务处理复杂
    • 依然存在单表数据量过大的问题(需要水平切分)

9.27.3 水平切分

当一个应用难以再细粒度的垂直切分或切分后数据量行数巨大,存在单库读写、存储性能瓶颈,这时候就需要进行水平切分了。

水平切分也可以分为:水平分库和水平分表。

9.27.3.1 水平分库

上面虽然已经把商品库分成 3 个库,但是随着业务的增加一个订单库也出现 QPS 过高,数据库响应速度来不及,一般 mysql 单机也就 1000 左右的 QPS,如果超过 1000 就要考虑分库。

9.27.3.2 水平分表

一般我们一张表的数据不要超过 1 千万,如果表数据超过 1 千万,并且还在不断增加数据,那就可以考虑分表。

9.27.3.3 优缺点

  • 优点

    • 不存在单库数据量过大、高并发的性能瓶颈,提升系统稳定性和负载能力
    • 应用端改造较小,不需要拆分业务模块
  • 缺点

    • 跨分片的事务一致性难以保证
    • 跨库的 Join 关联查询性能较差
    • 数据多次扩展难度和维护量极大

9.27.4 数据分片规则

我们考虑去水平切分表,将一张表水平切分成多张表,这就涉及到数据分片的规则,比较常见的有:Hash 取模分表、数值 Range 分表、一致性 Hash 算法分表。

9.27.4.1 Hash 取模分表

一般采用 Hash 取模的切分方式,例如:假设按 goods_id 分 4 张表。(goods_id%4 取整确定表)

优缺点

  • 优点

    • 数据分片相对比较均匀,不容易出现热点和并发访问的瓶颈。
  • 缺点

    • 后期分片集群扩容时,需要迁移旧的数据很难。
    • 容易面临跨分片查询的复杂问题。比如上例中,如果频繁用到的查询条件中不带 goods_id 时,将会导致无法定位数据库,从而需要同时向 4 个库发起查询, -再在内存中合并数据,取最小集返回给应用,分库反而成为拖累。

9.27.4.2 数值 Range 分表

按照时间区间或 ID 区间来切分。例如:将 goods_id 为 1-1000 的记录分到第一个表,1000-2000 的分到第二个表,以此类推。

优缺点

  • 优点

    • 单表大小可控
    • 天然便于水平扩展,后期如果想对整个分片集群扩容时,只需要添加节点即可,无需对其他分片的数据进行迁移
    • 使用分片字段进行范围查找时,连续分片可快速定位分片进行快速查询,有效避免跨分片查询的问题。
  • 缺点

- - - - - - - - - - - +
// 创建新的 DbContext,然后刷新 OnModelCreating(推荐方式)
var dynamicDbContextResolve = App.TransientServices.GetService<Func<Type, IScoped, DbContext>>();
var dynamicDbContext = dynamicDbContextResolve(typeof(MyDbContextLocator), default);
// 重新调用 OnModelCreating,在 OnModelCreating 中配置 ToTable("动态表") 即可。
DynamicModelCacheKeyFactory.RebuildModels();
var persons= dynamicDbContext.Set<Person>();
persons.Add(new Person{});
了解更多

想了解更多 DynamicModelCacheKeyFactory 知识可查阅 EF Core - 多个模型之间交替 章节。

9.27.7 反馈与建议

与我们交流

给 Fur 提 Issue

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/tran/index.html b/handbook/build/docs/tran/index.html index cf321d1b20b..bc8f7c75fd5 100644 --- a/handbook/build/docs/tran/index.html +++ b/handbook/build/docs/tran/index.html @@ -4,35 +4,35 @@ -9.25 事务和工作单元 | Fur - - - - - - - - - - - +9.25 事务和工作单元 | Fur + + + + + + + + + + +
-

9.25 事务和工作单元

9.25.1 事务

事务指作为单个逻辑工作单元执行的一系列操作,要么完全地执行,要么完全地不执行

简单的说,事务就是并发控制的单位,是用户定义的一个操作序列。 而一个逻辑工作单元要成为事务,就必须满足 ACID 属性。

  • A:原子性(Atomicity):事务中的操作要么都不做,要么就全做
  • C:一致性(Consistency):事务执行的结果必须是从数据库从一个一致性状态转换到另一个一致性状态
  • I:隔离性(Isolation):一个事务的执行不能被其他事务干扰
  • D:持久性(Durability):一个事务一旦提交,它对数据库中数据的改变就应该是永久性的

默认情况下,Fur 框架为每一次请求都开启了分布式事务,保证了每一次请求都是一个完整的 工作单元。当然,我们也可以手动管理事务。

9.25.2 工作单元

简单来说,就是为了保证一次完整的功能操作所产生的一些列提交数据的完整性,起着事务的作用。在计算机领域中,工作单元通常用 UnitOfWork 名称表示。

通常我们保证用户的每一次请求都是处于在一个功能单元中,也就是工作单元。

默认情况下,在 Fur 框架中,工作单元无需我们手动维护,框架会自动保证了每一次请求都是一个 工作单元,要么同时成功,要么同时失败。

9.25.3 如何使用

9.25.3.1 自动管理

Fur 框架中,工作单元无需我们手动维护,框架会自动保证了每一次请求都是一个 工作单元,要么同时成功,要么同时失败。所以无需操作。

9.25.3.2 手动管理

// 开启事务
using (var transaction = _testRepository.Database.BeginTransaction())
{
try
{
_testRepository.Insert(new Blog { Url = "http://blogs.msdn.com/dotnet" });
_testRepository.SaveChanges();
+

9.25 事务和工作单元

9.25.1 事务

事务指作为单个逻辑工作单元执行的一系列操作,要么完全地执行,要么完全地不执行

简单的说,事务就是并发控制的单位,是用户定义的一个操作序列。 而一个逻辑工作单元要成为事务,就必须满足 ACID 属性。

  • A:原子性(Atomicity):事务中的操作要么都不做,要么就全做
  • C:一致性(Consistency):事务执行的结果必须是从数据库从一个一致性状态转换到另一个一致性状态
  • I:隔离性(Isolation):一个事务的执行不能被其他事务干扰
  • D:持久性(Durability):一个事务一旦提交,它对数据库中数据的改变就应该是永久性的

默认情况下,Fur 框架为每一次请求都开启了分布式事务,保证了每一次请求都是一个完整的 工作单元。当然,我们也可以手动管理事务。

9.25.2 工作单元

简单来说,就是为了保证一次完整的功能操作所产生的一些列提交数据的完整性,起着事务的作用。在计算机领域中,工作单元通常用 UnitOfWork 名称表示。

通常我们保证用户的每一次请求都是处于在一个功能单元中,也就是工作单元。

默认情况下,在 Fur 框架中,工作单元无需我们手动维护,框架会自动保证了每一次请求都是一个 工作单元,要么同时成功,要么同时失败。

9.25.3 如何使用

9.25.3.1 自动管理

Fur 框架中,工作单元无需我们手动维护,框架会自动保证了每一次请求都是一个 工作单元,要么同时成功,要么同时失败。所以无需操作。

9.25.3.2 手动管理

// 开启事务
using (var transaction = _testRepository.Database.BeginTransaction())
{
try
{
_testRepository.Insert(new Blog { Url = "http://blogs.msdn.com/dotnet" });
_testRepository.SaveChanges();
_testRepository.Insert(new Blog { Url = "http://blogs.msdn.com/visualstudio" });
_testRepository.SaveChanges();
var blogs = _testRepository.Entity
.OrderBy(b => b.Url)
.ToList();
-
// 提交事务
transaction.Commit();
}
catch (Exception)
{
// 回滚事务
transaction.RollBack();
}
}

9.25.4 工作单元特性说明

9.25.4.1 [UnitOfWork]

[UnitOfWork] 特性用来标记事务信息,如作用范围,隔离级别等。

  • Enabled:是否启动工作单元,默认 true
  • ScopeOption:定义事务范围行为,默认 TransactionScopeOption.Required
  • IsolationLevel:设置事务隔离级别,默认 IsolationLevel.ReadCommitted;
  • AsyncFlowOption:允许跨线程连续任务的事务流,如有异步操作需开启该选项,默认开启
特别注意

一旦方法贴了 [UnitOfWork(false)] 特性后,那么该方法不再启用工作单元模式,也就是不包含事务,也不会自动提交数据库。慎用!

9.25.4.2 [NonTransact]

一但方法或类贴了 [NonTransact] 特性,那么将关闭事务操作,但是还是会自动保存数据库到数据。

9.25.5 常见错误

  • A TransactionScope must be disposed on the same thread that it was created.

只需要在当前操作方法上贴 [NonTransact] 特性即可。

9.25.6 反馈与建议

与我们交流

给 Fur 提 Issue


了解更多

想了解更多 事务 知识可查阅 EF Core - 使用事务 章节。

- - - - - - - - - - - +
// 提交事务
transaction.Commit();
}
catch (Exception)
{
// 回滚事务
transaction.RollBack();
}
}

9.25.4 工作单元特性说明

9.25.4.1 [UnitOfWork]

[UnitOfWork] 特性用来标记事务信息,如作用范围,隔离级别等。

  • Enabled:是否启动工作单元,默认 true
  • ScopeOption:定义事务范围行为,默认 TransactionScopeOption.Required
  • IsolationLevel:设置事务隔离级别,默认 IsolationLevel.ReadCommitted;
  • AsyncFlowOption:允许跨线程连续任务的事务流,如有异步操作需开启该选项,默认开启
特别注意

一旦方法贴了 [UnitOfWork(false)] 特性后,那么该方法不再启用工作单元模式,也就是不包含事务,也不会自动提交数据库。慎用!

9.25.4.2 [NonTransact]

一但方法或类贴了 [NonTransact] 特性,那么将关闭事务操作,但是还是会自动保存数据库到数据。

9.25.5 常见错误

  • A TransactionScope must be disposed on the same thread that it was created.

只需要在当前操作方法上贴 [NonTransact] 特性即可。

9.25.6 反馈与建议

与我们交流

给 Fur 提 Issue


了解更多

想了解更多 事务 知识可查阅 EF Core - 使用事务 章节。

+ + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/unittest/index.html b/handbook/build/docs/unittest/index.html index 2e7c2e0b3d2..715765cbf4d 100644 --- a/handbook/build/docs/unittest/index.html +++ b/handbook/build/docs/unittest/index.html @@ -4,32 +4,32 @@ -27.1 单元测试 | Fur - - - - - - - - - - - +27.1 单元测试 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/docs/view-engine/index.html b/handbook/build/docs/view-engine/index.html index 8f4c0367eda..e76d160843c 100644 --- a/handbook/build/docs/view-engine/index.html +++ b/handbook/build/docs/view-engine/index.html @@ -4,32 +4,32 @@ -17. 视图引擎 | Fur - - - - - - - - - - - +17. 视图引擎 | Fur + + + + + + + + + + +
-
- - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/handbook/build/e0678751.7aa41554.js b/handbook/build/e0678751.7aa41554.js new file mode 100644 index 00000000000..a905af317bf --- /dev/null +++ b/handbook/build/e0678751.7aa41554.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[73],{127:function(e,n,t){"use strict";t.r(n),t.d(n,"frontMatter",(function(){return o})),t.d(n,"metadata",(function(){return p})),t.d(n,"rightToc",(function(){return s})),t.d(n,"default",(function(){return m}));var i=t(2),a=t(6),r=(t(0),t(142)),c=t(144),l=t(149),b=t(150),o={id:"specification-document",title:"6. \u89c4\u8303\u5316\u63a5\u53e3\u6587\u6863",sidebar_label:"6. \u89c4\u8303\u5316\u63a5\u53e3\u6587\u6863"},p={unversionedId:"specification-document",id:"specification-document",isDocsHomePage:!1,title:"6. \u89c4\u8303\u5316\u63a5\u53e3\u6587\u6863",description:"6.1 \u4ec0\u4e48\u662f\u63a5\u53e3\u6587\u6863",source:"@site/docs\\specification-document.mdx",slug:"/specification-document",permalink:"/fur/docs/specification-document",editUrl:"https://gitee.com/monksoul/Fur/tree/main/handbook/docs/specification-document.mdx",version:"current",sidebar_label:"6. \u89c4\u8303\u5316\u63a5\u53e3\u6587\u6863",sidebar:"docs",previous:{title:"5. \u52a8\u6001 WebAPI",permalink:"/fur/docs/dynamic-api-controller"},next:{title:"7. \u53cb\u597d\u5f02\u5e38\u5904\u7406",permalink:"/fur/docs/friendly-exception"}},s=[{value:"6.1 \u4ec0\u4e48\u662f\u63a5\u53e3\u6587\u6863",id:"61-\u4ec0\u4e48\u662f\u63a5\u53e3\u6587\u6863",children:[]},{value:"6.2 \u4e3a\u4ec0\u4e48\u8981\u5199\u63a5\u53e3\u6587\u6863",id:"62-\u4e3a\u4ec0\u4e48\u8981\u5199\u63a5\u53e3\u6587\u6863",children:[]},{value:"6.3 \u4e3a\u4ec0\u4e48\u9700\u8981\u89c4\u8303\u5316\u6587\u6863",id:"63-\u4e3a\u4ec0\u4e48\u9700\u8981\u89c4\u8303\u5316\u6587\u6863",children:[{value:"6.3.1 \u534f\u8bae\u89c4\u8303",id:"631-\u534f\u8bae\u89c4\u8303",children:[]},{value:"6.3.2 \u63a5\u53e3\u8def\u5f84\u89c4\u8303",id:"632-\u63a5\u53e3\u8def\u5f84\u89c4\u8303",children:[]},{value:"6.3.3 \u7248\u672c\u63a7\u5236\u89c4\u8303",id:"633-\u7248\u672c\u63a7\u5236\u89c4\u8303",children:[]},{value:"6.3.4 \u63a5\u53e3\u547d\u540d\u89c4\u8303",id:"634-\u63a5\u53e3\u547d\u540d\u89c4\u8303",children:[]},{value:"6.3.5 \u8bf7\u6c42\u53c2\u6570\u89c4\u8303",id:"635-\u8bf7\u6c42\u53c2\u6570\u89c4\u8303",children:[]},{value:"6.3.6 \u8fd4\u56de\u6570\u636e\u89c4\u8303",id:"636-\u8fd4\u56de\u6570\u636e\u89c4\u8303",children:[]}]},{value:"6.4 \u4ec0\u4e48\u662f Swagger",id:"64-\u4ec0\u4e48\u662f-swagger",children:[]},{value:"6.5 Swagger \u4f7f\u7528",id:"65-swagger-\u4f7f\u7528",children:[{value:"6.5.1 \u6ce8\u518c\u670d\u52a1",id:"651-\u6ce8\u518c\u670d\u52a1",children:[]},{value:"6.5.2 \u9ed8\u8ba4\u5730\u5740",id:"652-\u9ed8\u8ba4\u5730\u5740",children:[]},{value:"6.5.3 \u9ed8\u8ba4\u5206\u7ec4",id:"653-\u9ed8\u8ba4\u5206\u7ec4",children:[]},{value:"6.5.4 \u6587\u6863\u6ce8\u91ca",id:"654-\u6587\u6863\u6ce8\u91ca",children:[]},{value:"6.5.5 \u591a\u5206\u7ec4\u652f\u6301",id:"655-\u591a\u5206\u7ec4\u652f\u6301",children:[]},{value:"6.5.6 \u591a\u5206\u7ec4\u6392\u5e8f",id:"656-\u591a\u5206\u7ec4\u6392\u5e8f",children:[]},{value:"6.5.7 \u591a\u5206\u7ec4\u4fe1\u606f\u914d\u7f6e",id:"657-\u591a\u5206\u7ec4\u4fe1\u606f\u914d\u7f6e",children:[]},{value:"6.5.8 \u7ec4\u4e2d\u7ec4\uff08\u6807\u7b7e\uff09",id:"658-\u7ec4\u4e2d\u7ec4\uff08\u6807\u7b7e\uff09",children:[]},{value:"6.5.9 \u9ed8\u8ba4\u5c55\u5f00\u6240\u6709\u6587\u6863",id:"659-\u9ed8\u8ba4\u5c55\u5f00\u6240\u6709\u6587\u6863",children:[]},{value:"6.5.10 \u914d\u7f6e\u6587\u6863\u6807\u9898",id:"6510-\u914d\u7f6e\u6587\u6863\u6807\u9898",children:[]},{value:"6.5.11 \u6388\u6743\u63a7\u5236",id:"6511-\u6388\u6743\u63a7\u5236",children:[]},{value:"6.5.12 \u5728\u7ebf\u6d4b\u8bd5",id:"6512-\u5728\u7ebf\u6d4b\u8bd5",children:[]},{value:"6.5.13 \u6027\u80fd\u76d1\u89c6 MiniProfiler",id:"6513-\u6027\u80fd\u76d1\u89c6-miniprofiler",children:[]},{value:"6.5.14 \u5b9a\u4e49\u63a5\u53e3\u8f93\u51fa\u7c7b\u578b",id:"6514-\u5b9a\u4e49\u63a5\u53e3\u8f93\u51fa\u7c7b\u578b",children:[]}]},{value:"6.6 SpecificationDocumentSettings \u914d\u7f6e",id:"66-specificationdocumentsettings-\u914d\u7f6e",children:[]},{value:"6.7 \u7edf\u4e00\u8fd4\u56de\u503c\u6a21\u578b",id:"67-\u7edf\u4e00\u8fd4\u56de\u503c\u6a21\u578b",children:[]},{value:"6.8 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"68-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],u={rightToc:s};function m(e){var n=e.components,t=Object(a.a)(e,["components"]);return Object(r.b)("wrapper",Object(i.a)({},u,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"61-\u4ec0\u4e48\u662f\u63a5\u53e3\u6587\u6863"},"6.1 \u4ec0\u4e48\u662f\u63a5\u53e3\u6587\u6863"),Object(r.b)("p",null,"\u5728\u73b0\u5728\u79fb\u52a8\u4e3a\u738b\u3001\u591a\u7aef\u4e92\u8f85\u3001\u524d\u7aef\u767e\u82b1\u9f50\u653e\u7684\u5f00\u653e\u65f6\u4ee3\uff0c\u4e0d\u518d\u662f\u4e00\u4eba\u5305\u63fd\u5f0f\u5f00\u53d1\uff0c\u5927\u5bb6\u5404\u53f8\u5176\u804c\uff0c\u540e\u7aef\u5de5\u7a0b\u5e08\u8d1f\u8d23\u63a5\u53e3\u5f00\u53d1\uff0c\u524d\u7aef\u8d1f\u8d23\u63a5\u53e3\u8054\u8c03\uff0c\u4e5f\u5c31\u662f\u4e92\u8054\u7f51\u73b0\u5728\u6d41\u884c\u7684\u524d\u540e\u7aef\u5206\u79bb\u67b6\u6784\u3002"),Object(r.b)("p",null,"\u6240\u4ee5\u5c31\u9700\u8981\u7531\u524d\u540e\u7aef\u5de5\u7a0b\u5e08\u5171\u540c\u5b9a\u4e49\u63a5\u53e3\uff0c\u7f16\u5199\u63a5\u53e3\u6587\u6863\uff0c\u4e4b\u540e\u5927\u5bb6\u6309\u7167\u8fd9\u4e2a\u63a5\u53e3\u6587\u6863\u8fdb\u884c\u5f00\u53d1\u3001\u7ef4\u62a4\u53ca\u5f00\u653e\u7ed9\u7b2c\u4e09\u65b9\u3002"),Object(r.b)("h2",{id:"62-\u4e3a\u4ec0\u4e48\u8981\u5199\u63a5\u53e3\u6587\u6863"},"6.2 \u4e3a\u4ec0\u4e48\u8981\u5199\u63a5\u53e3\u6587\u6863"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u80fd\u591f\u8ba9\u524d\u7aef\u5f00\u53d1\u4e0e\u540e\u53f0\u5f00\u53d1\u4eba\u5458\u66f4\u597d\u7684\u914d\u5408\uff0c\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387"),Object(r.b)("li",{parentName:"ul"},"\u9879\u76ee\u8fed\u4ee3\u6216\u8005\u9879\u76ee\u4eba\u5458\u66f4\u8fed\u65f6\uff0c\u65b9\u4fbf\u540e\u671f\u4eba\u5458\u67e5\u770b\u548c\u7ef4\u62a4"),Object(r.b)("li",{parentName:"ul"},"\u65b9\u4fbf\u6d4b\u8bd5\u4eba\u5458\u8fdb\u884c\u63a5\u53e3\u6d4b\u8bd5")),Object(r.b)("h2",{id:"63-\u4e3a\u4ec0\u4e48\u9700\u8981\u89c4\u8303\u5316\u6587\u6863"},"6.3 \u4e3a\u4ec0\u4e48\u9700\u8981\u89c4\u8303\u5316\u6587\u6863"),Object(r.b)("p",null,"\u7531\u4e8e\u6bcf\u4e2a\u516c\u53f8\u540e\u7aef\u4eba\u5458\u6280\u672f\u53c2\u5dee\u4e0d\u9f50\uff0c\u6280\u672f\u6587\u6863\u80fd\u529b\u4e5f\u4e0d\u4f8b\u5916\uff0c\u5bfc\u81f4\u63a5\u53e3\u5b9a\u4e49\u53ca\u6587\u6863\u4e94\u82b1\u516b\u95e8\uff0c\u4e0d\u540c\u9879\u76ee\u6216\u4e0d\u540c\u516c\u53f8\u5bf9\u63a5\u6781\u5176\u56f0\u96be\uff0c\u800c\u4e14\u4f53\u9a8c\u7cdf\u7cd5\u3002\u6240\u4ee5\uff0c\u65e0\u89c4\u77e9\u4e0d\u6210\u65b9\u5706\uff0c\u4e3a\u4e86\u5f00\u53d1\u4eba\u5458\u95f4\u66f4\u597d\u7684\u914d\u5408\uff0c\u8feb\u5207\u9700\u8981\u6574\u7406\u51fa\u4e00\u5957\u89c4\u8303\u3002"),Object(r.b)("p",null,"\u901a\u5e38\u63a5\u53e3\u89c4\u8303\u5206\u4e3a\u516d\u4e2a\u90e8\u5206\uff1a"),Object(r.b)("h3",{id:"631-\u534f\u8bae\u89c4\u8303"},"6.3.1 \u534f\u8bae\u89c4\u8303"),Object(r.b)("p",null,"\u4e3a\u4e86\u786e\u4fdd\u4e0d\u540c\u7cfb\u7edf/\u6a21\u5757\u95f4\u7684\u6570\u636e\u4ea4\u4e92\uff0c\u9700\u8981\u4e8b\u5148\u7ea6\u5b9a\u597d\u901a\u8baf\u534f\u8bae\uff0c\u5982\uff1aTCP\u3001HTTP\u3001HTTPS \u534f\u8bae\u3002\u4e3a\u4e86\u786e\u4fdd\u6570\u636e\u4ea4\u4e92\u5b89\u5168\uff0c\u5efa\u8bae\u4f7f\u7528 HTTPS \u534f\u8bae"),Object(r.b)("h3",{id:"632-\u63a5\u53e3\u8def\u5f84\u89c4\u8303"},"6.3.2 \u63a5\u53e3\u8def\u5f84\u89c4\u8303"),Object(r.b)("p",null,"\u4f5c\u4e3a\u63a5\u53e3\u8def\u5f84\uff0c\u4e3a\u4e86\u65b9\u4fbf\u6e05\u6670\u7684\u533a\u5206\u6765\u81ea\u4e0d\u540c\u7684\u7cfb\u7edf\uff0c\u53ef\u4ee5\u91c7\u7528\u4e0d\u540c\u7cfb\u7edf/\u6a21\u5757\u540d\u4f5c\u4e3a\u63a5\u53e3\u8def\u5f84\u524d\u7f00\uff0c\u5982\uff1a\u652f\u4ed8\u6a21\u5757\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"/pay/xxx"),"\uff0c\u8ba2\u5355\u6a21\u5757\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"/order/xxx")),Object(r.b)("h3",{id:"633-\u7248\u672c\u63a7\u5236\u89c4\u8303"},"6.3.3 \u7248\u672c\u63a7\u5236\u89c4\u8303"),Object(r.b)("p",null,'\u4e3a\u4e86\u4fbf\u4e8e\u540e\u671f\u63a5\u53e3\u7684\u5347\u7ea7\u548c\u7ef4\u62a4\uff0c\u5efa\u8bae\u5728\u63a5\u53e3\u8def\u5f84\u4e2d\u52a0\u5165\u7248\u672c\u53f7\uff0c\u4fbf\u4e8e\u7ba1\u7406\uff0c\u5b9e\u73b0\u63a5\u53e3\u591a\u7248\u672c\u7684\u53ef\u7ef4\u62a4\u6027\u3002\u5982\uff1a\u63a5\u53e3\u8def\u5f84\u4e2d\u6dfb\u52a0\u7c7b\u4f3c"',Object(r.b)("inlineCode",{parentName:"p"},"v1"),'"\u3001"',Object(r.b)("inlineCode",{parentName:"p"},"v2"),'"\u7b49\u7248\u672c\u53f7'),Object(r.b)("h3",{id:"634-\u63a5\u53e3\u547d\u540d\u89c4\u8303"},"6.3.4 \u63a5\u53e3\u547d\u540d\u89c4\u8303"),Object(r.b)("p",null,'\u548c C# \u547d\u540d\u89c4\u8303\u4e00\u6837\uff0c\u597d\u7684\u3001\u7edf\u4e00\u7684\u63a5\u53e3\u547d\u540d\u89c4\u8303\uff0c\u4e0d\u4ec5\u53ef\u4ee5\u589e\u5f3a\u5176\u53ef\u8bfb\u6027\uff0c\u800c\u4e14\u8fd8\u4f1a\u51cf\u5c11\u5f88\u591a\u4e0d\u5fc5\u8981\u7684\u53e3\u5934/\u4e66\u9762\u4e0a\u7684\u89e3\u91ca\u3002\uff0c\u53ef\u4f7f\u7528"\u9a7c\u5cf0\u547d\u540d\u6cd5"\u6309\u7167\u5b9e\u73b0\u63a5\u53e3\u7684',Object(r.b)("strong",{parentName:"p"},"\u4e1a\u52a1\u7c7b\u578b\u3001\u4e1a\u52a1\u573a\u666f"),"\u7b49\u547d\u540d\uff0c\u6709\u5fc5\u8981\u65f6\u53ef\u91c7\u53d6\u591a\u7ea7\u76ee\u5f55\u547d\u540d\uff0c\u4f46\u76ee\u5f55\u4e0d\u5b9c\u8fc7\u957f\uff0c\u4e24\u7ea7\u76ee\u5f55\u8f83\u4e3a\u9002\u5b9c"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u5e38\u89c1\u547d\u540d\u65b9\u5f0f"),":",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u63a5\u53e3\u540d\u79f0\u52a8\u8bcd\u524d/\u540e\u7f00\u5316"),"\uff1a \u63a5\u53e3\u540d\u79f0\u4ee5\u63a5\u53e3\u6570\u636e\u64cd\u4f5c\u7684\u52a8\u8bcd\u4e3a\u524d/\u540e\u7f00\uff0c\u5e38\u89c1\u52a8\u8bcd\u6709\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Add\u3001Delete\u3001Update\u3001Query\u3001Get\u3001Send\u3001Save\u3001Detail\u3001List"),"\u7b49\uff0c\u5982\uff1a\u65b0\u5efa\u7528\u6237 ",Object(r.b)("inlineCode",{parentName:"li"},"AddUser"),"\u3001\u67e5\u8be2\u8ba2\u5355\u8be6\u60c5 ",Object(r.b)("inlineCode",{parentName:"li"},"QueryOrderDetail"),"\u3002"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u63a5\u53e3\u540d\u79f0\u52a8\u8bcd + \u8bf7\u6c42\u65b9\u5f0f"),"\uff1a\u63a5\u53e3\u8def\u5f84\u4e2d\u5305\u542b\u5177\u4f53\u63a5\u53e3\u540d\u79f0\u7684\u540d\u8bcd\uff0c\u63a5\u53e3\u6570\u636e\u64cd\u4f5c\u52a8\u4f5c\u4ee5 HTTP \u8bf7\u6c42\u65b9\u5f0f\u6765\u533a\u5206\u3002\u5e38\u7528\u7684 HTTP \u8bf7\u6c42\u65b9\u5f0f\u6709\uff1a",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"GET"),"\uff1a\u4ece\u670d\u52a1\u5668\u53d6\u51fa\u8d44\u6e90\uff08\u4e00\u9879\u6216\u591a\u9879\uff09"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"POST"),"\uff1a\u5728\u670d\u52a1\u5668\u65b0\u5efa\u4e00\u4e2a\u8d44\u6e90"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"PUT"),"\uff1a\u5728\u670d\u52a1\u5668\u66f4\u65b0\u8d44\u6e90\uff08\u5ba2\u6237\u7aef\u63d0\u4f9b\u6539\u53d8\u540e\u7684\u5b8c\u6574\u8d44\u6e90\uff09"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"PATCH"),"\uff1a\u5728\u670d\u52a1\u5668\u66f4\u65b0\u8d44\u6e90\uff08\u5ba2\u6237\u7aef\u63d0\u4f9b\u6539\u53d8\u7684\u5c5e\u6027\uff09"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DELETE"),"\uff1a\u4ece\u670d\u52a1\u5668\u5220\u9664\u8d44\u6e90")))))),Object(r.b)("h3",{id:"635-\u8bf7\u6c42\u53c2\u6570\u89c4\u8303"},"6.3.5 \u8bf7\u6c42\u53c2\u6570\u89c4\u8303"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u8bf7\u6c42\u65b9\u5f0f"),"\uff1a\u6309\u7167 ",Object(r.b)("inlineCode",{parentName:"li"},"GET\u3001POST\u3001PUT")," \u7b49\u542b\u4e49\u5b9a\u4e49\uff0c\u907f\u514d\u51fa\u73b0\u4e0d\u4e00\u81f4\u73b0\u8c61\uff0c\u5bf9\u4eba\u9020\u6210\u8bef\u89e3\u3001\u6b67\u4e49",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u8bf7\u6c42\u5934"),"\uff1a\u8bf7\u6c42\u5934\u6839\u636e\u9879\u76ee\u9700\u6c42\u6dfb\u52a0\u914d\u7f6e\u53c2\u6570\u3002\u5982\uff1a\u8bf7\u6c42\u6570\u636e\u683c\u5f0f\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"accept=application/json")," \u7b49\u3002\u5982\u6709\u9700\u8981\uff0c\u8bf7\u6c42\u5934\u53ef\u6839\u636e\u9879\u76ee\u9700\u6c42\u8981\u6c42\u4f20\u5165\u7528\u6237 token\u3001\u552f\u4e00\u9a8c\u7b7e\u7801\u7b49\u52a0\u5bc6\u6570\u636e"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u8bf7\u6c42\u53c2\u6570/\u8bf7\u6c42\u4f53"),"\uff1a \u8bf7\u6c42\u53c2\u6570\u5b57\u6bb5\uff0c\u5c3d\u53ef\u80fd\u4e0e\u6570\u636e\u5e93\u8868\u5b57\u6bb5\u3001\u5bf9\u8c61\u5c5e\u6027\u540d\u7b49\u4fdd\u6301\u4e00\u81f4\uff0c\u56e0\u4e3a\u4fdd\u6301\u4e00\u81f4\u6700\u7701\u4e8b\uff0c\u6700\u8212\u670d\u7684\u4e00\u4ef6\u4e8b")))),Object(r.b)("h3",{id:"636-\u8fd4\u56de\u6570\u636e\u89c4\u8303"},"6.3.6 \u8fd4\u56de\u6570\u636e\u89c4\u8303"),Object(r.b)("p",null,"\u7edf\u4e00\u89c4\u8303\u8fd4\u56de\u6570\u636e\u7684\u683c\u5f0f\uff0c\u5bf9\u5df1\u5bf9\u5f7c\u90fd\u6709\u597d\u5904\uff0c\u6b64\u5904\u4ee5 json \u683c\u5f0f\u4e3a\u4f8b\u3002\u8fd4\u56de\u6570\u636e\u5e94\u5305\u542b\uff1a",Object(r.b)("strong",{parentName:"p"},"\u8fd4\u56de\u72b6\u6001\u7801\u3001\u8fd4\u56de\u72b6\u6001\u4fe1\u606f\u3001\u5177\u4f53\u6570\u636e"),"\u3002",Object(r.b)("strong",{parentName:"p"},"\u8fd4\u56de\u6570\u636e\u4e2d\u7684\u72b6\u6001\u7801\u3001\u72b6\u6001\u4fe1\u606f\uff0c\u5e38\u6307\u5177\u4f53\u7684\u4e1a\u52a1\u72b6\u6001\uff0c\u4e0d\u5efa\u8bae\u548c HTTP \u72b6\u6001\u7801\u6df7\u5728\u4e00\u8d77"),"\u3002HTTP \u72b6\u6001\uff0c\u662f\u7528\u6765\u4f53\u73b0 HTTP \u94fe\u8def\u72b6\u6001\u60c5\u51b5\uff0c\u5982\uff1a404-Not Found\u3002HTTP \u72b6\u6001\u7801\u548c json \u7ed3\u679c\u4e2d\u7684\u72b6\u6001\u7801\uff0c\u5e76\u5b58\u5c1a\u53ef\uff0c\u7528\u4e8e\u4f53\u73b0\u4e0d\u540c\u7ef4\u5ea6\u7684\u72b6\u6001\u3002"),Object(r.b)("h2",{id:"64-\u4ec0\u4e48\u662f-swagger"},"6.4 \u4ec0\u4e48\u662f Swagger"),Object(r.b)("p",null,"\u76f8\u4fe1\u65e0\u8bba\u662f\u524d\u7aef\u8fd8\u662f\u540e\u7aef\u5f00\u53d1\uff0c\u90fd\u6216\u591a\u6216\u5c11\u5730\u88ab\u63a5\u53e3\u6587\u6863\u6298\u78e8\u8fc7\u3002\u524d\u7aef\u7ecf\u5e38\u62b1\u6028\u540e\u7aef\u7ed9\u7684\u63a5\u53e3\u6587\u6863\u4e0e\u5b9e\u9645\u60c5\u51b5\u4e0d\u4e00\u81f4\u3002\u540e\u7aef\u53c8\u89c9\u5f97\u7f16\u5199\u53ca\u7ef4\u62a4\u63a5\u53e3\u6587\u6863\u4f1a\u8017\u8d39\u4e0d\u5c11\u7cbe\u529b\uff0c\u7ecf\u5e38\u6765\u4e0d\u53ca\u66f4\u65b0\u3002"),Object(r.b)("p",null,"\u5176\u5b9e\u65e0\u8bba\u662f\u524d\u7aef\u8c03\u7528\u540e\u7aef\uff0c\u8fd8\u662f\u540e\u7aef\u8c03\u7528\u540e\u7aef\uff0c\u90fd\u671f\u671b\u6709\u4e00\u4e2a\u597d\u7684\u63a5\u53e3\u6587\u6863\u3002\u4f46\u662f\u8fd9\u4e2a\u63a5\u53e3\u6587\u6863\u5bf9\u4e8e\u7a0b\u5e8f\u5458\u6765\u8bf4\uff0c\u5c31\u8ddf\u6ce8\u91ca\u4e00\u6837\uff0c\u7ecf\u5e38\u4f1a\u62b1\u6028\u522b\u4eba\u5199\u7684\u4ee3\u7801\u6ca1\u6709\u5199\u6ce8\u91ca\uff0c\u7136\u800c\u81ea\u5df1\u5199\u8d77\u4ee3\u7801\u8d77\u6765\uff0c\u6700\u8ba8\u538c\u7684\uff0c\u4e5f\u662f\u5199\u6ce8\u91ca\u3002\u6240\u4ee5\u4ec5\u4ec5\u53ea\u901a\u8fc7\u5f3a\u5236\u6765\u89c4\u8303\u5927\u5bb6\u662f\u4e0d\u591f\u7684\uff0c\u968f\u7740\u65f6\u95f4\u63a8\u79fb\uff0c\u7248\u672c\u8fed\u4ee3\uff0c\u63a5\u53e3\u6587\u6863\u5f80\u5f80\u5f88\u5bb9\u6613\u5c31\u8ddf\u4e0d\u4e0a\u4ee3\u7801\u4e86\u3002"),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"\u53d1\u73b0\u4e86\u75db\u70b9\u5c31\u8981\u53bb\u627e\u89e3\u51b3\u65b9\u6848\u3002\u89e3\u51b3\u65b9\u6848\u7528\u7684\u4eba\u591a\u4e86\uff0c\u5c31\u6210\u4e86\u6807\u51c6\u7684\u89c4\u8303\uff0c\u8fd9\u5c31\u662f ",Object(r.b)("inlineCode",{parentName:"strong"},"Swagger")," \u7684\u7531\u6765"),"\u3002"),Object(r.b)("p",null,"\u901a\u8fc7\u8fd9\u5957\u89c4\u8303\uff0c\u4f60\u53ea\u9700\u8981\u6309\u7167\u5b83\u7684\u89c4\u8303\u53bb\u5b9a\u4e49\u63a5\u53e3\u53ca\u63a5\u53e3\u76f8\u5173\u7684\u4fe1\u606f\u3002\u518d\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u884d\u751f\u51fa\u6765\u7684\u4e00\u7cfb\u5217\u9879\u76ee\u548c\u5de5\u5177\uff0c\u5c31\u53ef\u4ee5\u505a\u5230\u751f\u6210\u5404\u79cd\u683c\u5f0f\u7684\u63a5\u53e3\u6587\u6863\uff0c\u751f\u6210\u591a\u79cd\u8bed\u8a00\u7684\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u7684\u4ee3\u7801\uff0c\u4ee5\u53ca\u5728\u7ebf\u63a5\u53e3\u8c03\u8bd5\u9875\u9762\u7b49\u7b49\u3002"),Object(r.b)("p",null,"\u8fd9\u6837\uff0c\u5982\u679c\u6309\u7167\u65b0\u7684\u5f00\u53d1\u6a21\u5f0f\uff0c\u5728\u5f00\u53d1\u65b0\u7248\u672c\u6216\u8005\u8fed\u4ee3\u7248\u672c\u7684\u65f6\u5019\uff0c\u53ea\u9700\u8981\u66f4\u65b0 ",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u63cf\u8ff0\u6587\u4ef6\uff0c\u5c31\u53ef\u4ee5\u81ea\u52a8\u751f\u6210\u63a5\u53e3\u6587\u6863\u548c\u5ba2\u6237\u7aef\u670d\u52a1\u7aef\u4ee3\u7801\uff0c\u505a\u5230\u8c03\u7528\u7aef\u4ee3\u7801\u3001\u670d\u52a1\u7aef\u4ee3\u7801\u4ee5\u53ca\u63a5\u53e3\u6587\u6863\u7684\u4e00\u81f4\u6027\u3002"),Object(r.b)("p",null,"\u6240\u4ee5\uff0cSwagger \u662f\u4e00\u4e2a\u89c4\u8303\u548c\u5b8c\u6574\u7684\u6846\u67b6\uff0c\u7528\u4e8e\u751f\u6210\u3001\u63cf\u8ff0\u3001\u8c03\u7528\u548c\u53ef\u89c6\u5316",Object(r.b)("inlineCode",{parentName:"p"},"RESTful")," \u98ce\u683c\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"Web")," \u670d\u52a1\u3002"),Object(r.b)("p",null,"\u603b\u4f53\u76ee\u6807\u662f\u4f7f\u5ba2\u6237\u7aef\u548c\u6587\u4ef6\u7cfb\u7edf\u4f5c\u4e3a\u670d\u52a1\u5668\u4ee5\u540c\u6837\u7684\u901f\u5ea6\u6765\u66f4\u65b0\u3002\u6587\u4ef6\u7684\u65b9\u6cd5\u3001\u53c2\u6570\u548c\u6a21\u578b\u7d27\u5bc6\u96c6\u6210\u5230\u670d\u52a1\u5668\u7aef\u7684\u4ee3\u7801\uff0c\u5141\u8bb8 API \u6765\u59cb\u7ec8\u4fdd\u6301\u540c\u6b65\u3002",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u8ba9\u90e8\u7f72\u7ba1\u7406\u548c\u4f7f\u7528\u529f\u80fd\u5f3a\u5927\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"API")," \u4ece\u672a\u5982\u6b64\u7b80\u5355\u3002"),Object(r.b)("h2",{id:"65-swagger-\u4f7f\u7528"},"6.5 Swagger \u4f7f\u7528"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u65b9\u4fbf\u4e14\u7075\u6d3b\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u914d\u7f6e\uff0c\u65e0\u9700\u589e\u52a0\u989d\u5916\u5b66\u4e60\u6210\u672c\u3002"),Object(r.b)("h3",{id:"651-\u6ce8\u518c\u670d\u52a1"},"6.5.1 \u6ce8\u518c\u670d\u52a1"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:'{11,21} title="Fur.Web.Core\\FurWebCoreStartup.cs"',"{11,21}":!0,title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddSpecificationDocuments();\n services.AddControllers();\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n // Other Codes\n\n app.UseSpecificationDocuments();\n\n app.UseEndpoints(endpoints =>\n {\n endpoints.MapControllers();\n });\n }\n }\n}\n")),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"services.AddSpecificationDocuments()")," \u901a\u5e38\u548c ",Object(r.b)("inlineCode",{parentName:"p"},".AddDynamicApiControllers()")," \u6210\u5bf9\u51fa\u73b0\u3002"))),Object(r.b)("h3",{id:"652-\u9ed8\u8ba4\u5730\u5740"},"6.5.2 \u9ed8\u8ba4\u5730\u5740"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"p"},"\u89c4\u8303\u5316\u6587\u6863")," \u5730\u5740\u4e3a\u4e3b\u673a\u6839\u76ee\u5f55\uff0c",Object(r.b)("strong",{parentName:"p"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e"),"\u3002"),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger1.png")}),Object(r.b)("h3",{id:"653-\u9ed8\u8ba4\u5206\u7ec4"},"6.5.3 \u9ed8\u8ba4\u5206\u7ec4"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u9ed8\u8ba4\u5206\u7ec4\u540d\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"Default"),"\uff0c",Object(r.b)("strong",{parentName:"p"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e"),"\u3002"),Object(r.b)("h3",{id:"654-\u6587\u6863\u6ce8\u91ca"},"6.5.4 \u6587\u6863\u6ce8\u91ca"),Object(r.b)("p",null,"\u89c4\u8303\u5316\u6587\u6863\u9ed8\u8ba4\u626b\u63cf ",Object(r.b)("inlineCode",{parentName:"p"},"Fur.Application"),"\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur.Web.Core"),"\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur.Web.Entry")," \u4e09\u4e2a\u7a0b\u5e8f\u96c6",Object(r.b)("inlineCode",{parentName:"p"},".xml")," \u6ce8\u91ca\u6587\u4ef6\uff0c",Object(r.b)("strong",{parentName:"p"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e"),"\u3002"),Object(r.b)("p",null,"\u53ea\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"p"},"///")," \u6807\u8bc6\u7684\u6ce8\u91ca\u8bed\u6cd5\uff0c\u5982\uff1a",Object(r.b)("strong",{parentName:"p"},"\u7c7b\u3001\u65b9\u6cd5\u3001\u5c5e\u6027\u3001\u53c2\u6570\u3001\u8fd4\u56de\u503c\u3001\u9a8c\u8bc1\u7279\u6027"),"\u3002"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{5-7,10-13,19-23}","{5-7,10-13,19-23}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n /// \n /// \u7c7b\u6ce8\u91ca\n /// \n public class FurAppService : IDynamicApiController\n {\n /// \n /// \u65b9\u6cd5\u6ce8\u91ca\n /// \n /// \n public string Get()\n {\n return nameof(Fur);\n }\n\n /// \n /// \u5e26 ID \u53c2\u6570\u7684\u65b9\u6cd5\u6ce8\u91ca\n /// \n /// \n /// \n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger2.png")}),Object(r.b)("h3",{id:"655-\u591a\u5206\u7ec4\u652f\u6301"},"6.5.5 \u591a\u5206\u7ec4\u652f\u6301"),Object(r.b)("p",null,"\u591a\u5206\u7ec4\u662f\u4e00\u4e2a\u7cfb\u7edf\u4e2d\u5fc5\u5907\u529f\u80fd\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u7cfb\u7edf\u5212\u5206\u4e3a\u591a\u4e2a\u6a21\u5757\uff0c\u6bcf\u4e2a\u6a21\u5757\u90fd\u72ec\u7acb\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"api")," \u914d\u7f6e\u3002\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u5b9e\u73b0\u591a\u5206\u7ec4\u975e\u5e38\u7b80\u5355\u3002\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,21,32}","{5,21,32}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings("Group1")]\n public class FurAppService : IDynamicApiController\n {\n /// \n /// \u968f\u7236\u7c7b Group1 \u5206\u7ec4\n /// \n /// \n public string Post()\n {\n return nameof(Fur);\n }\n\n /// \n /// \u5728 Group1\u3001Group3 \u90fd\u6709\u6211\n /// \n /// \n [ApiDescriptionSettings("Group1", "Group3")]\n public string Get()\n {\n return nameof(Fur);\n }\n\n /// \n /// \u6211\u53ea\u5728 Group2 \u51fa\u73b0\n /// \n /// \n /// \n [ApiDescriptionSettings("Group2")]\n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger3.gif")}),Object(r.b)("h3",{id:"656-\u591a\u5206\u7ec4\u6392\u5e8f"},"6.5.6 \u591a\u5206\u7ec4\u6392\u5e8f"),Object(r.b)(l.a,{defaultValue:"fz1",values:[{label:"\u65b9\u5f0f\u4e00",value:"fz1"},{label:"\u65b9\u5f0f\u4e8c",value:"fz2"}],mdxType:"Tabs"},Object(r.b)(b.a,{value:"fz1",mdxType:"TabItem"},Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"\u901a\u8fc7\u5206\u7ec4\u540d\u79f0\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"strong"},"@\u6574\u6570")," \u8fdb\u884c\u6392\u5e8f")),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,19}","{5,19}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings("Group1@1")]\n public class FurAppService : IDynamicApiController\n {\n public string Post()\n {\n return nameof(Fur);\n }\n\n [ApiDescriptionSettings("Group1", "Group3")]\n public string Get()\n {\n return nameof(Fur);\n }\n\n [ApiDescriptionSettings("Group@2")]\n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u53ef\u4ee5\u901a\u8fc7\u5728\u5206\u7ec4\u540d\u540e\u9762\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"p"},"@\u6574\u6570")," \u8fdb\u884c\u6392\u5e8f\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"\u6574\u6570")," \u8d8a\u5927\u6392\u524d\u9762\u3002\u5982\u679c\u5206\u7ec4\u540d\u79f0\u591a\u6b21\u6307\u5b9a\u4e14\u591a\u6b21\u6307\u5b9a\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"@\u6574\u6570")," \uff0c\u5219\u81ea\u52a8",Object(r.b)("strong",{parentName:"p"},"\u53d6\u8be5\u5206\u7ec4\u6700\u5927\u7684\u6574\u6570"),"\u8fdb\u884c\u6392\u5e8f\u3002")),Object(r.b)(b.a,{value:"fz2",mdxType:"TabItem"},Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u914d\u7f6e\u6392\u5e8f")),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-json",metastring:'{2,3,4-17} title="Fur.Web.Entry/appsettings.json"',"{2,3,4-17}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "SpecificationDocumentSettings": {\n "GroupOpenApiInfos": [\n {\n "Group": "Group1",\n "Order": 1\n },\n {\n "Group": "Group2",\n "Order": 2\n },\n {\n "Group": "Group3",\n "Order": 0\n }\n ]\n }\n }\n}\n')))),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger5.png")}),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u6392\u5e8f\u8bf4\u660e")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5206\u7ec4\u9ed8\u8ba4\u6392\u5e8f ",Object(r.b)("inlineCode",{parentName:"p"},"Order")," \u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"0"),"\u3002\u5982\u679c\u540c\u65f6\u914d\u7f6e\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"@\u6574\u6570")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u914d\u7f6e\u6587\u4ef6\uff0c\u90a3\u4e48\u4f18\u5148\u91c7\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u4e2d\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"Order")))),Object(r.b)("h3",{id:"657-\u591a\u5206\u7ec4\u4fe1\u606f\u914d\u7f6e"},"6.5.7 \u591a\u5206\u7ec4\u4fe1\u606f\u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u53ef\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"appsetting.json")," \u914d\u7f6e\u5206\u7ec4\u4fe1\u606f\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-json",metastring:'{3,4-20} title="Fur.Web.Entry/appsettings.json"',"{3,4-20}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "SpecificationDocumentSettings": {\n "GroupOpenApiInfos": [\n {\n "Group": "Group1",\n "Title": "\u5206\u7ec4\u6807\u9898",\n "Description": "\u8fd9\u91cc\u662f\u5206\u7ec4\u63cf\u8ff0",\n "Version": "\u7248\u672c\u53f7",\n "TermsOfService": "https://chinadot.net",\n "Contact": {\n "Name": "\u767e\u5c0f\u50e7",\n "Url": "https://gitee.com/monksoul",\n "Email": "monksoul@outlook.com"\n },\n "License": {\n "Name": "Apache-2.0",\n "Url": "https://gitee.com/monksoul/Fur/blob/alpha/LICENSE"\n }\n }\n ]\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger5.png")}),Object(r.b)("h3",{id:"658-\u7ec4\u4e2d\u7ec4\uff08\u6807\u7b7e\uff09"},"6.5.8 \u7ec4\u4e2d\u7ec4\uff08\u6807\u7b7e\uff09"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Tag")," \u914d\u7f6e\u4e3b\u8981\u7528\u4e8e\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u6807\u7b7e\u5206\u7ec4\u4fe1\u606f\u53ca\u5408\u5e76\u6807\u7b7e\u3002\u4e5f\u5c31\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"\u7ec4\u4e2d\u7ec4"),":"),Object(r.b)(l.a,{defaultValue:"tag1",values:[{label:"\u6807\u7b7e\u547d\u540d",value:"tag1"},{label:"\u5408\u5e76\u6807\u7b7e",value:"tag2"}],mdxType:"Tabs"},Object(r.b)(b.a,{value:"tag1",mdxType:"TabItem"},Object(r.b)("h4",{id:"\u672a\u8d34\u6807\u7b7e\u4e4b\u524d"},"\u672a\u8d34\u6807\u7b7e\u4e4b\u524d"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs"}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n\n public class TestAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n}\n")),Object(r.b)("h4",{id:"\u8d34\u6807\u7b7e\u4e4b\u540e"},"\u8d34\u6807\u7b7e\u4e4b\u540e"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,19}","{5,19}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(Tag = "\u5206\u7ec4\u4e00")]\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n\n [ApiDescriptionSettings(Tag = "\u5206\u7ec4\u4e8c")]\n public class TestAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/tag1.png")})),Object(r.b)(b.a,{value:"tag2",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,19}","{5,19}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(Tag = "\u5408\u5e76\u6240\u6709\u6807\u7b7e")]\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n\n [ApiDescriptionSettings(Tag = "\u5408\u5e76\u6240\u6709\u6807\u7b7e")]\n public class TestAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/tag2.png")}))),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5982\u679c ",Object(r.b)("inlineCode",{parentName:"p"},"Tag")," \u540d\u5b57\u4e00\u6837\uff0c\u5219\u4f1a\u81ea\u52a8\u5408\u5e76\uff0c\u5426\u5219\u53ea\u662f\u547d\u540d\u3002"))),Object(r.b)("h3",{id:"659-\u9ed8\u8ba4\u5c55\u5f00\u6240\u6709\u6587\u6863"},"6.5.9 \u9ed8\u8ba4\u5c55\u5f00\u6240\u6709\u6587\u6863"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-json",metastring:'{2-5} title="Fur.Web.Entry/appsettings.json"',"{2-5}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "SpecificationDocumentSettings": {\n "DocExpansionState": "Full"\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger6.gif")}),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"DocExpansionState")," \u914d\u7f6e\u8bf4\u660e\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"List"),"\uff1a\u5217\u8868\u5f0f\uff08\u5c55\u5f00\u5b50\u7c7b\uff09\uff0c",Object(r.b)("strong",{parentName:"li"},"\u9ed8\u8ba4\u503c")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Full"),"\uff1a\u5b8c\u5168\u5c55\u5f00"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"None"),"\uff1a\u5217\u8868\u5f0f\uff08\u4e0d\u5c55\u5f00\u5b50\u7c7b\uff09")),Object(r.b)("h3",{id:"6510-\u914d\u7f6e\u6587\u6863\u6807\u9898"},"6.5.10 \u914d\u7f6e\u6587\u6863\u6807\u9898"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-json",metastring:'{2-5} title="Fur.Web.Entry/appsettings.json"',"{2-5}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "SpecificationDocumentSettings": {\n "DocumentTitle": "\u6211\u662f\u81ea\u5b9a\u4e49\u6807\u9898"\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger7.png")}),Object(r.b)("h3",{id:"6511-\u6388\u6743\u63a7\u5236"},"6.5.11 \u6388\u6743\u63a7\u5236"),Object(r.b)("p",null,"\u5f85\u6574\u7406..."),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-json",metastring:'title="Fur.Web.Entry/appsettings.json"',title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "SpecificationDocumentSettings": {\n "EnableAuthorized": true,\n\n "SecurityDefinitions": [\n {\n "Id": "Bearer",\n "Type": "Http",\n "Name": "Authorization",\n "Description": "JWT Authorization header using the Bearer scheme.",\n "BearerFormat": "JWT",\n "Scheme": "bearer",\n "In": "Header",\n\n "Requirement": {\n "Scheme": {\n "Reference": {\n "Id": "Bearer",\n "Type": "SecurityScheme"\n },\n "Accesses": null\n }\n }\n }\n ]\n }\n }\n}\n')),Object(r.b)("h3",{id:"6512-\u5728\u7ebf\u6d4b\u8bd5"},"6.5.12 \u5728\u7ebf\u6d4b\u8bd5"),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger8.gif")}),Object(r.b)("h3",{id:"6513-\u6027\u80fd\u76d1\u89c6-miniprofiler"},"6.5.13 \u6027\u80fd\u76d1\u89c6 ",Object(r.b)("inlineCode",{parentName:"h3"},"MiniProfiler")),Object(r.b)("p",null,"\u89c4\u8303\u5316\u6587\u6863\u9ed8\u8ba4\u96c6\u6210\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"MiniProfiler")," \u7b2c\u4e09\u65b9\u6027\u80fd\u7ec4\u4ef6\uff0c\u901a\u8fc7\u8be5\u7ec4\u4ef6\u53ef\u4ee5\u65b9\u4fbf\u67e5\u770b\u8bf7\u6c42\u6027\u80fd\u3001\u5f02\u5e38\u5806\u6808\u3001\u6570\u636e\u5e93\u64cd\u4f5c\u7b49\u4fe1\u606f\u3002\u9ed8\u8ba4\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u9996\u9875\u5de6\u4e0a\u89d2\u663e\u793a\u3002"),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/mipr.png")}),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5c0f\u63d0\u793a")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u4e5f\u53ef\u4ee5\u901a\u8fc7 ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"appsetting.json"))," \u4e2d ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"AppSettings:InjectMiniProfiler"))," \u8bbe\u4e3a ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"false"))," \u5173\u95ed\u3002"))),Object(r.b)("h3",{id:"6514-\u5b9a\u4e49\u63a5\u53e3\u8f93\u51fa\u7c7b\u578b"},"6.5.14 \u5b9a\u4e49\u63a5\u53e3\u8f93\u51fa\u7c7b\u578b"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,8-9}","{2,8-9}":!0}),"using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [ProducesResponseType(201, Type = typeof(TestDto))]\n [ProducesResponseType(400)]\n public string Get()\n {\n return nameof(Fur);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/fhzlx.png")}),Object(r.b)("h2",{id:"66-specificationdocumentsettings-\u914d\u7f6e"},"6.6 ",Object(r.b)("inlineCode",{parentName:"h2"},"SpecificationDocumentSettings")," \u914d\u7f6e"),Object(r.b)("p",null,"\u9664\u4e86\u4e0a\u8ff0\u4f8b\u5b50\u5916\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u4e86\u4e00\u4e9b\u914d\u7f6e\u9009\u9879\uff0c\u5982\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DocumentTitle"),"\uff1a\u6587\u6863\u6807\u9898\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"Specification Api Document")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DefaultGroupName"),"\uff1a\u9ed8\u8ba4\u5206\u7ec4\u540d\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"Default")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"EnableAuthorized"),"\uff1a\u662f\u5426\u542f\u7528\u6743\u9650\u63a7\u5236\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"true")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"FormatAsV2"),"\uff1a\u91c7\u7528 ",Object(r.b)("inlineCode",{parentName:"li"},"Swagger 2.0")," \u7248\u672c\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"false")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"RoutePrefix"),"\uff1a\u89c4\u8303\u5316\u6587\u6863\u5730\u5740\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"string")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DocExpansionState"),"\uff1a\u6587\u6863\u663e\u793a\u65b9\u5f0f\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"DocExpansion"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"List"),"\uff0c\u53d6\u503c\uff1a",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"List"),"\uff1a\u5217\u8868\u5f0f\uff08\u5c55\u5f00\u5b50\u7c7b\uff09\uff0c",Object(r.b)("strong",{parentName:"li"},"\u9ed8\u8ba4\u503c")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Full"),"\uff1a\u5b8c\u5168\u5c55\u5f00"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"None"),"\uff1a\u5217\u8868\u5f0f\uff08\u4e0d\u5c55\u5f00\u5b50\u7c7b\uff09"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"XmlComments"),"\uff1a\u7a0b\u5e8f\u96c6\u6ce8\u91ca\u63cf\u8ff0\u6587\u4ef6\u540d\uff08\u53ef\u5e26 ",Object(r.b)("inlineCode",{parentName:"li"},".xml"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"Fur.Application, Fur.Web.Entry, Fur.Web.Core")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"GroupOpenApiInfos"),"\uff1a\u5206\u7ec4\u4fe1\u606f\u914d\u7f6e\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"SpecificationOpenApiInfo[]"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"{ 'Group': 'Default'}")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"SecurityDefinitions"),"\uff1a\u5b89\u5168\u7b56\u7565\u5b9a\u4e49\u914d\u7f6e\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"SpecificationOpenApiSecurityScheme[]"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"[]"))),Object(r.b)("h2",{id:"67-\u7edf\u4e00\u8fd4\u56de\u503c\u6a21\u578b"},"6.7 \u7edf\u4e00\u8fd4\u56de\u503c\u6a21\u578b"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b ",Object(r.b)("inlineCode",{parentName:"p"},"\u89c4\u8303\u5316\u7ed3\u679c")," \u529f\u80fd\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"p"},"IUnifyResultProvider")," \u63d0\u4f9b\u5668\u5b9e\u73b0\u7edf\u4e00\u89c4\u8303\u5316\u8fd4\u56de\u503c\u5b9a\u5236\uff0c\u5982\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"RESTfulResultProvider"),"\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs"}),'using Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.AspNetCore.Mvc.Filters;\nusing Microsoft.AspNetCore.Mvc.ModelBinding;\nusing System.Collections.Generic;\n\nnamespace Fur.UnifyResult\n{\n /// \n /// RESTful \u98ce\u683c\u8fd4\u56de\u503c\n /// \n public class RESTfulResultProvider : IUnifyResultProvider\n {\n /// \n /// \u5f02\u5e38\u8fd4\u56de\u503c\n /// \n /// \n /// \n public IActionResult OnException(ExceptionContext context)\n {\n return new JsonResult(new RESTfulResult\n {\n StatusCode = StatusCodes.Status500InternalServerError,\n Successed = false,\n Data = null,\n Errors = context.Exception.Message\n });\n }\n\n /// \n /// \u6210\u529f\u8fd4\u56de\u503c\n /// \n /// \n /// \n public IActionResult OnSuccessed(ActionExecutedContext context)\n {\n object data;\n // \u5904\u7406\u5185\u5bb9\u7ed3\u679c\n if (context.Result is ContentResult contentResult) data = contentResult.Content;\n // \u5904\u7406\u5bf9\u8c61\u7ed3\u679c\n else if (context.Result is ObjectResult objectResult) data = objectResult.Value;\n else return null;\n\n return new JsonResult(new RESTfulResult\n {\n StatusCode = context.Result is EmptyResult ? StatusCodes.Status204NoContent : StatusCodes.Status200OK,\n Successed = true,\n Data = data,\n Errors = null\n });\n }\n\n /// \n /// \u9a8c\u8bc1\u5931\u8d25\u8fd4\u56de\u503c\n /// \n /// \n /// \n /// \n /// \n /// \n public IActionResult OnValidateFailed(ActionExecutingContext context, ModelStateDictionary modelStates, Dictionary> validationResults, string validateFaildMessage)\n {\n return new JsonResult(new RESTfulResult\n {\n StatusCode = StatusCodes.Status400BadRequest,\n Successed = false,\n Data = null,\n Errors = validationResults\n });\n }\n }\n}\n')),Object(r.b)("p",null,"\u4e4b\u540e\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Startup.cs")," \u4e2d\u6ce8\u518c\u5373\u53ef\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs"}),"services.AddControllers().AddUnifyResult();\n")),Object(r.b)("h2",{id:"68-\u53cd\u9988\u4e0e\u5efa\u8bae"},"6.8 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(i.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}m.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return s})),t.d(n,"b",(function(){return d}));var i=t(0),a=t.n(i);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function l(e){for(var n=1;n=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}var o=a.a.createContext({}),p=function(e){var n=a.a.useContext(o),t=n;return e&&(t="function"==typeof e?e(n):l(l({},n),e)),t},s=function(e){var n=p(e.components);return a.a.createElement(o.Provider,{value:n},e.children)},u={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},m=a.a.forwardRef((function(e,n){var t=e.components,i=e.mdxType,r=e.originalType,c=e.parentName,o=b(e,["components","mdxType","originalType","parentName"]),s=p(t),m=i,d=s["".concat(c,".").concat(m)]||s[m]||u[m]||r;return t?a.a.createElement(d,l(l({ref:n},o),{},{components:t})):a.a.createElement(d,l({ref:n},o))}));function d(e,n){var t=arguments,i=n&&n.mdxType;if("string"==typeof e||i){var r=t.length,c=new Array(r);c[0]=m;var l={};for(var b in n)hasOwnProperty.call(n,b)&&(l[b]=n[b]);l.originalType=e,l.mdxType="string"==typeof e?e:i,c[1]=l;for(var o=2;oMiniProfiler",id:"6513-\u6027\u80fd\u76d1\u89c6-miniprofiler",children:[]},{value:"6.5.14 \u5b9a\u4e49\u63a5\u53e3\u8f93\u51fa\u7c7b\u578b",id:"6514-\u5b9a\u4e49\u63a5\u53e3\u8f93\u51fa\u7c7b\u578b",children:[]}]},{value:"6.6 SpecificationDocumentSettings \u914d\u7f6e",id:"66-specificationdocumentsettings-\u914d\u7f6e",children:[]},{value:"6.7 \u7edf\u4e00\u8fd4\u56de\u503c\u6a21\u578b",id:"67-\u7edf\u4e00\u8fd4\u56de\u503c\u6a21\u578b",children:[]},{value:"6.8 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"68-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],u={rightToc:s};function m(e){var n=e.components,t=Object(a.a)(e,["components"]);return Object(r.b)("wrapper",Object(i.a)({},u,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"61-\u4ec0\u4e48\u662f\u63a5\u53e3\u6587\u6863"},"6.1 \u4ec0\u4e48\u662f\u63a5\u53e3\u6587\u6863"),Object(r.b)("p",null,"\u5728\u73b0\u5728\u79fb\u52a8\u4e3a\u738b\u3001\u591a\u7aef\u4e92\u8f85\u3001\u524d\u7aef\u767e\u82b1\u9f50\u653e\u7684\u5f00\u653e\u65f6\u4ee3\uff0c\u4e0d\u518d\u662f\u4e00\u4eba\u5305\u63fd\u5f0f\u5f00\u53d1\uff0c\u5927\u5bb6\u5404\u53f8\u5176\u804c\uff0c\u540e\u7aef\u5de5\u7a0b\u5e08\u8d1f\u8d23\u63a5\u53e3\u5f00\u53d1\uff0c\u524d\u7aef\u8d1f\u8d23\u63a5\u53e3\u8054\u8c03\uff0c\u4e5f\u5c31\u662f\u4e92\u8054\u7f51\u73b0\u5728\u6d41\u884c\u7684\u524d\u540e\u7aef\u5206\u79bb\u67b6\u6784\u3002"),Object(r.b)("p",null,"\u6240\u4ee5\u5c31\u9700\u8981\u7531\u524d\u540e\u7aef\u5de5\u7a0b\u5e08\u5171\u540c\u5b9a\u4e49\u63a5\u53e3\uff0c\u7f16\u5199\u63a5\u53e3\u6587\u6863\uff0c\u4e4b\u540e\u5927\u5bb6\u6309\u7167\u8fd9\u4e2a\u63a5\u53e3\u6587\u6863\u8fdb\u884c\u5f00\u53d1\u3001\u7ef4\u62a4\u53ca\u5f00\u653e\u7ed9\u7b2c\u4e09\u65b9\u3002"),Object(r.b)("h2",{id:"62-\u4e3a\u4ec0\u4e48\u8981\u5199\u63a5\u53e3\u6587\u6863"},"6.2 \u4e3a\u4ec0\u4e48\u8981\u5199\u63a5\u53e3\u6587\u6863"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u80fd\u591f\u8ba9\u524d\u7aef\u5f00\u53d1\u4e0e\u540e\u53f0\u5f00\u53d1\u4eba\u5458\u66f4\u597d\u7684\u914d\u5408\uff0c\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387"),Object(r.b)("li",{parentName:"ul"},"\u9879\u76ee\u8fed\u4ee3\u6216\u8005\u9879\u76ee\u4eba\u5458\u66f4\u8fed\u65f6\uff0c\u65b9\u4fbf\u540e\u671f\u4eba\u5458\u67e5\u770b\u548c\u7ef4\u62a4"),Object(r.b)("li",{parentName:"ul"},"\u65b9\u4fbf\u6d4b\u8bd5\u4eba\u5458\u8fdb\u884c\u63a5\u53e3\u6d4b\u8bd5")),Object(r.b)("h2",{id:"63-\u4e3a\u4ec0\u4e48\u9700\u8981\u89c4\u8303\u5316\u6587\u6863"},"6.3 \u4e3a\u4ec0\u4e48\u9700\u8981\u89c4\u8303\u5316\u6587\u6863"),Object(r.b)("p",null,"\u7531\u4e8e\u6bcf\u4e2a\u516c\u53f8\u540e\u7aef\u4eba\u5458\u6280\u672f\u53c2\u5dee\u4e0d\u9f50\uff0c\u6280\u672f\u6587\u6863\u80fd\u529b\u4e5f\u4e0d\u4f8b\u5916\uff0c\u5bfc\u81f4\u63a5\u53e3\u5b9a\u4e49\u53ca\u6587\u6863\u4e94\u82b1\u516b\u95e8\uff0c\u4e0d\u540c\u9879\u76ee\u6216\u4e0d\u540c\u516c\u53f8\u5bf9\u63a5\u6781\u5176\u56f0\u96be\uff0c\u800c\u4e14\u4f53\u9a8c\u7cdf\u7cd5\u3002\u6240\u4ee5\uff0c\u65e0\u89c4\u77e9\u4e0d\u6210\u65b9\u5706\uff0c\u4e3a\u4e86\u5f00\u53d1\u4eba\u5458\u95f4\u66f4\u597d\u7684\u914d\u5408\uff0c\u8feb\u5207\u9700\u8981\u6574\u7406\u51fa\u4e00\u5957\u89c4\u8303\u3002"),Object(r.b)("p",null,"\u901a\u5e38\u63a5\u53e3\u89c4\u8303\u5206\u4e3a\u516d\u4e2a\u90e8\u5206\uff1a"),Object(r.b)("h3",{id:"631-\u534f\u8bae\u89c4\u8303"},"6.3.1 \u534f\u8bae\u89c4\u8303"),Object(r.b)("p",null,"\u4e3a\u4e86\u786e\u4fdd\u4e0d\u540c\u7cfb\u7edf/\u6a21\u5757\u95f4\u7684\u6570\u636e\u4ea4\u4e92\uff0c\u9700\u8981\u4e8b\u5148\u7ea6\u5b9a\u597d\u901a\u8baf\u534f\u8bae\uff0c\u5982\uff1aTCP\u3001HTTP\u3001HTTPS \u534f\u8bae\u3002\u4e3a\u4e86\u786e\u4fdd\u6570\u636e\u4ea4\u4e92\u5b89\u5168\uff0c\u5efa\u8bae\u4f7f\u7528 HTTPS \u534f\u8bae"),Object(r.b)("h3",{id:"632-\u63a5\u53e3\u8def\u5f84\u89c4\u8303"},"6.3.2 \u63a5\u53e3\u8def\u5f84\u89c4\u8303"),Object(r.b)("p",null,"\u4f5c\u4e3a\u63a5\u53e3\u8def\u5f84\uff0c\u4e3a\u4e86\u65b9\u4fbf\u6e05\u6670\u7684\u533a\u5206\u6765\u81ea\u4e0d\u540c\u7684\u7cfb\u7edf\uff0c\u53ef\u4ee5\u91c7\u7528\u4e0d\u540c\u7cfb\u7edf/\u6a21\u5757\u540d\u4f5c\u4e3a\u63a5\u53e3\u8def\u5f84\u524d\u7f00\uff0c\u5982\uff1a\u652f\u4ed8\u6a21\u5757\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"/pay/xxx"),"\uff0c\u8ba2\u5355\u6a21\u5757\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"/order/xxx")),Object(r.b)("h3",{id:"633-\u7248\u672c\u63a7\u5236\u89c4\u8303"},"6.3.3 \u7248\u672c\u63a7\u5236\u89c4\u8303"),Object(r.b)("p",null,'\u4e3a\u4e86\u4fbf\u4e8e\u540e\u671f\u63a5\u53e3\u7684\u5347\u7ea7\u548c\u7ef4\u62a4\uff0c\u5efa\u8bae\u5728\u63a5\u53e3\u8def\u5f84\u4e2d\u52a0\u5165\u7248\u672c\u53f7\uff0c\u4fbf\u4e8e\u7ba1\u7406\uff0c\u5b9e\u73b0\u63a5\u53e3\u591a\u7248\u672c\u7684\u53ef\u7ef4\u62a4\u6027\u3002\u5982\uff1a\u63a5\u53e3\u8def\u5f84\u4e2d\u6dfb\u52a0\u7c7b\u4f3c"',Object(r.b)("inlineCode",{parentName:"p"},"v1"),'"\u3001"',Object(r.b)("inlineCode",{parentName:"p"},"v2"),'"\u7b49\u7248\u672c\u53f7'),Object(r.b)("h3",{id:"634-\u63a5\u53e3\u547d\u540d\u89c4\u8303"},"6.3.4 \u63a5\u53e3\u547d\u540d\u89c4\u8303"),Object(r.b)("p",null,'\u548c C# \u547d\u540d\u89c4\u8303\u4e00\u6837\uff0c\u597d\u7684\u3001\u7edf\u4e00\u7684\u63a5\u53e3\u547d\u540d\u89c4\u8303\uff0c\u4e0d\u4ec5\u53ef\u4ee5\u589e\u5f3a\u5176\u53ef\u8bfb\u6027\uff0c\u800c\u4e14\u8fd8\u4f1a\u51cf\u5c11\u5f88\u591a\u4e0d\u5fc5\u8981\u7684\u53e3\u5934/\u4e66\u9762\u4e0a\u7684\u89e3\u91ca\u3002\uff0c\u53ef\u4f7f\u7528"\u9a7c\u5cf0\u547d\u540d\u6cd5"\u6309\u7167\u5b9e\u73b0\u63a5\u53e3\u7684',Object(r.b)("strong",{parentName:"p"},"\u4e1a\u52a1\u7c7b\u578b\u3001\u4e1a\u52a1\u573a\u666f"),"\u7b49\u547d\u540d\uff0c\u6709\u5fc5\u8981\u65f6\u53ef\u91c7\u53d6\u591a\u7ea7\u76ee\u5f55\u547d\u540d\uff0c\u4f46\u76ee\u5f55\u4e0d\u5b9c\u8fc7\u957f\uff0c\u4e24\u7ea7\u76ee\u5f55\u8f83\u4e3a\u9002\u5b9c"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u5e38\u89c1\u547d\u540d\u65b9\u5f0f"),":",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u63a5\u53e3\u540d\u79f0\u52a8\u8bcd\u524d/\u540e\u7f00\u5316"),"\uff1a \u63a5\u53e3\u540d\u79f0\u4ee5\u63a5\u53e3\u6570\u636e\u64cd\u4f5c\u7684\u52a8\u8bcd\u4e3a\u524d/\u540e\u7f00\uff0c\u5e38\u89c1\u52a8\u8bcd\u6709\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"Add\u3001Delete\u3001Update\u3001Query\u3001Get\u3001Send\u3001Save\u3001Detail\u3001List"),"\u7b49\uff0c\u5982\uff1a\u65b0\u5efa\u7528\u6237 ",Object(r.b)("inlineCode",{parentName:"li"},"AddUser"),"\u3001\u67e5\u8be2\u8ba2\u5355\u8be6\u60c5 ",Object(r.b)("inlineCode",{parentName:"li"},"QueryOrderDetail"),"\u3002"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u63a5\u53e3\u540d\u79f0\u52a8\u8bcd + \u8bf7\u6c42\u65b9\u5f0f"),"\uff1a\u63a5\u53e3\u8def\u5f84\u4e2d\u5305\u542b\u5177\u4f53\u63a5\u53e3\u540d\u79f0\u7684\u540d\u8bcd\uff0c\u63a5\u53e3\u6570\u636e\u64cd\u4f5c\u52a8\u4f5c\u4ee5 HTTP \u8bf7\u6c42\u65b9\u5f0f\u6765\u533a\u5206\u3002\u5e38\u7528\u7684 HTTP \u8bf7\u6c42\u65b9\u5f0f\u6709\uff1a",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"GET"),"\uff1a\u4ece\u670d\u52a1\u5668\u53d6\u51fa\u8d44\u6e90\uff08\u4e00\u9879\u6216\u591a\u9879\uff09"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"POST"),"\uff1a\u5728\u670d\u52a1\u5668\u65b0\u5efa\u4e00\u4e2a\u8d44\u6e90"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"PUT"),"\uff1a\u5728\u670d\u52a1\u5668\u66f4\u65b0\u8d44\u6e90\uff08\u5ba2\u6237\u7aef\u63d0\u4f9b\u6539\u53d8\u540e\u7684\u5b8c\u6574\u8d44\u6e90\uff09"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"PATCH"),"\uff1a\u5728\u670d\u52a1\u5668\u66f4\u65b0\u8d44\u6e90\uff08\u5ba2\u6237\u7aef\u63d0\u4f9b\u6539\u53d8\u7684\u5c5e\u6027\uff09"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DELETE"),"\uff1a\u4ece\u670d\u52a1\u5668\u5220\u9664\u8d44\u6e90")))))),Object(r.b)("h3",{id:"635-\u8bf7\u6c42\u53c2\u6570\u89c4\u8303"},"6.3.5 \u8bf7\u6c42\u53c2\u6570\u89c4\u8303"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u8bf7\u6c42\u65b9\u5f0f"),"\uff1a\u6309\u7167 ",Object(r.b)("inlineCode",{parentName:"li"},"GET\u3001POST\u3001PUT")," \u7b49\u542b\u4e49\u5b9a\u4e49\uff0c\u907f\u514d\u51fa\u73b0\u4e0d\u4e00\u81f4\u73b0\u8c61\uff0c\u5bf9\u4eba\u9020\u6210\u8bef\u89e3\u3001\u6b67\u4e49",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u8bf7\u6c42\u5934"),"\uff1a\u8bf7\u6c42\u5934\u6839\u636e\u9879\u76ee\u9700\u6c42\u6dfb\u52a0\u914d\u7f6e\u53c2\u6570\u3002\u5982\uff1a\u8bf7\u6c42\u6570\u636e\u683c\u5f0f\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"accept=application/json")," \u7b49\u3002\u5982\u6709\u9700\u8981\uff0c\u8bf7\u6c42\u5934\u53ef\u6839\u636e\u9879\u76ee\u9700\u6c42\u8981\u6c42\u4f20\u5165\u7528\u6237 token\u3001\u552f\u4e00\u9a8c\u7b7e\u7801\u7b49\u52a0\u5bc6\u6570\u636e"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"\u8bf7\u6c42\u53c2\u6570/\u8bf7\u6c42\u4f53"),"\uff1a \u8bf7\u6c42\u53c2\u6570\u5b57\u6bb5\uff0c\u5c3d\u53ef\u80fd\u4e0e\u6570\u636e\u5e93\u8868\u5b57\u6bb5\u3001\u5bf9\u8c61\u5c5e\u6027\u540d\u7b49\u4fdd\u6301\u4e00\u81f4\uff0c\u56e0\u4e3a\u4fdd\u6301\u4e00\u81f4\u6700\u7701\u4e8b\uff0c\u6700\u8212\u670d\u7684\u4e00\u4ef6\u4e8b")))),Object(r.b)("h3",{id:"636-\u8fd4\u56de\u6570\u636e\u89c4\u8303"},"6.3.6 \u8fd4\u56de\u6570\u636e\u89c4\u8303"),Object(r.b)("p",null,"\u7edf\u4e00\u89c4\u8303\u8fd4\u56de\u6570\u636e\u7684\u683c\u5f0f\uff0c\u5bf9\u5df1\u5bf9\u5f7c\u90fd\u6709\u597d\u5904\uff0c\u6b64\u5904\u4ee5 json \u683c\u5f0f\u4e3a\u4f8b\u3002\u8fd4\u56de\u6570\u636e\u5e94\u5305\u542b\uff1a",Object(r.b)("strong",{parentName:"p"},"\u8fd4\u56de\u72b6\u6001\u7801\u3001\u8fd4\u56de\u72b6\u6001\u4fe1\u606f\u3001\u5177\u4f53\u6570\u636e"),"\u3002",Object(r.b)("strong",{parentName:"p"},"\u8fd4\u56de\u6570\u636e\u4e2d\u7684\u72b6\u6001\u7801\u3001\u72b6\u6001\u4fe1\u606f\uff0c\u5e38\u6307\u5177\u4f53\u7684\u4e1a\u52a1\u72b6\u6001\uff0c\u4e0d\u5efa\u8bae\u548c HTTP \u72b6\u6001\u7801\u6df7\u5728\u4e00\u8d77"),"\u3002HTTP \u72b6\u6001\uff0c\u662f\u7528\u6765\u4f53\u73b0 HTTP \u94fe\u8def\u72b6\u6001\u60c5\u51b5\uff0c\u5982\uff1a404-Not Found\u3002HTTP \u72b6\u6001\u7801\u548c json \u7ed3\u679c\u4e2d\u7684\u72b6\u6001\u7801\uff0c\u5e76\u5b58\u5c1a\u53ef\uff0c\u7528\u4e8e\u4f53\u73b0\u4e0d\u540c\u7ef4\u5ea6\u7684\u72b6\u6001\u3002"),Object(r.b)("h2",{id:"64-\u4ec0\u4e48\u662f-swagger"},"6.4 \u4ec0\u4e48\u662f Swagger"),Object(r.b)("p",null,"\u76f8\u4fe1\u65e0\u8bba\u662f\u524d\u7aef\u8fd8\u662f\u540e\u7aef\u5f00\u53d1\uff0c\u90fd\u6216\u591a\u6216\u5c11\u5730\u88ab\u63a5\u53e3\u6587\u6863\u6298\u78e8\u8fc7\u3002\u524d\u7aef\u7ecf\u5e38\u62b1\u6028\u540e\u7aef\u7ed9\u7684\u63a5\u53e3\u6587\u6863\u4e0e\u5b9e\u9645\u60c5\u51b5\u4e0d\u4e00\u81f4\u3002\u540e\u7aef\u53c8\u89c9\u5f97\u7f16\u5199\u53ca\u7ef4\u62a4\u63a5\u53e3\u6587\u6863\u4f1a\u8017\u8d39\u4e0d\u5c11\u7cbe\u529b\uff0c\u7ecf\u5e38\u6765\u4e0d\u53ca\u66f4\u65b0\u3002"),Object(r.b)("p",null,"\u5176\u5b9e\u65e0\u8bba\u662f\u524d\u7aef\u8c03\u7528\u540e\u7aef\uff0c\u8fd8\u662f\u540e\u7aef\u8c03\u7528\u540e\u7aef\uff0c\u90fd\u671f\u671b\u6709\u4e00\u4e2a\u597d\u7684\u63a5\u53e3\u6587\u6863\u3002\u4f46\u662f\u8fd9\u4e2a\u63a5\u53e3\u6587\u6863\u5bf9\u4e8e\u7a0b\u5e8f\u5458\u6765\u8bf4\uff0c\u5c31\u8ddf\u6ce8\u91ca\u4e00\u6837\uff0c\u7ecf\u5e38\u4f1a\u62b1\u6028\u522b\u4eba\u5199\u7684\u4ee3\u7801\u6ca1\u6709\u5199\u6ce8\u91ca\uff0c\u7136\u800c\u81ea\u5df1\u5199\u8d77\u4ee3\u7801\u8d77\u6765\uff0c\u6700\u8ba8\u538c\u7684\uff0c\u4e5f\u662f\u5199\u6ce8\u91ca\u3002\u6240\u4ee5\u4ec5\u4ec5\u53ea\u901a\u8fc7\u5f3a\u5236\u6765\u89c4\u8303\u5927\u5bb6\u662f\u4e0d\u591f\u7684\uff0c\u968f\u7740\u65f6\u95f4\u63a8\u79fb\uff0c\u7248\u672c\u8fed\u4ee3\uff0c\u63a5\u53e3\u6587\u6863\u5f80\u5f80\u5f88\u5bb9\u6613\u5c31\u8ddf\u4e0d\u4e0a\u4ee3\u7801\u4e86\u3002"),Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"\u53d1\u73b0\u4e86\u75db\u70b9\u5c31\u8981\u53bb\u627e\u89e3\u51b3\u65b9\u6848\u3002\u89e3\u51b3\u65b9\u6848\u7528\u7684\u4eba\u591a\u4e86\uff0c\u5c31\u6210\u4e86\u6807\u51c6\u7684\u89c4\u8303\uff0c\u8fd9\u5c31\u662f ",Object(r.b)("inlineCode",{parentName:"strong"},"Swagger")," \u7684\u7531\u6765"),"\u3002"),Object(r.b)("p",null,"\u901a\u8fc7\u8fd9\u5957\u89c4\u8303\uff0c\u4f60\u53ea\u9700\u8981\u6309\u7167\u5b83\u7684\u89c4\u8303\u53bb\u5b9a\u4e49\u63a5\u53e3\u53ca\u63a5\u53e3\u76f8\u5173\u7684\u4fe1\u606f\u3002\u518d\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u884d\u751f\u51fa\u6765\u7684\u4e00\u7cfb\u5217\u9879\u76ee\u548c\u5de5\u5177\uff0c\u5c31\u53ef\u4ee5\u505a\u5230\u751f\u6210\u5404\u79cd\u683c\u5f0f\u7684\u63a5\u53e3\u6587\u6863\uff0c\u751f\u6210\u591a\u79cd\u8bed\u8a00\u7684\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u7684\u4ee3\u7801\uff0c\u4ee5\u53ca\u5728\u7ebf\u63a5\u53e3\u8c03\u8bd5\u9875\u9762\u7b49\u7b49\u3002"),Object(r.b)("p",null,"\u8fd9\u6837\uff0c\u5982\u679c\u6309\u7167\u65b0\u7684\u5f00\u53d1\u6a21\u5f0f\uff0c\u5728\u5f00\u53d1\u65b0\u7248\u672c\u6216\u8005\u8fed\u4ee3\u7248\u672c\u7684\u65f6\u5019\uff0c\u53ea\u9700\u8981\u66f4\u65b0 ",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u63cf\u8ff0\u6587\u4ef6\uff0c\u5c31\u53ef\u4ee5\u81ea\u52a8\u751f\u6210\u63a5\u53e3\u6587\u6863\u548c\u5ba2\u6237\u7aef\u670d\u52a1\u7aef\u4ee3\u7801\uff0c\u505a\u5230\u8c03\u7528\u7aef\u4ee3\u7801\u3001\u670d\u52a1\u7aef\u4ee3\u7801\u4ee5\u53ca\u63a5\u53e3\u6587\u6863\u7684\u4e00\u81f4\u6027\u3002"),Object(r.b)("p",null,"\u6240\u4ee5\uff0cSwagger \u662f\u4e00\u4e2a\u89c4\u8303\u548c\u5b8c\u6574\u7684\u6846\u67b6\uff0c\u7528\u4e8e\u751f\u6210\u3001\u63cf\u8ff0\u3001\u8c03\u7528\u548c\u53ef\u89c6\u5316",Object(r.b)("inlineCode",{parentName:"p"},"RESTful")," \u98ce\u683c\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"Web")," \u670d\u52a1\u3002"),Object(r.b)("p",null,"\u603b\u4f53\u76ee\u6807\u662f\u4f7f\u5ba2\u6237\u7aef\u548c\u6587\u4ef6\u7cfb\u7edf\u4f5c\u4e3a\u670d\u52a1\u5668\u4ee5\u540c\u6837\u7684\u901f\u5ea6\u6765\u66f4\u65b0\u3002\u6587\u4ef6\u7684\u65b9\u6cd5\u3001\u53c2\u6570\u548c\u6a21\u578b\u7d27\u5bc6\u96c6\u6210\u5230\u670d\u52a1\u5668\u7aef\u7684\u4ee3\u7801\uff0c\u5141\u8bb8 API \u6765\u59cb\u7ec8\u4fdd\u6301\u540c\u6b65\u3002",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u8ba9\u90e8\u7f72\u7ba1\u7406\u548c\u4f7f\u7528\u529f\u80fd\u5f3a\u5927\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"API")," \u4ece\u672a\u5982\u6b64\u7b80\u5355\u3002"),Object(r.b)("h2",{id:"65-swagger-\u4f7f\u7528"},"6.5 Swagger \u4f7f\u7528"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u65b9\u4fbf\u4e14\u7075\u6d3b\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u914d\u7f6e\uff0c\u65e0\u9700\u589e\u52a0\u989d\u5916\u5b66\u4e60\u6210\u672c\u3002"),Object(r.b)("h3",{id:"651-\u6ce8\u518c\u670d\u52a1"},"6.5.1 \u6ce8\u518c\u670d\u52a1"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:'{11,21} title="Fur.Web.Core\\FurWebCoreStartup.cs"',"{11,21}":!0,title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddSpecificationDocuments();\n services.AddControllers();\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n // Other Codes\n\n app.UseSpecificationDocuments();\n\n app.UseEndpoints(endpoints =>\n {\n endpoints.MapControllers();\n });\n }\n }\n}\n")),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"services.AddSpecificationDocuments()")," \u901a\u5e38\u548c ",Object(r.b)("inlineCode",{parentName:"p"},".AddDynamicApiControllers()")," \u6210\u5bf9\u51fa\u73b0\u3002"))),Object(r.b)("h3",{id:"652-\u9ed8\u8ba4\u5730\u5740"},"6.5.2 \u9ed8\u8ba4\u5730\u5740"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"p"},"\u89c4\u8303\u5316\u6587\u6863")," \u5730\u5740\u4e3a\u4e3b\u673a\u6839\u76ee\u5f55\uff0c",Object(r.b)("strong",{parentName:"p"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e"),"\u3002"),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger1.png")}),Object(r.b)("h3",{id:"653-\u9ed8\u8ba4\u5206\u7ec4"},"6.5.3 \u9ed8\u8ba4\u5206\u7ec4"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\u9ed8\u8ba4\u5206\u7ec4\u540d\u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"Default"),"\uff0c",Object(r.b)("strong",{parentName:"p"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e"),"\u3002"),Object(r.b)("h3",{id:"654-\u6587\u6863\u6ce8\u91ca"},"6.5.4 \u6587\u6863\u6ce8\u91ca"),Object(r.b)("p",null,"\u89c4\u8303\u5316\u6587\u6863\u9ed8\u8ba4\u626b\u63cf ",Object(r.b)("inlineCode",{parentName:"p"},"Fur.Application"),"\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur.Web.Core"),"\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur.Web.Entry")," \u4e09\u4e2a\u7a0b\u5e8f\u96c6",Object(r.b)("inlineCode",{parentName:"p"},".xml")," \u6ce8\u91ca\u6587\u4ef6\uff0c",Object(r.b)("strong",{parentName:"p"},"\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e"),"\u3002"),Object(r.b)("p",null,"\u53ea\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"p"},"///")," \u6807\u8bc6\u7684\u6ce8\u91ca\u8bed\u6cd5\uff0c\u5982\uff1a",Object(r.b)("strong",{parentName:"p"},"\u7c7b\u3001\u65b9\u6cd5\u3001\u5c5e\u6027\u3001\u53c2\u6570\u3001\u8fd4\u56de\u503c\u3001\u9a8c\u8bc1\u7279\u6027"),"\u3002"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{5-7,10-13,19-23}","{5-7,10-13,19-23}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n /// \n /// \u7c7b\u6ce8\u91ca\n /// \n public class FurAppService : IDynamicApiController\n {\n /// \n /// \u65b9\u6cd5\u6ce8\u91ca\n /// \n /// \n public string Get()\n {\n return nameof(Fur);\n }\n\n /// \n /// \u5e26 ID \u53c2\u6570\u7684\u65b9\u6cd5\u6ce8\u91ca\n /// \n /// \n /// \n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger2.png")}),Object(r.b)("h3",{id:"655-\u591a\u5206\u7ec4\u652f\u6301"},"6.5.5 \u591a\u5206\u7ec4\u652f\u6301"),Object(r.b)("p",null,"\u591a\u5206\u7ec4\u662f\u4e00\u4e2a\u7cfb\u7edf\u4e2d\u5fc5\u5907\u529f\u80fd\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u7cfb\u7edf\u5212\u5206\u4e3a\u591a\u4e2a\u6a21\u5757\uff0c\u6bcf\u4e2a\u6a21\u5757\u90fd\u72ec\u7acb\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"api")," \u914d\u7f6e\u3002\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u5b9e\u73b0\u591a\u5206\u7ec4\u975e\u5e38\u7b80\u5355\u3002\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,21,32}","{5,21,32}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings("Group1")]\n public class FurAppService : IDynamicApiController\n {\n /// \n /// \u968f\u7236\u7c7b Group1 \u5206\u7ec4\n /// \n /// \n public string Post()\n {\n return nameof(Fur);\n }\n\n /// \n /// \u5728 Group1\u3001Group3 \u90fd\u6709\u6211\n /// \n /// \n [ApiDescriptionSettings("Group1", "Group3")]\n public string Get()\n {\n return nameof(Fur);\n }\n\n /// \n /// \u6211\u53ea\u5728 Group2 \u51fa\u73b0\n /// \n /// \n /// \n [ApiDescriptionSettings("Group2")]\n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger3.gif")}),Object(r.b)("h3",{id:"656-\u591a\u5206\u7ec4\u6392\u5e8f"},"6.5.6 \u591a\u5206\u7ec4\u6392\u5e8f"),Object(r.b)(l.a,{defaultValue:"fz1",values:[{label:"\u65b9\u5f0f\u4e00",value:"fz1"},{label:"\u65b9\u5f0f\u4e8c",value:"fz2"}],mdxType:"Tabs"},Object(r.b)(b.a,{value:"fz1",mdxType:"TabItem"},Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"\u901a\u8fc7\u5206\u7ec4\u540d\u79f0\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"strong"},"@\u6574\u6570")," \u8fdb\u884c\u6392\u5e8f")),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,19}","{5,19}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings("Group1@1")]\n public class FurAppService : IDynamicApiController\n {\n public string Post()\n {\n return nameof(Fur);\n }\n\n [ApiDescriptionSettings("Group1", "Group3")]\n public string Get()\n {\n return nameof(Fur);\n }\n\n [ApiDescriptionSettings("Group@2")]\n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u53ef\u4ee5\u901a\u8fc7\u5728\u5206\u7ec4\u540d\u540e\u9762\u6dfb\u52a0 ",Object(r.b)("inlineCode",{parentName:"p"},"@\u6574\u6570")," \u8fdb\u884c\u6392\u5e8f\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"\u6574\u6570")," \u8d8a\u5927\u6392\u524d\u9762\u3002\u5982\u679c\u5206\u7ec4\u540d\u79f0\u591a\u6b21\u6307\u5b9a\u4e14\u591a\u6b21\u6307\u5b9a\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"@\u6574\u6570")," \uff0c\u5219\u81ea\u52a8",Object(r.b)("strong",{parentName:"p"},"\u53d6\u8be5\u5206\u7ec4\u6700\u5927\u7684\u6574\u6570"),"\u8fdb\u884c\u6392\u5e8f\u3002")),Object(r.b)(b.a,{value:"fz2",mdxType:"TabItem"},Object(r.b)("p",null,Object(r.b)("strong",{parentName:"p"},"\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u914d\u7f6e\u6392\u5e8f")),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-json",metastring:'{2,3,4-17} title="Fur.Web.Entry/appsettings.json"',"{2,3,4-17}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "SpecificationDocumentSettings": {\n "GroupOpenApiInfos": [\n {\n "Group": "Group1",\n "Order": 1\n },\n {\n "Group": "Group2",\n "Order": 2\n },\n {\n "Group": "Group3",\n "Order": 0\n }\n ]\n }\n }\n}\n')))),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger5.png")}),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u6392\u5e8f\u8bf4\u660e")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5206\u7ec4\u9ed8\u8ba4\u6392\u5e8f ",Object(r.b)("inlineCode",{parentName:"p"},"Order")," \u4e3a ",Object(r.b)("inlineCode",{parentName:"p"},"0"),"\u3002\u5982\u679c\u540c\u65f6\u914d\u7f6e\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"@\u6574\u6570")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u914d\u7f6e\u6587\u4ef6\uff0c\u90a3\u4e48\u4f18\u5148\u91c7\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u4e2d\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"Order")))),Object(r.b)("h3",{id:"657-\u591a\u5206\u7ec4\u4fe1\u606f\u914d\u7f6e"},"6.5.7 \u591a\u5206\u7ec4\u4fe1\u606f\u914d\u7f6e"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u53ef\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},"appsetting.json")," \u914d\u7f6e\u5206\u7ec4\u4fe1\u606f\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-json",metastring:'{3,4-20} title="Fur.Web.Entry/appsettings.json"',"{3,4-20}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "SpecificationDocumentSettings": {\n "GroupOpenApiInfos": [\n {\n "Group": "Group1",\n "Title": "\u5206\u7ec4\u6807\u9898",\n "Description": "\u8fd9\u91cc\u662f\u5206\u7ec4\u63cf\u8ff0",\n "Version": "\u7248\u672c\u53f7",\n "TermsOfService": "https://chinadot.net",\n "Contact": {\n "Name": "\u767e\u5c0f\u50e7",\n "Url": "https://gitee.com/monksoul",\n "Email": "monksoul@outlook.com"\n },\n "License": {\n "Name": "Apache-2.0",\n "Url": "https://gitee.com/monksoul/Fur/blob/alpha/LICENSE"\n }\n }\n ]\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger5.png")}),Object(r.b)("h3",{id:"658-\u7ec4\u4e2d\u7ec4\uff08\u6807\u7b7e\uff09"},"6.5.8 \u7ec4\u4e2d\u7ec4\uff08\u6807\u7b7e\uff09"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Tag")," \u914d\u7f6e\u4e3b\u8981\u7528\u4e8e\u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u6807\u7b7e\u5206\u7ec4\u4fe1\u606f\u53ca\u5408\u5e76\u6807\u7b7e\u3002\u4e5f\u5c31\u662f ",Object(r.b)("inlineCode",{parentName:"p"},"\u7ec4\u4e2d\u7ec4"),":"),Object(r.b)(l.a,{defaultValue:"tag1",values:[{label:"\u6807\u7b7e\u547d\u540d",value:"tag1"},{label:"\u5408\u5e76\u6807\u7b7e",value:"tag2"}],mdxType:"Tabs"},Object(r.b)(b.a,{value:"tag1",mdxType:"TabItem"},Object(r.b)("h4",{id:"\u672a\u8d34\u6807\u7b7e\u4e4b\u524d"},"\u672a\u8d34\u6807\u7b7e\u4e4b\u524d"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs"}),"using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n\n public class TestAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n}\n")),Object(r.b)("h4",{id:"\u8d34\u6807\u7b7e\u4e4b\u540e"},"\u8d34\u6807\u7b7e\u4e4b\u540e"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,19}","{5,19}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(Tag = "\u5206\u7ec4\u4e00")]\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n\n [ApiDescriptionSettings(Tag = "\u5206\u7ec4\u4e8c")]\n public class TestAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/tag1.png")})),Object(r.b)(b.a,{value:"tag2",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,19}","{5,19}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [ApiDescriptionSettings(Tag = "\u5408\u5e76\u6240\u6709\u6807\u7b7e")]\n public class FurAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n\n [ApiDescriptionSettings(Tag = "\u5408\u5e76\u6240\u6709\u6807\u7b7e")]\n public class TestAppService : IDynamicApiController\n {\n public string Get()\n {\n return nameof(Fur);\n }\n\n public int Get(int id)\n {\n return id;\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/tag2.png")}))),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5982\u679c ",Object(r.b)("inlineCode",{parentName:"p"},"Tag")," \u540d\u5b57\u4e00\u6837\uff0c\u5219\u4f1a\u81ea\u52a8\u5408\u5e76\uff0c\u5426\u5219\u53ea\u662f\u547d\u540d\u3002"))),Object(r.b)("h3",{id:"659-\u9ed8\u8ba4\u5c55\u5f00\u6240\u6709\u6587\u6863"},"6.5.9 \u9ed8\u8ba4\u5c55\u5f00\u6240\u6709\u6587\u6863"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-json",metastring:'{2-5} title="Fur.Web.Entry/appsettings.json"',"{2-5}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "SpecificationDocumentSettings": {\n "DocExpansionState": "Full"\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger6.gif")}),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"DocExpansionState")," \u914d\u7f6e\u8bf4\u660e\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"List"),"\uff1a\u5217\u8868\u5f0f\uff08\u5c55\u5f00\u5b50\u7c7b\uff09\uff0c",Object(r.b)("strong",{parentName:"li"},"\u9ed8\u8ba4\u503c")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Full"),"\uff1a\u5b8c\u5168\u5c55\u5f00"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"None"),"\uff1a\u5217\u8868\u5f0f\uff08\u4e0d\u5c55\u5f00\u5b50\u7c7b\uff09")),Object(r.b)("h3",{id:"6510-\u914d\u7f6e\u6587\u6863\u6807\u9898"},"6.5.10 \u914d\u7f6e\u6587\u6863\u6807\u9898"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-json",metastring:'{2-5} title="Fur.Web.Entry/appsettings.json"',"{2-5}":!0,title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "SpecificationDocumentSettings": {\n "DocumentTitle": "\u6211\u662f\u81ea\u5b9a\u4e49\u6807\u9898"\n }\n }\n}\n')),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger7.png")}),Object(r.b)("h3",{id:"6511-\u6388\u6743\u63a7\u5236"},"6.5.11 \u6388\u6743\u63a7\u5236"),Object(r.b)("p",null,"\u5f85\u6574\u7406..."),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-json",metastring:'title="Fur.Web.Entry/appsettings.json"',title:'"Fur.Web.Entry/appsettings.json"'}),'{\n "AppSettings": {\n "SpecificationDocumentSettings": {\n "EnableAuthorized": true,\n\n "SecurityDefinitions": [\n {\n "Id": "Bearer",\n "Type": "Http",\n "Name": "Authorization",\n "Description": "JWT Authorization header using the Bearer scheme.",\n "BearerFormat": "JWT",\n "Scheme": "bearer",\n "In": "Header",\n\n "Requirement": {\n "Scheme": {\n "Reference": {\n "Id": "Bearer",\n "Type": "SecurityScheme"\n },\n "Accesses": null\n }\n }\n }\n ]\n }\n }\n}\n')),Object(r.b)("h3",{id:"6512-\u5728\u7ebf\u6d4b\u8bd5"},"6.5.12 \u5728\u7ebf\u6d4b\u8bd5"),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/swagger8.gif")}),Object(r.b)("h3",{id:"6513-\u6027\u80fd\u76d1\u89c6-miniprofiler"},"6.5.13 \u6027\u80fd\u76d1\u89c6 ",Object(r.b)("inlineCode",{parentName:"h3"},"MiniProfiler")),Object(r.b)("p",null,"\u89c4\u8303\u5316\u6587\u6863\u9ed8\u8ba4\u96c6\u6210\u4e86 ",Object(r.b)("inlineCode",{parentName:"p"},"MiniProfiler")," \u7b2c\u4e09\u65b9\u6027\u80fd\u7ec4\u4ef6\uff0c\u901a\u8fc7\u8be5\u7ec4\u4ef6\u53ef\u4ee5\u65b9\u4fbf\u67e5\u770b\u8bf7\u6c42\u6027\u80fd\u3001\u5f02\u5e38\u5806\u6808\u3001\u6570\u636e\u5e93\u64cd\u4f5c\u7b49\u4fe1\u606f\u3002\u9ed8\u8ba4\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Swagger")," \u9996\u9875\u5de6\u4e0a\u89d2\u663e\u793a\u3002"),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/mipr.png")}),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u5c0f\u63d0\u793a")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u4e5f\u53ef\u4ee5\u901a\u8fc7 ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"appsetting.json"))," \u4e2d ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"AppSettings:InjectMiniProfiler"))," \u8bbe\u4e3a ",Object(r.b)("strong",{parentName:"p"},Object(r.b)("inlineCode",{parentName:"strong"},"false"))," \u5173\u95ed\u3002"))),Object(r.b)("h3",{id:"6514-\u5b9a\u4e49\u63a5\u53e3\u8f93\u51fa\u7c7b\u578b"},"6.5.14 \u5b9a\u4e49\u63a5\u53e3\u8f93\u51fa\u7c7b\u578b"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,8-9}","{2,8-9}":!0}),"using Fur.DynamicApiController;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Application\n{\n public class FurAppService : IDynamicApiController\n {\n [ProducesResponseType(201, Type = typeof(TestDto))]\n [ProducesResponseType(400)]\n public string Get()\n {\n return nameof(Fur);\n }\n }\n}\n")),Object(r.b)("p",null,"\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(r.b)("img",{src:Object(c.a)("img/fhzlx.png")}),Object(r.b)("h2",{id:"66-specificationdocumentsettings-\u914d\u7f6e"},"6.6 ",Object(r.b)("inlineCode",{parentName:"h2"},"SpecificationDocumentSettings")," \u914d\u7f6e"),Object(r.b)("p",null,"\u9664\u4e86\u4e0a\u8ff0\u4f8b\u5b50\u5916\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u4e86\u4e00\u4e9b\u914d\u7f6e\u9009\u9879\uff0c\u5982\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DocumentTitle"),"\uff1a\u6587\u6863\u6807\u9898\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"Specification Api Document")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DefaultGroupName"),"\uff1a\u9ed8\u8ba4\u5206\u7ec4\u540d\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"Default")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"EnableAuthorized"),"\uff1a\u662f\u5426\u542f\u7528\u6743\u9650\u63a7\u5236\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"true")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"FormatAsV2"),"\uff1a\u91c7\u7528 ",Object(r.b)("inlineCode",{parentName:"li"},"Swagger 2.0")," \u7248\u672c\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"bool"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"false")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"RoutePrefix"),"\uff1a\u89c4\u8303\u5316\u6587\u6863\u5730\u5740\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"string")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"DocExpansionState"),"\uff1a\u6587\u6863\u663e\u793a\u65b9\u5f0f\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"DocExpansion"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"List"),"\uff0c\u53d6\u503c\uff1a",Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"List"),"\uff1a\u5217\u8868\u5f0f\uff08\u5c55\u5f00\u5b50\u7c7b\uff09\uff0c",Object(r.b)("strong",{parentName:"li"},"\u9ed8\u8ba4\u503c")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Full"),"\uff1a\u5b8c\u5168\u5c55\u5f00"),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"None"),"\uff1a\u5217\u8868\u5f0f\uff08\u4e0d\u5c55\u5f00\u5b50\u7c7b\uff09"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"XmlComments"),"\uff1a\u7a0b\u5e8f\u96c6\u6ce8\u91ca\u63cf\u8ff0\u6587\u4ef6\u540d\uff08\u53ef\u5e26 ",Object(r.b)("inlineCode",{parentName:"li"},".xml"),"\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"string"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"Fur.Application, Fur.Web.Entry, Fur.Web.Core")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"GroupOpenApiInfos"),"\uff1a\u5206\u7ec4\u4fe1\u606f\u914d\u7f6e\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"SpecificationOpenApiInfo[]"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"{ 'Group': 'Default'}")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"SecurityDefinitions"),"\uff1a\u5b89\u5168\u7b56\u7565\u5b9a\u4e49\u914d\u7f6e\uff0c",Object(r.b)("inlineCode",{parentName:"li"},"SpecificationOpenApiSecurityScheme[]"),"\uff0c\u9ed8\u8ba4 ",Object(r.b)("inlineCode",{parentName:"li"},"[]"))),Object(r.b)("h2",{id:"67-\u7edf\u4e00\u8fd4\u56de\u503c\u6a21\u578b"},"6.7 \u7edf\u4e00\u8fd4\u56de\u503c\u6a21\u578b"),Object(r.b)("p",null,Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b ",Object(r.b)("inlineCode",{parentName:"p"},"\u89c4\u8303\u5316\u7ed3\u679c")," \u529f\u80fd\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b9e\u73b0 ",Object(r.b)("inlineCode",{parentName:"p"},"IUnifyResultProvider")," \u63d0\u4f9b\u5668\u5b9e\u73b0\u7edf\u4e00\u89c4\u8303\u5316\u8fd4\u56de\u503c\u5b9a\u5236\uff0c\u5982\uff1a",Object(r.b)("inlineCode",{parentName:"p"},"RESTfulResultProvider"),"\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs"}),'using Microsoft.AspNetCore.Http;\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.AspNetCore.Mvc.Filters;\nusing Microsoft.AspNetCore.Mvc.ModelBinding;\nusing System.Collections.Generic;\n\nnamespace Fur.UnifyResult\n{\n /// \n /// RESTful \u98ce\u683c\u8fd4\u56de\u503c\n /// \n public class RESTfulResultProvider : IUnifyResultProvider\n {\n /// \n /// \u5f02\u5e38\u8fd4\u56de\u503c\n /// \n /// \n /// \n public IActionResult OnException(ExceptionContext context)\n {\n return new JsonResult(new RESTfulResult\n {\n StatusCode = StatusCodes.Status500InternalServerError,\n Successed = false,\n Data = null,\n Errors = context.Exception.Message\n });\n }\n\n /// \n /// \u6210\u529f\u8fd4\u56de\u503c\n /// \n /// \n /// \n public IActionResult OnSuccessed(ActionExecutedContext context)\n {\n object data;\n // \u5904\u7406\u5185\u5bb9\u7ed3\u679c\n if (context.Result is ContentResult contentResult) data = contentResult.Content;\n // \u5904\u7406\u5bf9\u8c61\u7ed3\u679c\n else if (context.Result is ObjectResult objectResult) data = objectResult.Value;\n else return null;\n\n return new JsonResult(new RESTfulResult\n {\n StatusCode = context.Result is EmptyResult ? StatusCodes.Status204NoContent : StatusCodes.Status200OK,\n Successed = true,\n Data = data,\n Errors = null\n });\n }\n\n /// \n /// \u9a8c\u8bc1\u5931\u8d25\u8fd4\u56de\u503c\n /// \n /// \n /// \n /// \n /// \n /// \n public IActionResult OnValidateFailed(ActionExecutingContext context, ModelStateDictionary modelStates, Dictionary> validationResults, string validateFaildMessage)\n {\n return new JsonResult(new RESTfulResult\n {\n StatusCode = StatusCodes.Status400BadRequest,\n Successed = false,\n Data = null,\n Errors = validationResults\n });\n }\n }\n}\n')),Object(r.b)("p",null,"\u4e4b\u540e\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Startup.cs")," \u4e2d\u6ce8\u518c\u5373\u53ef\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(i.a)({parentName:"pre"},{className:"language-cs"}),"services.AddControllers().AddUnifyResult();\n")),Object(r.b)("h2",{id:"68-\u53cd\u9988\u4e0e\u5efa\u8bae"},"6.8 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(i.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(i.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(i.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(i.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(i.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}m.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return s})),t.d(n,"b",(function(){return d}));var i=t(0),a=t.n(i);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function l(e){for(var n=1;n=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}var o=a.a.createContext({}),p=function(e){var n=a.a.useContext(o),t=n;return e&&(t="function"==typeof e?e(n):l(l({},n),e)),t},s=function(e){var n=p(e.components);return a.a.createElement(o.Provider,{value:n},e.children)},u={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},m=a.a.forwardRef((function(e,n){var t=e.components,i=e.mdxType,r=e.originalType,c=e.parentName,o=b(e,["components","mdxType","originalType","parentName"]),s=p(t),m=i,d=s["".concat(c,".").concat(m)]||s[m]||u[m]||r;return t?a.a.createElement(d,l(l({ref:n},o),{},{components:t})):a.a.createElement(d,l({ref:n},o))}));function d(e,n){var t=arguments,i=n&&n.mdxType;if("string"==typeof e||i){var r=t.length,c=new Array(r);c[0]=m;var l={};for(var b in n)hasOwnProperty.call(n,b)&&(l[b]=n[b]);l.originalType=e,l.mdxType="string"==typeof e?e:i,c[1]=l;for(var o=2;oappsettings.json \u4fe1\u606f",id:"4231-\u914d\u7f6e-appsettingsjson-\u4fe1\u606f",children:[]},{value:"4.2.3.2 \u521b\u5efa AppInfoOptions \u5f3a\u7c7b\u578b\u7c7b",id:"4232-\u521b\u5efa-appinfooptions-\u5f3a\u7c7b\u578b\u7c7b",children:[]},{value:"4.2.3.3 \u6ce8\u518c AppInfoOptions \u670d\u52a1",id:"4233-\u6ce8\u518c-appinfooptions-\u670d\u52a1",children:[]},{value:"4.2.3.4 \u8bfb\u53d6 AppInfoOptions \u4fe1\u606f",id:"4234-\u8bfb\u53d6-appinfooptions-\u4fe1\u606f",children:[]},{value:"4.2.3.5 \u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f",id:"4235-\u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f",children:[]}]},{value:"4.2.4 \u9009\u9879\u63a5\u53e3\u8bf4\u660e",id:"424-\u9009\u9879\u63a5\u53e3\u8bf4\u660e",children:[]},{value:"4.2.5 \u9009\u9879\u81ea\u5b9a\u4e49\u914d\u7f6e",id:"425-\u9009\u9879\u81ea\u5b9a\u4e49\u914d\u7f6e",children:[{value:"4.2.5.1 \u9009\u9879\u67e5\u627e\u952e\u6d41\u7a0b",id:"4251-\u9009\u9879\u67e5\u627e\u952e\u6d41\u7a0b",children:[]}]},{value:"4.2.6 [OptionsSettings] \u8bf4\u660e",id:"426-optionssettings-\u8bf4\u660e",children:[]},{value:"4.2.7 \u9009\u9879\u9a8c\u8bc1",id:"427-\u9009\u9879\u9a8c\u8bc1",children:[]},{value:"4.2.8 \u9009\u9879\u540e\u671f\u914d\u7f6e",id:"428-\u9009\u9879\u540e\u671f\u914d\u7f6e",children:[]},{value:"4.2.9 \u9009\u9879\u66f4\u6539\u901a\u77e5\uff08\u70ed\u66f4\u65b0\uff09",id:"429-\u9009\u9879\u66f4\u6539\u901a\u77e5\uff08\u70ed\u66f4\u65b0\uff09",children:[]},{value:"4.2.10 \u9009\u9879\u7684\u4f18\u7f3a\u70b9",id:"4210-\u9009\u9879\u7684\u4f18\u7f3a\u70b9",children:[]},{value:"4.2.11 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"4211-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],l={rightToc:b};function O(e){var n=e.components,t=Object(i.a)(e,["components"]);return Object(o.b)("wrapper",Object(a.a)({},l,t,{components:n,mdxType:"MDXLayout"}),Object(o.b)("h2",{id:"421-\u4ec0\u4e48\u662f\u9009\u9879"},"4.2.1 \u4ec0\u4e48\u662f\u9009\u9879"),Object(o.b)("p",null,"\u9009\u9879\u662f ",Object(o.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u63a8\u8350\u7684\u52a8\u6001\u8bfb\u53d6\u914d\u7f6e\u7684\u65b9\u5f0f\uff0c\u8fd9\u79cd\u65b9\u5f0f\u5c06\u914d\u7f6e\u6587\u4ef6\u6570\u636e\u7528\u4e00\u4e2a",Object(o.b)("strong",{parentName:"p"},"\u5f3a\u7c7b\u578b"),"\u6765\u6258\u7ba1\uff0c\u80fd\u591f\u5b9e\u73b0\u914d\u7f6e\u9a8c\u8bc1\u3001\u9ed8\u8ba4\u503c\u914d\u7f6e\u3001\u5b9e\u65f6\u8bfb\u53d6\u7b49\u529f\u80fd\u3002"),Object(o.b)("h2",{id:"422-\u4e0e\u914d\u7f6e\u7684\u533a\u522b"},"4.2.2 \u4e0e\u914d\u7f6e\u7684\u533a\u522b"),Object(o.b)("p",null,"\u9009\u9879\u5b9e\u9645\u4e0a\u4e5f\u662f\u914d\u7f6e\uff0c\u4f46\u5728\u540e\u8005\u7684\u57fa\u7840\u4e0a\u6dfb\u52a0\u4e86\u914d\u7f6e\u9a8c\u8bc1\u3001\u9ed8\u8ba4\u503c/\u540e\u671f\u914d\u7f6e\u8bbe\u5b9a\u53ca\u63d0\u4f9b\u4e86\u591a\u79cd\u63a5\u53e3\u8bfb\u53d6\u914d\u7f6e\u4fe1\u606f\uff0c\u540c\u65f6\u8fd8\u652f\u6301\u4f9b\u914d\u7f6e\u66f4\u6539\u901a\u77e5\u7b49\u5f3a\u5927\u7075\u6d3b\u529f\u80fd\u3002"),Object(o.b)("p",null,"\u6240\u4ee5\uff0c\u9664\u4e86\u4e00\u6b21\u6027\u8bfb\u53d6\u4f7f\u7528\u7684\u914d\u7f6e\u4ee5\u5916\uff0c\u90fd\u5e94\u8be5\u9009\u7528 ",Object(o.b)("strong",{parentName:"p"},"\u9009\u9879")," \u66ff\u6362 ",Object(o.b)("strong",{parentName:"p"},"\u914d\u7f6e"),"\u3002"),Object(o.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u77e5\u8bc6\u5bfc\u822a")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u6709\u5173\u914d\u7f6e\u8bf4\u660e\u53ef\u67e5\u770b\u300a",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"/fur/docs/configuration"}),"4.1 \u914d\u7f6e"),"\u300b \u7ae0\u8282\u3002"))),Object(o.b)("h2",{id:"423-\u9009\u9879\u7684\u4f7f\u7528"},"4.2.3 \u9009\u9879\u7684\u4f7f\u7528"),Object(o.b)("p",null,"\u5047\u8bbe\u6211\u4eec\u9700\u8981\u5728\u7cfb\u7edf\u8fd0\u884c\u65f6\u83b7\u53d6",Object(o.b)("strong",{parentName:"p"},"\u7cfb\u7edf\u540d\u79f0\u3001\u7248\u672c\u53f7\u53ca\u7248\u6743\u4fe1\u606f"),"\uff0c\u8fd9\u4e9b\u4fe1\u606f\u53ef\u80fd\u968f\u65f6\u53d8\u5316\u800c\u4e14\u9700\u8981\u5728\u591a\u4e2a\u5730\u65b9\u4f7f\u7528\u3002\u8fd9\u65f6\u5c31\u9700\u8981\u5c06\u8fd9\u4e9b\u4fe1\u606f\u914d\u7f6e\u8d77\u6765\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a"),Object(o.b)("h3",{id:"4231-\u914d\u7f6e-appsettingsjson-\u4fe1\u606f"},"4.2.3.1 \u914d\u7f6e ",Object(o.b)("inlineCode",{parentName:"h3"},"appsettings.json")," \u4fe1\u606f"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:"{2-6}","{2-6}":!0}),'{\n "AppInfo": {\n "Name": "Fur",\n "Version": "1.0.0",\n "Company": "Baiqian"\n }\n}\n')),Object(o.b)("h3",{id:"4232-\u521b\u5efa-appinfooptions-\u5f3a\u7c7b\u578b\u7c7b"},"4.2.3.2 \u521b\u5efa ",Object(o.b)("inlineCode",{parentName:"h3"},"AppInfoOptions")," \u5f3a\u7c7b\u578b\u7c7b"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5}","{1,5}":!0}),"using Fur.ConfigurableOptions;\n\nnamespace Fur.Application\n{\n public class AppInfoOptions : IConfigurableOptions\n {\n public string Name { get; set; }\n public string Version { get; set; }\n public string Company { get; set; }\n }\n}\n")),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u6e29\u99a8\u63d0\u793a")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u5efa\u8bae\u6240\u6709\u9009\u9879\u7c7b\u90fd\u5e94\u8be5\u4ee5 ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"Options"))," \u547d\u540d\u7ed3\u5c3e\u3002"),Object(o.b)("p",{parentName:"div"},"\u53e6\u5916\uff0c",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u7684\u6ce8\u518c\u9009\u9879\u670d\u52a1\u7684\u65b9\u6cd5\uff0c\u53ea\u9700\u8981\u7ee7\u627f ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"IConfigurableOptions"))," \u63a5\u53e3\u5373\u53ef\uff0c\u8be5\u63a5\u53e3\u4f4d\u4e8e ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"Fur.ConfigurableOptions"))," \u547d\u540d\u7a7a\u95f4\u4e0b\u3002"))),Object(o.b)("h3",{id:"4233-\u6ce8\u518c-appinfooptions-\u670d\u52a1"},"4.2.3.3 \u6ce8\u518c ",Object(o.b)("inlineCode",{parentName:"h3"},"AppInfoOptions")," \u670d\u52a1"),Object(o.b)("p",null,Object(o.b)("strong",{parentName:"p"},"\u9009\u9879\u4e0d\u540c\u4e8e\u914d\u7f6e\uff0c\u9700\u5728\u5e94\u7528\u542f\u52a8\u65f6\u6ce8\u518c")),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{12} title="Fur.Web.Core\\FurWebCoreStartup.cs"',"{12}":!0,title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddConfigurableOptions();\n }\n }\n}\n")),Object(o.b)("h3",{id:"4234-\u8bfb\u53d6-appinfooptions-\u4fe1\u606f"},"4.2.3.4 \u8bfb\u53d6 ",Object(o.b)("inlineCode",{parentName:"h3"},"AppInfoOptions")," \u4fe1\u606f"),Object(o.b)("p",null,"\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u63d0\u4f9b\u4e86\u591a\u79cd\u8bfb\u53d6\u65b9\u5f0f\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u901a\u8fc7 ",Object(o.b)("inlineCode",{parentName:"li"},"App.GetOptions(jsonKey)")," \u8bfb\u53d6\uff08",Object(o.b)("strong",{parentName:"li"},"\u4e0d\u63a8\u8350"),"\uff09"),Object(o.b)("li",{parentName:"ul"},"\u901a\u8fc7\u4f9d\u8d56\u6ce8\u5165\u4ee5\u4e0b\u5b9e\u4f8b\u8bfb\u53d6\uff1a",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IOptions")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IOptionsSnapshot")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IOptionsMonitor")))),Object(o.b)("li",{parentName:"ul"},"\u901a\u8fc7 ",Object(o.b)("inlineCode",{parentName:"li"},"App")," \u9759\u6001\u7c7b\u63d0\u4f9b\u7684\u9759\u6001\u65b9\u6cd5\u83b7\u53d6\uff1a",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"App.GetOptions()")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"App.GetOptionsMonitor()")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"App.GetOptionsSnapshot()"))))),Object(o.b)(p.a,{defaultValue:"App.GetOptions(jsonKey)",values:[{label:"App.GetOptions(jsonKey)",value:"App.GetOptions(jsonKey)"},{label:"\u4f9d\u8d56\u6ce8\u5165\u65b9\u5f0f",value:"\u4f9d\u8d56\u6ce8\u5165\u65b9\u5f0f"},{label:"App.GetOptions()",value:"App.GetOptions()"}],mdxType:"Tabs"},Object(o.b)(r.a,{value:"App.GetOptions(jsonKey)",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{13-16}","{13-16}":!0}),'using Fur.Application;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n public class DefaultController : ControllerBase\n {\n [HttpGet]\n public string Get()\n {\n // \u4e0d\u63a8\u8350\u91c7\u7528\u6b64\u65b9\u5f0f\u8bfb\u53d6\n var appInfo = App.GetOptions("AppInfo");\n return $@"\u540d\u79f0\uff1a{appInfo.Name}\uff0c\n \u7248\u672c\uff1a{appInfo.Version}\uff0c\n \u516c\u53f8\uff1a{appInfo.Company}";\n }\n }\n}\n'))),Object(o.b)(r.a,{value:"\u4f9d\u8d56\u6ce8\u5165\u65b9\u5f0f",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{3,15-17,27-29,31-33,35-37}","{3,15-17,27-29,31-33,35-37}":!0}),'using Fur.Application;\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.Extensions.Options;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n public class DefaultController : ControllerBase\n {\n private readonly AppInfoOptions options1;\n private readonly AppInfoOptions options2;\n private readonly AppInfoOptions options3;\n\n public DefaultController(\n IOptions options\n , IOptionsSnapshot optionsSnapshot\n , IOptionsMonitor optionsMonitor)\n {\n options1 = options.Value;\n options2 = optionsSnapshot.Value;\n options3 = optionsMonitor.CurrentValue;\n }\n\n [HttpGet]\n public string Get()\n {\n var info1 = $@"\u540d\u79f0\uff1a{options1.Name}\uff0c\n \u7248\u672c\uff1a{options1.Version}\uff0c\n \u516c\u53f8\uff1a{options1.Company}";\n\n var info2 = $@"\u540d\u79f0\uff1a{options3.Name}\uff0c\n \u7248\u672c\uff1a{options3.Version}\uff0c\n \u516c\u53f8\uff1a{options3.Company}";\n\n var info3 = $@"\u540d\u79f0\uff1a{options3.Name}\uff0c\n \u7248\u672c\uff1a{options3.Version}\uff0c\n \u516c\u53f8\uff1a{options3.Company}";\n\n return $"{info1}-{info2}-{info3}";\n }\n }\n}\n'))),Object(o.b)(r.a,{value:"App.GetOptions()",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{12-15,17-20,22-25}","{12-15,17-20,22-25}":!0}),'using Fur.Application;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n public class DefaultController : ControllerBase\n {\n [HttpGet]\n public string Get()\n {\n var options1 = App.GetOptions();\n var info1 = $@"\u540d\u79f0\uff1a{options1.Name}\uff0c\n \u7248\u672c\uff1a{options1.Version}\uff0c\n \u516c\u53f8\uff1a{options1.Company}";\n\n var options2 = App.GetOptionsSnapshot();\n var info2 = $@"\u540d\u79f0\uff1a{options2.Name}\uff0c\n \u7248\u672c\uff1a{options2.Version}\uff0c\n \u516c\u53f8\uff1a{options2.Company}";\n\n var options3 = App.GetOptionsMonitor();\n var info3 = $@"\u540d\u79f0\uff1a{options3.Name}\uff0c\n \u7248\u672c\uff1a{options3.Version}\uff0c\n \u516c\u53f8\uff1a{options3.Company}";\n\n return $"{info1}-{info2}-{info3}";\n }\n }\n}\n')))),Object(o.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},Object(o.b)("inlineCode",{parentName:"p"},"App.GetOptions(jsonKey)")," \u9759\u6001\u65b9\u6cd5 \u533a\u522b\u4e8e\u6ca1\u6709\u53c2\u6570\u7684 ",Object(o.b)("inlineCode",{parentName:"p"},"App.GetOptions()")," \u9759\u6001\u65b9\u6cd5\uff0c\u524d\u8005\u5b9e\u9645\u4e0a\u8fd8\u662f ",Object(o.b)("strong",{parentName:"p"},"\u914d\u7f6e"),"\uff0c\u53ea\u4e0d\u8fc7\u505a\u4e86\u5f3a\u7c7b\u578b\u89e3\u6790\uff0c\u540e\u8005\u5219\u901a\u8fc7 ",Object(o.b)("inlineCode",{parentName:"p"},"IOptions")," \u89e3\u6790\u3002"),Object(o.b)("p",{parentName:"div"},"\u4e24\u8005\u6e90\u7801\u5982\u4e0b\uff1a"),Object(o.b)("pre",{parentName:"div"},Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{18-20,27-29} title="Fur/App/App.cs"',"{18-20,27-29}":!0,title:'"Fur/App/App.cs"'}),'using Microsoft.Extensions.Configuration;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\n\nnamespace Fur\n{\n /// \n /// \u5168\u5c40\u5e94\u7528\u7c7b\n /// \n public static class App\n {\n /// \n /// \u83b7\u53d6\u9009\u9879\n /// \n /// \u5f3a\u7c7b\u578b\u9009\u9879\u7c7b\n /// \u914d\u7f6e\u4e2d\u5bf9\u5e94\u7684Key\n /// \n public static TOptions GetOptions(string jsonKey)\n where TOptions : class\n => Configuration.GetSection(jsonKey).Get();\n\n /// \n /// \u83b7\u53d6\u9009\u9879\n /// \n /// \u5f3a\u7c7b\u578b\u9009\u9879\u7c7b\n /// \n public static TOptions GetOptions()\n where TOptions : class\n => ServiceProvider.GetService>().Value;\n\n // Other Codes...\n }\n}\n')),Object(o.b)("p",{parentName:"div"},"\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\u5f97\u77e5\uff0c\u4e3a\u4ec0\u4e48\u4e0d\u63a8\u8350\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"App.GetOptions(jsonKey)")," \u8bfb\u53d6\uff0c\u56e0\u4e3a\u8fd9\u79cd\u65b9\u5f0f\u65e0\u6cd5\u5e94\u7528\u9009\u9879\u9a8c\u8bc1\u3001\u9ed8\u8ba4\u914d\u7f6e\u3001\u66f4\u6539\u901a\u77e5\u7b49\u529f\u80fd\u3002"))),Object(o.b)("h3",{id:"4235-\u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f"},"4.2.3.5 \u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u5982\u679c\u9009\u9879\u9700\u8981\u5728\u591a\u4e2a\u5730\u65b9\u4f7f\u7528\uff0c\u5219\u65e0\u8bba\u4efb\u4f55\u65f6\u5019\u90fd\u4e0d\u63a8\u8350\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"li"},"App.GetOptions(jsonKey)")),Object(o.b)("li",{parentName:"ul"},"\u5728\u53ef\u4f9d\u8d56\u6ce8\u5165\u7c7b\u4e2d\uff0c\u4f9d\u8d56\u6ce8\u5165 ",Object(o.b)("inlineCode",{parentName:"li"},"IOptions[Snapshot|Monitor]")," \u8bfb\u53d6"),Object(o.b)("li",{parentName:"ul"},"\u5728\u9759\u6001\u7c7b/\u975e\u4f9d\u8d56\u6ce8\u5165\u7c7b\u4e2d\uff0c\u9009\u62e9 ",Object(o.b)("inlineCode",{parentName:"li"},"App.GetOptions[Snapshot|Monitor]()")," \u8bfb\u53d6")),Object(o.b)("h2",{id:"424-\u9009\u9879\u63a5\u53e3\u8bf4\u660e"},"4.2.4 \u9009\u9879\u63a5\u53e3\u8bf4\u660e"),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u5e94\u7528\u63d0\u4f9b\u4e86\u591a\u79cd\u8bfb\u53d6\u9009\u9879\u7684\u63a5\u53e3\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IOptions"),"\uff1a",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\uff1a",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u5728\u5e94\u7528\u542f\u52a8\u540e\u8bfb\u53d6\u914d\u7f6e\u6570\u636e"),Object(o.b)("li",{parentName:"ul"},"\u547d\u540d\u9009\u9879"))),Object(o.b)("li",{parentName:"ul"},"\u6ce8\u518c\u4e3a\u5355\u4e00\u5b9e\u4f8b\u4e14\u53ef\u4ee5\u6ce8\u5165\u5230\u4efb\u4f55\u670d\u52a1\u751f\u5b58\u671f"))),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IOptionsSnapshot"),"\uff1a",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u5728\u6bcf\u6b21\u8bf7\u6c42\u65f6\u5e94\u91cd\u65b0\u8ba1\u7b97\u9009\u9879\u7684\u65b9\u6848\u4e2d\u6709\u7528"),Object(o.b)("li",{parentName:"ul"},"\u6ce8\u518c\u4e3a\u8303\u56f4\u5185\uff0c\u56e0\u6b64\u65e0\u6cd5\u6ce8\u5165\u5230\u5355\u4e00\u5b9e\u4f8b\u670d\u52a1"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\u547d\u540d\u9009\u9879"))),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IOptionsMonitor"),"\uff1a",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u7528\u4e8e\u68c0\u7d22\u9009\u9879\u5e76\u7ba1\u7406 TOptions \u5b9e\u4f8b\u7684\u9009\u9879\u901a\u77e5\u3002"),Object(o.b)("li",{parentName:"ul"},"\u6ce8\u518c\u4e3a\u5355\u4e00\u5b9e\u4f8b\u4e14\u53ef\u4ee5\u6ce8\u5165\u5230\u4efb\u4f55\u670d\u52a1\u751f\u5b58\u671f\u3002"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\uff1a",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u66f4\u6539\u901a\u77e5"),Object(o.b)("li",{parentName:"ul"},"\u547d\u540d\u9009\u9879"),Object(o.b)("li",{parentName:"ul"},"\u53ef\u91cd\u8f7d\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},"\u9009\u62e9\u6027\u9009\u9879\u5931\u6548 ",Object(o.b)("inlineCode",{parentName:"li"},"(IOptionsMonitorCache)"))))))),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(o.b)("inlineCode",{parentName:"p"},"\u9009\u9879\u63a5\u53e3")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/configuration/options?view=aspnetcore-5.0#options-interfaces"}),"ASP.NET Core - \u9009\u9879 - \u9009\u9879\u63a5\u53e3")," \u5c0f\u8282\u3002"))),Object(o.b)("h2",{id:"425-\u9009\u9879\u81ea\u5b9a\u4e49\u914d\u7f6e"},"4.2.5 \u9009\u9879\u81ea\u5b9a\u4e49\u914d\u7f6e"),Object(o.b)("p",null,"\u6211\u4eec\u77e5\u9053\uff0c\u9009\u9879\u5b9e\u9645\u4e0a\u9700\u8981\u548c\u914d\u7f6e\u6587\u4ef6\u7279\u5b9a\u952e\u503c\u6302\u94a9\uff0c\u90a3 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u662f\u5982\u4f55\u51c6\u786e\u7684\u627e\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u952e\u503c\u7684\u5462\uff1f"),Object(o.b)("h3",{id:"4251-\u9009\u9879\u67e5\u627e\u952e\u6d41\u7a0b"},"4.2.5.1 \u9009\u9879\u67e5\u627e\u952e\u6d41\u7a0b"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},"\u6ca1\u6709\u8d34 ",Object(o.b)("inlineCode",{parentName:"strong"},"[OptionsSettings]")," \u7279\u6027"),Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u4ee5 ",Object(o.b)("inlineCode",{parentName:"li"},"Options")," \u7ed3\u5c3e\uff0c\u5219\u53bb\u9664 ",Object(o.b)("inlineCode",{parentName:"li"},"Options")," \u5b57\u7b26\u4e32"),Object(o.b)("li",{parentName:"ul"},"\u5426\u5219\u8fd4\u56de ",Object(o.b)("inlineCode",{parentName:"li"},"\u7c7b\u540d\u79f0")))),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},"\u8d34\u4e86 ",Object(o.b)("inlineCode",{parentName:"strong"},"[OptionsSettings]")," \u7279\u6027"),Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u5982\u679c\u914d\u7f6e\u4e86 ",Object(o.b)("inlineCode",{parentName:"li"},"JsonKey")," \u5c5e\u6027\uff0c\u5219\u8fd4\u56de ",Object(o.b)("inlineCode",{parentName:"li"},"JsonKey")," \u7684\u503c"),Object(o.b)("li",{parentName:"ul"},"\u5426\u5219\u8fd4\u56de ",Object(o.b)("inlineCode",{parentName:"li"},"\u7c7b\u540d\u79f0"))))),Object(o.b)(p.a,{defaultValue:"non-optionsettings",values:[{label:"\u65e0[OptionsSettings]",value:"non-optionsettings"},{label:"\u6709[OptionsSettings]",value:"has-optionsettings"}],mdxType:"Tabs"},Object(o.b)(r.a,{value:"non-optionsettings",mdxType:"TabItem"},Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u4ee5 ",Object(o.b)("inlineCode",{parentName:"li"},"Options")," \u7ed3\u5c3e\uff0c\u5219\u952e\u540d\u4e3a\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"AppInfo"))),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),"public class AppInfoOptions : IConfigurableOptions\n{\n public string Name { get; set; }\n public string Version { get; set; }\n public string Company { get; set; }\n}\n")),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u4e0d\u4ee5 ",Object(o.b)("inlineCode",{parentName:"li"},"Options")," \u7ed3\u5c3e\uff0c\u5219\u952e\u540d\u4e3a\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"AppInfoSettings"))),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),"public class AppInfoSettings : IConfigurableOptions\n{\n public string Name { get; set; }\n public string Version { get; set; }\n public string Company { get; set; }\n}\n"))),Object(o.b)(r.a,{value:"has-optionsettings",mdxType:"TabItem"},Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u914d\u7f6e\u4e86 ",Object(o.b)("inlineCode",{parentName:"li"},"JsonKey")," \u5c5e\u6027\uff0c\uff0c\u5219\u952e\u540d\u4e3a\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"AppSettings:AppInfo"))),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),'[OptionsSettings("AppSettings:AppInfo")]\npublic class AppInfoOptions : IConfigurableOptions\n{\n public string Name { get; set; }\n public string Version { get; set; }\n public string Company { get; set; }\n}\n')),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u6ca1\u6709\u914d\u7f6e ",Object(o.b)("inlineCode",{parentName:"li"},"JsonKey")," \u5c5e\u6027\uff0c\uff0c\u5219\u952e\u540d\u4e3a\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"AppInfoSettings"))),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),"[OptionsSettings]\npublic class AppInfoSettings : IConfigurableOptions\n{\n public string Name { get; set; }\n public string Version { get; set; }\n public string Company { get; set; }\n}\n")))),Object(o.b)("h2",{id:"426-optionssettings-\u8bf4\u660e"},"4.2.6 ",Object(o.b)("inlineCode",{parentName:"h2"},"[OptionsSettings]")," \u8bf4\u660e"),Object(o.b)("p",null,"\u9009\u9879\u7c7b\u53ef\u4ee5\u901a\u8fc7 ",Object(o.b)("inlineCode",{parentName:"p"},"[OptionsSettings]")," \u6765\u914d\u7f6e\u67e5\u627e\u8def\u5f84\u503c\u3002"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"JsonKey"),"\uff1a\u5bf9\u5e94\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u952e\uff0c\u652f\u6301 ",Object(o.b)("strong",{parentName:"li"},"\u5206\u5c42\u952e")," \u5b57\u7b26\u4e32\uff0c\u53c2\u89c1\uff1a\u300a",Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"configuration#%E5%A6%82%E4%BD%95%E9%80%89%E6%8B%A9%E8%AF%BB%E5%8F%96%E6%96%B9%E5%BC%8F"}),"4.2 \u914d\u7f6e - 3.1.3 \u5206\u5c42\u8bfb\u53d6\u6570\u636e"),"\u300b"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"PostConfigureAll"),"\uff1a\u9009\u9879\u540e\u671f\u914d\u7f6e\uff0c\u9ed8\u8ba4 ",Object(o.b)("inlineCode",{parentName:"li"},"false"),"\u3002",Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/configuration/options?view=aspnetcore-3.1#options-post-configuration"}),"ASP.NET Core - \u9009\u9879 - \u9009\u9879\u540e\u671f\u914d\u7f6e"))),Object(o.b)("h2",{id:"427-\u9009\u9879\u9a8c\u8bc1"},"4.2.7 \u9009\u9879\u9a8c\u8bc1"),Object(o.b)("p",null,"\u9009\u9879\u652f\u6301\u9a8c\u8bc1\u914d\u7f6e\u6709\u6548\u6027\uff0c\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u901a\u8fc7 ",Object(o.b)("inlineCode",{parentName:"p"},"services.AddConfigurableOptions()")," \u6ce8\u518c\u9009\u9879\u9ed8\u8ba4\u542f\u7528\u4e86\u9a8c\u8bc1\u652f\u6301\u3002"),Object(o.b)("p",null,"\u5305\u62ec\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u7279\u6027\u65b9\u5f0f ",Object(o.b)("inlineCode",{parentName:"li"},"DataAnnotations")),Object(o.b)("li",{parentName:"ul"},"\u81ea\u5b9a\u4e49\u590d\u6742\u9a8c\u8bc1 ",Object(o.b)("inlineCode",{parentName:"li"},"IValidateOptions"))),Object(o.b)(p.a,{defaultValue:"texin",values:[{label:"\u7279\u6027\u65b9\u5f0f",value:"texin"},{label:"\u590d\u6742\u9a8c\u8bc1",value:"fuza"}],mdxType:"Tabs"},Object(o.b)(r.a,{value:"texin",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,8,10,12}","{2,8,10,12}":!0}),'using Fur.ConfigurableOptions;\nusing System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Application\n{\n public class AppInfoOptions : IConfigurableOptions\n {\n [Required(ErrorMessage = "\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a")]\n public string Name { get; set; }\n [Required, RegularExpression(@"^[0-9][0-9\\.]+[0-9]$", ErrorMessage = "\u4e0d\u662f\u6709\u6548\u7684\u7248\u672c\u53f7")]\n public string Version { get; set; }\n [Required, MaxLength(100)]\n public string Company { get; set; }\n }\n}\n'))),Object(o.b)(r.a,{value:"fuza",mdxType:"TabItem"},Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u7c7b ",Object(o.b)("inlineCode",{parentName:"li"},"AppInfoValidation")," \u5e76\u7ee7\u627f ",Object(o.b)("inlineCode",{parentName:"li"},"IValidateOptions")," \u63a5\u53e3\uff0c\u540c\u65f6\u5b9e\u73b0 ",Object(o.b)("inlineCode",{parentName:"li"},"Validate")," \u65b9\u6cd5\u3002")),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,6,8,12,15}","{1,6,8,12,15}":!0}),'using Microsoft.Extensions.Options;\nusing System.Text.RegularExpressions;\n\nnamespace Fur.Application\n{\n public class AppInfoValidation : IValidateOptions\n {\n public ValidateOptionsResult Validate(string name, AppInfoOptions options)\n {\n if (!Regex.IsMatch(options.Version, @"^[0-9][0-9\\.]+[0-9]$"))\n {\n return ValidateOptionsResult.Fail("\u4e0d\u662f\u6709\u6548\u7684\u7248\u672c\u53f7");\n }\n\n return ValidateOptionsResult.Success;\n }\n }\n}\n')),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u9009\u9879\u7c7b\u7ee7\u627f ",Object(o.b)("inlineCode",{parentName:"li"},"IConfigurableOptions")," \u63a5\u53e3\uff0c\u5e76\u5b9e\u73b0\u8be5\u63a5\u53e3\u3002")),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{6,16-18}","{6,16-18}":!0}),'using Fur.ConfigurableOptions;\nusing System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Application\n{\n public class AppInfoOptions : IConfigurableOptions\n {\n [Required(ErrorMessage = "\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a")]\n public string Name { get; set; }\n [Required]\n public string Version { get; set; }\n [Required, MaxLength(100)]\n public string Company { get; set; }\n\n // \u9009\u9879\u540e\u671f\u914d\u7f6e\n public void PostConfigure(AppInfoOptions options)\n {\n }\n }\n}\n')),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u5b8c\u6574\u4ee3\u7801\u5982\u4e0b\uff1a")),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{4,9,19,25,27,31,34}","{4,9,19,25,27,31,34}":!0}),'using Fur.ConfigurableOptions;\nusing Microsoft.Extensions.Options;\nusing System.ComponentModel.DataAnnotations;\nusing System.Text.RegularExpressions;\n\nnamespace Fur.Application\n{\n // \u7ee7\u627f IConfigurableOptions \u63a5\u53e3\n public class AppInfoOptions : IConfigurableOptions\n {\n [Required(ErrorMessage = "\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a")]\n public string Name { get; set; }\n [Required]\n public string Version { get; set; }\n [Required, MaxLength(100)]\n public string Company { get; set; }\n\n // \u9009\u9879\u540e\u671f\u914d\u7f6e\n public void PostConfigure(AppInfoOptions options)\n {\n }\n }\n\n // \u521b\u5efa\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u7c7b\n public class AppInfoValidation : IValidateOptions\n {\n public ValidateOptionsResult Validate(string name, AppInfoOptions options)\n {\n if (!Regex.IsMatch(options.Version, @"^[0-9][0-9\\.]+[0-9]$"))\n {\n return ValidateOptionsResult.Fail("\u4e0d\u662f\u6709\u6548\u7684\u7248\u672c\u53f7");\n }\n\n return ValidateOptionsResult.Success;\n }\n }\n}\n')))),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"IConfigurableOptions"))," \u7ee7\u627f\u81ea ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"IConfigurableOptions")),"\uff0c\u4e5f\u5c31\u662f\u81ea\u5b9a\u4e49\u590d\u6742\u9a8c\u8bc1\u9ed8\u8ba4\u5177\u6709 ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"PostConfigure(TOptions options)"))," \u9009\u9879\u540e\u671f\u914d\u7f6e\u65b9\u6cd5\u3002\u5173\u4e8e\u300a",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"#227-%E9%80%89%E9%A1%B9%E5%90%8E%E6%9C%9F%E9%85%8D%E7%BD%AE"}),"4.3.7 \u9009\u9879\u540e\u671f\u914d\u7f6e"),"\u300b\u5c06\u5728\u4e0b\u4e00\u5c0f\u8282\u8bf4\u660e\u3002"))),Object(o.b)("h2",{id:"428-\u9009\u9879\u540e\u671f\u914d\u7f6e"},"4.2.8 \u9009\u9879\u540e\u671f\u914d\u7f6e"),Object(o.b)("p",null,"\u9009\u9879\u540e\u671f\u914d\u7f6e\u901a\u4fd7\u4e00\u70b9\u6765\u8bf4\uff0c\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u89e3\u6790\u503c\u6216\u8bbe\u5b9a\u9ed8\u8ba4\u503c/\u540e\u671f\u914d\u7f6e\u7b49\u3002"),Object(o.b)("p",null,"\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u914d\u7f6e\u9009\u9879\u540e\u671f\u914d\u7f6e\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u7ee7\u627f ",Object(o.b)("inlineCode",{parentName:"p"},"IConfigurableOptions\n {\n [Required(ErrorMessage = "\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a")]\n public string Name { get; set; }\n [Required]\n public string Version { get; set; }\n [Required, MaxLength(100)]\n public string Company { get; set; }\n\n public void PostConfigure(AppInfoOptions options, IConfiguration configuration)\n {\n options.Name ??= "Fur";\n options.Version ??= "1.0.0";\n options.Version ??= "Baiqian";\n }\n }\n}\n')),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"IConfigurableOptions"))," \u7ee7\u627f\u81ea ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"IConfigurableOptions")),"\uff0c\u4e5f\u5c31\u662f\u81ea\u5b9a\u4e49\u590d\u6742\u9a8c\u8bc1\u9ed8\u8ba4\u5177\u6709 ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"PostConfigure(TOptions options, IConfiguration configuration)"))," \u9009\u9879\u540e\u671f\u914d\u7f6e\u65b9\u6cd5\u3002"))),Object(o.b)("h2",{id:"429-\u9009\u9879\u66f4\u6539\u901a\u77e5\uff08\u70ed\u66f4\u65b0\uff09"},"4.2.9 \u9009\u9879\u66f4\u6539\u901a\u77e5\uff08",Object(o.b)("inlineCode",{parentName:"h2"},"\u70ed\u66f4\u65b0"),"\uff09"),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u7b80\u5355\u4e14\u7075\u6d3b\u7684\u65b9\u5f0f\u76d1\u542c\u9009\u9879\u66f4\u6539\uff0c\u4e5f\u5c31\u662f ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"appsettings.json")," \u6216 \u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u53d1\u751f\u4efb\u4f55\u66f4\u6539\u90fd\u4f1a\u89e6\u53d1\u5904\u7406\u65b9\u6cd5"),"\u3002"),Object(o.b)("p",null,"\u4f7f\u7528\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u7ee7\u627f ",Object(o.b)("inlineCode",{parentName:"p"},"IConfigurableOptionsListener")," \u63a5\u53e3\u5e76\u5b9e\u73b0 ",Object(o.b)("inlineCode",{parentName:"p"},"void OnListener(TOptions options, IConfiguration configuration)")," \u65b9\u6cd5\u5373\u53ef\u3002"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,12-16}","{5,12-16}":!0}),"using Fur.ConfigurableOptions;\n\nnamespace Fur.Application\n{\n public class AppInfoOptions : IConfigurableOptionsListener\n {\n public string Name { get; set; }\n public string Version { get; set; }\n public string Company { get; set; }\n }\n\n public void OnListener(AppInfoOptions options, IConfiguration configuration)\n {\n var name = options.Name; // \u5b9e\u65f6\u7684\u6700\u65b0\u503c\n var version = options.Version; // \u5b9e\u65f6\u7684\u6700\u65b0\u503c\n }\n\n public void PostConfigure(AppInfoOptions options, IConfiguration configuration)\n {\n }\n}\n")),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"IConfigurableOptionsListener"))," \u7ee7\u627f\u81ea ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"IConfigurableOptions")),"\u3002"))),Object(o.b)("h2",{id:"4210-\u9009\u9879\u7684\u4f18\u7f3a\u70b9"},"4.2.10 \u9009\u9879\u7684\u4f18\u7f3a\u70b9"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("p",{parentName:"li"},"\u4f18\u70b9"),Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u5f3a\u7c7b\u578b\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},"\u63d0\u4f9b\u591a\u79cd\u8bfb\u53d6\u65b9\u5f0f"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\u70ed\u52a0\u8f7d"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\u8bbe\u7f6e\u9ed8\u8ba4\u503c/\u540e\u671f\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\u5728\u8fd0\u884c\u73af\u5883\u4e2d\u52a8\u6001\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\u9a8c\u8bc1\u914d\u7f6e\u6709\u6548\u6027"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\u66f4\u6539\u901a\u77e5"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\u547d\u540d\u9009\u9879"))),Object(o.b)("li",{parentName:"ul"},Object(o.b)("p",{parentName:"li"},"\u7f3a\u70b9"),Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u9700\u8981\u5b9a\u4e49\u5bf9\u5e94\u7c7b\u578b"),Object(o.b)("li",{parentName:"ul"},"\u9700\u8981\u5728\u542f\u52a8\u65f6\u6ce8\u518c")))),Object(o.b)("h2",{id:"4211-\u53cd\u9988\u4e0e\u5efa\u8bae"},"4.2.11 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))),Object(o.b)("hr",null),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(o.b)("inlineCode",{parentName:"p"},"\u9009\u9879")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/configuration/options?view=aspnetcore-5.0"}),"ASP.NET Core - \u9009\u9879")," \u7ae0\u8282\u3002"))))}O.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return l})),t.d(n,"b",(function(){return m}));var a=t(0),i=t.n(a);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function p(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function r(e){for(var n=1;n=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var c=i.a.createContext({}),b=function(e){var n=i.a.useContext(c),t=n;return e&&(t="function"==typeof e?e(n):r(r({},n),e)),t},l=function(e){var n=b(e.components);return i.a.createElement(c.Provider,{value:n},e.children)},O={inlineCode:"code",wrapper:function(e){var n=e.children;return i.a.createElement(i.a.Fragment,{},n)}},u=i.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,o=e.originalType,p=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),l=b(t),u=a,m=l["".concat(p,".").concat(u)]||l[u]||O[u]||o;return t?i.a.createElement(m,r(r({ref:n},c),{},{components:t})):i.a.createElement(m,r({ref:n},c))}));function m(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var o=t.length,p=new Array(o);p[0]=u;var r={};for(var s in n)hasOwnProperty.call(n,s)&&(r[s]=n[s]);r.originalType=e,r.mdxType="string"==typeof e?e:a,p[1]=r;for(var c=2;cappsettings.json \u4fe1\u606f",id:"4231-\u914d\u7f6e-appsettingsjson-\u4fe1\u606f",children:[]},{value:"4.2.3.2 \u521b\u5efa AppInfoOptions \u5f3a\u7c7b\u578b\u7c7b",id:"4232-\u521b\u5efa-appinfooptions-\u5f3a\u7c7b\u578b\u7c7b",children:[]},{value:"4.2.3.3 \u6ce8\u518c AppInfoOptions \u670d\u52a1",id:"4233-\u6ce8\u518c-appinfooptions-\u670d\u52a1",children:[]},{value:"4.2.3.4 \u8bfb\u53d6 AppInfoOptions \u4fe1\u606f",id:"4234-\u8bfb\u53d6-appinfooptions-\u4fe1\u606f",children:[]},{value:"4.2.3.5 \u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f",id:"4235-\u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f",children:[]}]},{value:"4.2.4 \u9009\u9879\u63a5\u53e3\u8bf4\u660e",id:"424-\u9009\u9879\u63a5\u53e3\u8bf4\u660e",children:[]},{value:"4.2.5 \u9009\u9879\u81ea\u5b9a\u4e49\u914d\u7f6e",id:"425-\u9009\u9879\u81ea\u5b9a\u4e49\u914d\u7f6e",children:[{value:"4.2.5.1 \u9009\u9879\u67e5\u627e\u952e\u6d41\u7a0b",id:"4251-\u9009\u9879\u67e5\u627e\u952e\u6d41\u7a0b",children:[]}]},{value:"4.2.6 [OptionsSettings] \u8bf4\u660e",id:"426-optionssettings-\u8bf4\u660e",children:[]},{value:"4.2.7 \u9009\u9879\u9a8c\u8bc1",id:"427-\u9009\u9879\u9a8c\u8bc1",children:[]},{value:"4.2.8 \u9009\u9879\u540e\u671f\u914d\u7f6e",id:"428-\u9009\u9879\u540e\u671f\u914d\u7f6e",children:[]},{value:"4.2.9 \u9009\u9879\u66f4\u6539\u901a\u77e5\uff08\u70ed\u66f4\u65b0\uff09",id:"429-\u9009\u9879\u66f4\u6539\u901a\u77e5\uff08\u70ed\u66f4\u65b0\uff09",children:[]},{value:"4.2.10 \u9009\u9879\u7684\u4f18\u7f3a\u70b9",id:"4210-\u9009\u9879\u7684\u4f18\u7f3a\u70b9",children:[]},{value:"4.2.11 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"4211-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],l={rightToc:b};function O(e){var n=e.components,t=Object(i.a)(e,["components"]);return Object(o.b)("wrapper",Object(a.a)({},l,t,{components:n,mdxType:"MDXLayout"}),Object(o.b)("h2",{id:"421-\u4ec0\u4e48\u662f\u9009\u9879"},"4.2.1 \u4ec0\u4e48\u662f\u9009\u9879"),Object(o.b)("p",null,"\u9009\u9879\u662f ",Object(o.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u63a8\u8350\u7684\u52a8\u6001\u8bfb\u53d6\u914d\u7f6e\u7684\u65b9\u5f0f\uff0c\u8fd9\u79cd\u65b9\u5f0f\u5c06\u914d\u7f6e\u6587\u4ef6\u6570\u636e\u7528\u4e00\u4e2a",Object(o.b)("strong",{parentName:"p"},"\u5f3a\u7c7b\u578b"),"\u6765\u6258\u7ba1\uff0c\u80fd\u591f\u5b9e\u73b0\u914d\u7f6e\u9a8c\u8bc1\u3001\u9ed8\u8ba4\u503c\u914d\u7f6e\u3001\u5b9e\u65f6\u8bfb\u53d6\u7b49\u529f\u80fd\u3002"),Object(o.b)("h2",{id:"422-\u4e0e\u914d\u7f6e\u7684\u533a\u522b"},"4.2.2 \u4e0e\u914d\u7f6e\u7684\u533a\u522b"),Object(o.b)("p",null,"\u9009\u9879\u5b9e\u9645\u4e0a\u4e5f\u662f\u914d\u7f6e\uff0c\u4f46\u5728\u540e\u8005\u7684\u57fa\u7840\u4e0a\u6dfb\u52a0\u4e86\u914d\u7f6e\u9a8c\u8bc1\u3001\u9ed8\u8ba4\u503c/\u540e\u671f\u914d\u7f6e\u8bbe\u5b9a\u53ca\u63d0\u4f9b\u4e86\u591a\u79cd\u63a5\u53e3\u8bfb\u53d6\u914d\u7f6e\u4fe1\u606f\uff0c\u540c\u65f6\u8fd8\u652f\u6301\u4f9b\u914d\u7f6e\u66f4\u6539\u901a\u77e5\u7b49\u5f3a\u5927\u7075\u6d3b\u529f\u80fd\u3002"),Object(o.b)("p",null,"\u6240\u4ee5\uff0c\u9664\u4e86\u4e00\u6b21\u6027\u8bfb\u53d6\u4f7f\u7528\u7684\u914d\u7f6e\u4ee5\u5916\uff0c\u90fd\u5e94\u8be5\u9009\u7528 ",Object(o.b)("strong",{parentName:"p"},"\u9009\u9879")," \u66ff\u6362 ",Object(o.b)("strong",{parentName:"p"},"\u914d\u7f6e"),"\u3002"),Object(o.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u77e5\u8bc6\u5bfc\u822a")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u6709\u5173\u914d\u7f6e\u8bf4\u660e\u53ef\u67e5\u770b\u300a",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"/docs/configuration"}),"4.1 \u914d\u7f6e"),"\u300b \u7ae0\u8282\u3002"))),Object(o.b)("h2",{id:"423-\u9009\u9879\u7684\u4f7f\u7528"},"4.2.3 \u9009\u9879\u7684\u4f7f\u7528"),Object(o.b)("p",null,"\u5047\u8bbe\u6211\u4eec\u9700\u8981\u5728\u7cfb\u7edf\u8fd0\u884c\u65f6\u83b7\u53d6",Object(o.b)("strong",{parentName:"p"},"\u7cfb\u7edf\u540d\u79f0\u3001\u7248\u672c\u53f7\u53ca\u7248\u6743\u4fe1\u606f"),"\uff0c\u8fd9\u4e9b\u4fe1\u606f\u53ef\u80fd\u968f\u65f6\u53d8\u5316\u800c\u4e14\u9700\u8981\u5728\u591a\u4e2a\u5730\u65b9\u4f7f\u7528\u3002\u8fd9\u65f6\u5c31\u9700\u8981\u5c06\u8fd9\u4e9b\u4fe1\u606f\u914d\u7f6e\u8d77\u6765\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a"),Object(o.b)("h3",{id:"4231-\u914d\u7f6e-appsettingsjson-\u4fe1\u606f"},"4.2.3.1 \u914d\u7f6e ",Object(o.b)("inlineCode",{parentName:"h3"},"appsettings.json")," \u4fe1\u606f"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:"{2-6}","{2-6}":!0}),'{\n "AppInfo": {\n "Name": "Fur",\n "Version": "1.0.0",\n "Company": "Baiqian"\n }\n}\n')),Object(o.b)("h3",{id:"4232-\u521b\u5efa-appinfooptions-\u5f3a\u7c7b\u578b\u7c7b"},"4.2.3.2 \u521b\u5efa ",Object(o.b)("inlineCode",{parentName:"h3"},"AppInfoOptions")," \u5f3a\u7c7b\u578b\u7c7b"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5}","{1,5}":!0}),"using Fur.ConfigurableOptions;\n\nnamespace Fur.Application\n{\n public class AppInfoOptions : IConfigurableOptions\n {\n public string Name { get; set; }\n public string Version { get; set; }\n public string Company { get; set; }\n }\n}\n")),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u6e29\u99a8\u63d0\u793a")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u5efa\u8bae\u6240\u6709\u9009\u9879\u7c7b\u90fd\u5e94\u8be5\u4ee5 ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"Options"))," \u547d\u540d\u7ed3\u5c3e\u3002"),Object(o.b)("p",{parentName:"div"},"\u53e6\u5916\uff0c",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u7684\u6ce8\u518c\u9009\u9879\u670d\u52a1\u7684\u65b9\u6cd5\uff0c\u53ea\u9700\u8981\u7ee7\u627f ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"IConfigurableOptions"))," \u63a5\u53e3\u5373\u53ef\uff0c\u8be5\u63a5\u53e3\u4f4d\u4e8e ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"Fur.ConfigurableOptions"))," \u547d\u540d\u7a7a\u95f4\u4e0b\u3002"))),Object(o.b)("h3",{id:"4233-\u6ce8\u518c-appinfooptions-\u670d\u52a1"},"4.2.3.3 \u6ce8\u518c ",Object(o.b)("inlineCode",{parentName:"h3"},"AppInfoOptions")," \u670d\u52a1"),Object(o.b)("p",null,Object(o.b)("strong",{parentName:"p"},"\u9009\u9879\u4e0d\u540c\u4e8e\u914d\u7f6e\uff0c\u9700\u5728\u5e94\u7528\u542f\u52a8\u65f6\u6ce8\u518c")),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{12} title="Fur.Web.Core\\FurWebCoreStartup.cs"',"{12}":!0,title:'"Fur.Web.Core\\FurWebCoreStartup.cs"'}),"using Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.Web.Core\n{\n [AppStartup(800)]\n public sealed class FurWebCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddConfigurableOptions();\n }\n }\n}\n")),Object(o.b)("h3",{id:"4234-\u8bfb\u53d6-appinfooptions-\u4fe1\u606f"},"4.2.3.4 \u8bfb\u53d6 ",Object(o.b)("inlineCode",{parentName:"h3"},"AppInfoOptions")," \u4fe1\u606f"),Object(o.b)("p",null,"\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u63d0\u4f9b\u4e86\u591a\u79cd\u8bfb\u53d6\u65b9\u5f0f\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u901a\u8fc7 ",Object(o.b)("inlineCode",{parentName:"li"},"App.GetOptions(jsonKey)")," \u8bfb\u53d6\uff08",Object(o.b)("strong",{parentName:"li"},"\u4e0d\u63a8\u8350"),"\uff09"),Object(o.b)("li",{parentName:"ul"},"\u901a\u8fc7\u4f9d\u8d56\u6ce8\u5165\u4ee5\u4e0b\u5b9e\u4f8b\u8bfb\u53d6\uff1a",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IOptions")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IOptionsSnapshot")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IOptionsMonitor")))),Object(o.b)("li",{parentName:"ul"},"\u901a\u8fc7 ",Object(o.b)("inlineCode",{parentName:"li"},"App")," \u9759\u6001\u7c7b\u63d0\u4f9b\u7684\u9759\u6001\u65b9\u6cd5\u83b7\u53d6\uff1a",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"App.GetOptions()")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"App.GetOptionsMonitor()")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"App.GetOptionsSnapshot()"))))),Object(o.b)(p.a,{defaultValue:"App.GetOptions(jsonKey)",values:[{label:"App.GetOptions(jsonKey)",value:"App.GetOptions(jsonKey)"},{label:"\u4f9d\u8d56\u6ce8\u5165\u65b9\u5f0f",value:"\u4f9d\u8d56\u6ce8\u5165\u65b9\u5f0f"},{label:"App.GetOptions()",value:"App.GetOptions()"}],mdxType:"Tabs"},Object(o.b)(r.a,{value:"App.GetOptions(jsonKey)",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{13-16}","{13-16}":!0}),'using Fur.Application;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n public class DefaultController : ControllerBase\n {\n [HttpGet]\n public string Get()\n {\n // \u4e0d\u63a8\u8350\u91c7\u7528\u6b64\u65b9\u5f0f\u8bfb\u53d6\n var appInfo = App.GetOptions("AppInfo");\n return $@"\u540d\u79f0\uff1a{appInfo.Name}\uff0c\n \u7248\u672c\uff1a{appInfo.Version}\uff0c\n \u516c\u53f8\uff1a{appInfo.Company}";\n }\n }\n}\n'))),Object(o.b)(r.a,{value:"\u4f9d\u8d56\u6ce8\u5165\u65b9\u5f0f",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{3,15-17,27-29,31-33,35-37}","{3,15-17,27-29,31-33,35-37}":!0}),'using Fur.Application;\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.Extensions.Options;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n public class DefaultController : ControllerBase\n {\n private readonly AppInfoOptions options1;\n private readonly AppInfoOptions options2;\n private readonly AppInfoOptions options3;\n\n public DefaultController(\n IOptions options\n , IOptionsSnapshot optionsSnapshot\n , IOptionsMonitor optionsMonitor)\n {\n options1 = options.Value;\n options2 = optionsSnapshot.Value;\n options3 = optionsMonitor.CurrentValue;\n }\n\n [HttpGet]\n public string Get()\n {\n var info1 = $@"\u540d\u79f0\uff1a{options1.Name}\uff0c\n \u7248\u672c\uff1a{options1.Version}\uff0c\n \u516c\u53f8\uff1a{options1.Company}";\n\n var info2 = $@"\u540d\u79f0\uff1a{options3.Name}\uff0c\n \u7248\u672c\uff1a{options3.Version}\uff0c\n \u516c\u53f8\uff1a{options3.Company}";\n\n var info3 = $@"\u540d\u79f0\uff1a{options3.Name}\uff0c\n \u7248\u672c\uff1a{options3.Version}\uff0c\n \u516c\u53f8\uff1a{options3.Company}";\n\n return $"{info1}-{info2}-{info3}";\n }\n }\n}\n'))),Object(o.b)(r.a,{value:"App.GetOptions()",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{12-15,17-20,22-25}","{12-15,17-20,22-25}":!0}),'using Fur.Application;\nusing Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n public class DefaultController : ControllerBase\n {\n [HttpGet]\n public string Get()\n {\n var options1 = App.GetOptions();\n var info1 = $@"\u540d\u79f0\uff1a{options1.Name}\uff0c\n \u7248\u672c\uff1a{options1.Version}\uff0c\n \u516c\u53f8\uff1a{options1.Company}";\n\n var options2 = App.GetOptionsSnapshot();\n var info2 = $@"\u540d\u79f0\uff1a{options2.Name}\uff0c\n \u7248\u672c\uff1a{options2.Version}\uff0c\n \u516c\u53f8\uff1a{options2.Company}";\n\n var options3 = App.GetOptionsMonitor();\n var info3 = $@"\u540d\u79f0\uff1a{options3.Name}\uff0c\n \u7248\u672c\uff1a{options3.Version}\uff0c\n \u516c\u53f8\uff1a{options3.Company}";\n\n return $"{info1}-{info2}-{info3}";\n }\n }\n}\n')))),Object(o.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"\u7279\u522b\u6ce8\u610f")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},Object(o.b)("inlineCode",{parentName:"p"},"App.GetOptions(jsonKey)")," \u9759\u6001\u65b9\u6cd5 \u533a\u522b\u4e8e\u6ca1\u6709\u53c2\u6570\u7684 ",Object(o.b)("inlineCode",{parentName:"p"},"App.GetOptions()")," \u9759\u6001\u65b9\u6cd5\uff0c\u524d\u8005\u5b9e\u9645\u4e0a\u8fd8\u662f ",Object(o.b)("strong",{parentName:"p"},"\u914d\u7f6e"),"\uff0c\u53ea\u4e0d\u8fc7\u505a\u4e86\u5f3a\u7c7b\u578b\u89e3\u6790\uff0c\u540e\u8005\u5219\u901a\u8fc7 ",Object(o.b)("inlineCode",{parentName:"p"},"IOptions")," \u89e3\u6790\u3002"),Object(o.b)("p",{parentName:"div"},"\u4e24\u8005\u6e90\u7801\u5982\u4e0b\uff1a"),Object(o.b)("pre",{parentName:"div"},Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:'{18-20,27-29} title="Fur/App/App.cs"',"{18-20,27-29}":!0,title:'"Fur/App/App.cs"'}),'using Microsoft.Extensions.Configuration;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Options;\n\nnamespace Fur\n{\n /// \n /// \u5168\u5c40\u5e94\u7528\u7c7b\n /// \n public static class App\n {\n /// \n /// \u83b7\u53d6\u9009\u9879\n /// \n /// \u5f3a\u7c7b\u578b\u9009\u9879\u7c7b\n /// \u914d\u7f6e\u4e2d\u5bf9\u5e94\u7684Key\n /// \n public static TOptions GetOptions(string jsonKey)\n where TOptions : class\n => Configuration.GetSection(jsonKey).Get();\n\n /// \n /// \u83b7\u53d6\u9009\u9879\n /// \n /// \u5f3a\u7c7b\u578b\u9009\u9879\u7c7b\n /// \n public static TOptions GetOptions()\n where TOptions : class\n => ServiceProvider.GetService>().Value;\n\n // Other Codes...\n }\n}\n')),Object(o.b)("p",{parentName:"div"},"\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\u5f97\u77e5\uff0c\u4e3a\u4ec0\u4e48\u4e0d\u63a8\u8350\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"App.GetOptions(jsonKey)")," \u8bfb\u53d6\uff0c\u56e0\u4e3a\u8fd9\u79cd\u65b9\u5f0f\u65e0\u6cd5\u5e94\u7528\u9009\u9879\u9a8c\u8bc1\u3001\u9ed8\u8ba4\u914d\u7f6e\u3001\u66f4\u6539\u901a\u77e5\u7b49\u529f\u80fd\u3002"))),Object(o.b)("h3",{id:"4235-\u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f"},"4.2.3.5 \u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u5982\u679c\u9009\u9879\u9700\u8981\u5728\u591a\u4e2a\u5730\u65b9\u4f7f\u7528\uff0c\u5219\u65e0\u8bba\u4efb\u4f55\u65f6\u5019\u90fd\u4e0d\u63a8\u8350\u4f7f\u7528 ",Object(o.b)("inlineCode",{parentName:"li"},"App.GetOptions(jsonKey)")),Object(o.b)("li",{parentName:"ul"},"\u5728\u53ef\u4f9d\u8d56\u6ce8\u5165\u7c7b\u4e2d\uff0c\u4f9d\u8d56\u6ce8\u5165 ",Object(o.b)("inlineCode",{parentName:"li"},"IOptions[Snapshot|Monitor]")," \u8bfb\u53d6"),Object(o.b)("li",{parentName:"ul"},"\u5728\u9759\u6001\u7c7b/\u975e\u4f9d\u8d56\u6ce8\u5165\u7c7b\u4e2d\uff0c\u9009\u62e9 ",Object(o.b)("inlineCode",{parentName:"li"},"App.GetOptions[Snapshot|Monitor]()")," \u8bfb\u53d6")),Object(o.b)("h2",{id:"424-\u9009\u9879\u63a5\u53e3\u8bf4\u660e"},"4.2.4 \u9009\u9879\u63a5\u53e3\u8bf4\u660e"),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u5e94\u7528\u63d0\u4f9b\u4e86\u591a\u79cd\u8bfb\u53d6\u9009\u9879\u7684\u63a5\u53e3\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IOptions"),"\uff1a",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\uff1a",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u5728\u5e94\u7528\u542f\u52a8\u540e\u8bfb\u53d6\u914d\u7f6e\u6570\u636e"),Object(o.b)("li",{parentName:"ul"},"\u547d\u540d\u9009\u9879"))),Object(o.b)("li",{parentName:"ul"},"\u6ce8\u518c\u4e3a\u5355\u4e00\u5b9e\u4f8b\u4e14\u53ef\u4ee5\u6ce8\u5165\u5230\u4efb\u4f55\u670d\u52a1\u751f\u5b58\u671f"))),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IOptionsSnapshot"),"\uff1a",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u5728\u6bcf\u6b21\u8bf7\u6c42\u65f6\u5e94\u91cd\u65b0\u8ba1\u7b97\u9009\u9879\u7684\u65b9\u6848\u4e2d\u6709\u7528"),Object(o.b)("li",{parentName:"ul"},"\u6ce8\u518c\u4e3a\u8303\u56f4\u5185\uff0c\u56e0\u6b64\u65e0\u6cd5\u6ce8\u5165\u5230\u5355\u4e00\u5b9e\u4f8b\u670d\u52a1"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\u547d\u540d\u9009\u9879"))),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"IOptionsMonitor"),"\uff1a",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u7528\u4e8e\u68c0\u7d22\u9009\u9879\u5e76\u7ba1\u7406 TOptions \u5b9e\u4f8b\u7684\u9009\u9879\u901a\u77e5\u3002"),Object(o.b)("li",{parentName:"ul"},"\u6ce8\u518c\u4e3a\u5355\u4e00\u5b9e\u4f8b\u4e14\u53ef\u4ee5\u6ce8\u5165\u5230\u4efb\u4f55\u670d\u52a1\u751f\u5b58\u671f\u3002"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\uff1a",Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u66f4\u6539\u901a\u77e5"),Object(o.b)("li",{parentName:"ul"},"\u547d\u540d\u9009\u9879"),Object(o.b)("li",{parentName:"ul"},"\u53ef\u91cd\u8f7d\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},"\u9009\u62e9\u6027\u9009\u9879\u5931\u6548 ",Object(o.b)("inlineCode",{parentName:"li"},"(IOptionsMonitorCache)"))))))),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(o.b)("inlineCode",{parentName:"p"},"\u9009\u9879\u63a5\u53e3")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/configuration/options?view=aspnetcore-5.0#options-interfaces"}),"ASP.NET Core - \u9009\u9879 - \u9009\u9879\u63a5\u53e3")," \u5c0f\u8282\u3002"))),Object(o.b)("h2",{id:"425-\u9009\u9879\u81ea\u5b9a\u4e49\u914d\u7f6e"},"4.2.5 \u9009\u9879\u81ea\u5b9a\u4e49\u914d\u7f6e"),Object(o.b)("p",null,"\u6211\u4eec\u77e5\u9053\uff0c\u9009\u9879\u5b9e\u9645\u4e0a\u9700\u8981\u548c\u914d\u7f6e\u6587\u4ef6\u7279\u5b9a\u952e\u503c\u6302\u94a9\uff0c\u90a3 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u662f\u5982\u4f55\u51c6\u786e\u7684\u627e\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u952e\u503c\u7684\u5462\uff1f"),Object(o.b)("h3",{id:"4251-\u9009\u9879\u67e5\u627e\u952e\u6d41\u7a0b"},"4.2.5.1 \u9009\u9879\u67e5\u627e\u952e\u6d41\u7a0b"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},"\u6ca1\u6709\u8d34 ",Object(o.b)("inlineCode",{parentName:"strong"},"[OptionsSettings]")," \u7279\u6027"),Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u4ee5 ",Object(o.b)("inlineCode",{parentName:"li"},"Options")," \u7ed3\u5c3e\uff0c\u5219\u53bb\u9664 ",Object(o.b)("inlineCode",{parentName:"li"},"Options")," \u5b57\u7b26\u4e32"),Object(o.b)("li",{parentName:"ul"},"\u5426\u5219\u8fd4\u56de ",Object(o.b)("inlineCode",{parentName:"li"},"\u7c7b\u540d\u79f0")))),Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},"\u8d34\u4e86 ",Object(o.b)("inlineCode",{parentName:"strong"},"[OptionsSettings]")," \u7279\u6027"),Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u5982\u679c\u914d\u7f6e\u4e86 ",Object(o.b)("inlineCode",{parentName:"li"},"JsonKey")," \u5c5e\u6027\uff0c\u5219\u8fd4\u56de ",Object(o.b)("inlineCode",{parentName:"li"},"JsonKey")," \u7684\u503c"),Object(o.b)("li",{parentName:"ul"},"\u5426\u5219\u8fd4\u56de ",Object(o.b)("inlineCode",{parentName:"li"},"\u7c7b\u540d\u79f0"))))),Object(o.b)(p.a,{defaultValue:"non-optionsettings",values:[{label:"\u65e0[OptionsSettings]",value:"non-optionsettings"},{label:"\u6709[OptionsSettings]",value:"has-optionsettings"}],mdxType:"Tabs"},Object(o.b)(r.a,{value:"non-optionsettings",mdxType:"TabItem"},Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u4ee5 ",Object(o.b)("inlineCode",{parentName:"li"},"Options")," \u7ed3\u5c3e\uff0c\u5219\u952e\u540d\u4e3a\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"AppInfo"))),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),"public class AppInfoOptions : IConfigurableOptions\n{\n public string Name { get; set; }\n public string Version { get; set; }\n public string Company { get; set; }\n}\n")),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u4e0d\u4ee5 ",Object(o.b)("inlineCode",{parentName:"li"},"Options")," \u7ed3\u5c3e\uff0c\u5219\u952e\u540d\u4e3a\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"AppInfoSettings"))),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),"public class AppInfoSettings : IConfigurableOptions\n{\n public string Name { get; set; }\n public string Version { get; set; }\n public string Company { get; set; }\n}\n"))),Object(o.b)(r.a,{value:"has-optionsettings",mdxType:"TabItem"},Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u914d\u7f6e\u4e86 ",Object(o.b)("inlineCode",{parentName:"li"},"JsonKey")," \u5c5e\u6027\uff0c\uff0c\u5219\u952e\u540d\u4e3a\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"AppSettings:AppInfo"))),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),'[OptionsSettings("AppSettings:AppInfo")]\npublic class AppInfoOptions : IConfigurableOptions\n{\n public string Name { get; set; }\n public string Version { get; set; }\n public string Company { get; set; }\n}\n')),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u6ca1\u6709\u914d\u7f6e ",Object(o.b)("inlineCode",{parentName:"li"},"JsonKey")," \u5c5e\u6027\uff0c\uff0c\u5219\u952e\u540d\u4e3a\uff1a",Object(o.b)("inlineCode",{parentName:"li"},"AppInfoSettings"))),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),"[OptionsSettings]\npublic class AppInfoSettings : IConfigurableOptions\n{\n public string Name { get; set; }\n public string Version { get; set; }\n public string Company { get; set; }\n}\n")))),Object(o.b)("h2",{id:"426-optionssettings-\u8bf4\u660e"},"4.2.6 ",Object(o.b)("inlineCode",{parentName:"h2"},"[OptionsSettings]")," \u8bf4\u660e"),Object(o.b)("p",null,"\u9009\u9879\u7c7b\u53ef\u4ee5\u901a\u8fc7 ",Object(o.b)("inlineCode",{parentName:"p"},"[OptionsSettings]")," \u6765\u914d\u7f6e\u67e5\u627e\u8def\u5f84\u503c\u3002"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"JsonKey"),"\uff1a\u5bf9\u5e94\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u952e\uff0c\u652f\u6301 ",Object(o.b)("strong",{parentName:"li"},"\u5206\u5c42\u952e")," \u5b57\u7b26\u4e32\uff0c\u53c2\u89c1\uff1a\u300a",Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"configuration#%E5%A6%82%E4%BD%95%E9%80%89%E6%8B%A9%E8%AF%BB%E5%8F%96%E6%96%B9%E5%BC%8F"}),"4.2 \u914d\u7f6e - 3.1.3 \u5206\u5c42\u8bfb\u53d6\u6570\u636e"),"\u300b"),Object(o.b)("li",{parentName:"ul"},Object(o.b)("inlineCode",{parentName:"li"},"PostConfigureAll"),"\uff1a\u9009\u9879\u540e\u671f\u914d\u7f6e\uff0c\u9ed8\u8ba4 ",Object(o.b)("inlineCode",{parentName:"li"},"false"),"\u3002",Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/configuration/options?view=aspnetcore-3.1#options-post-configuration"}),"ASP.NET Core - \u9009\u9879 - \u9009\u9879\u540e\u671f\u914d\u7f6e"))),Object(o.b)("h2",{id:"427-\u9009\u9879\u9a8c\u8bc1"},"4.2.7 \u9009\u9879\u9a8c\u8bc1"),Object(o.b)("p",null,"\u9009\u9879\u652f\u6301\u9a8c\u8bc1\u914d\u7f6e\u6709\u6548\u6027\uff0c\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u901a\u8fc7 ",Object(o.b)("inlineCode",{parentName:"p"},"services.AddConfigurableOptions()")," \u6ce8\u518c\u9009\u9879\u9ed8\u8ba4\u542f\u7528\u4e86\u9a8c\u8bc1\u652f\u6301\u3002"),Object(o.b)("p",null,"\u5305\u62ec\uff1a"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u7279\u6027\u65b9\u5f0f ",Object(o.b)("inlineCode",{parentName:"li"},"DataAnnotations")),Object(o.b)("li",{parentName:"ul"},"\u81ea\u5b9a\u4e49\u590d\u6742\u9a8c\u8bc1 ",Object(o.b)("inlineCode",{parentName:"li"},"IValidateOptions"))),Object(o.b)(p.a,{defaultValue:"texin",values:[{label:"\u7279\u6027\u65b9\u5f0f",value:"texin"},{label:"\u590d\u6742\u9a8c\u8bc1",value:"fuza"}],mdxType:"Tabs"},Object(o.b)(r.a,{value:"texin",mdxType:"TabItem"},Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,8,10,12}","{2,8,10,12}":!0}),'using Fur.ConfigurableOptions;\nusing System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Application\n{\n public class AppInfoOptions : IConfigurableOptions\n {\n [Required(ErrorMessage = "\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a")]\n public string Name { get; set; }\n [Required, RegularExpression(@"^[0-9][0-9\\.]+[0-9]$", ErrorMessage = "\u4e0d\u662f\u6709\u6548\u7684\u7248\u672c\u53f7")]\n public string Version { get; set; }\n [Required, MaxLength(100)]\n public string Company { get; set; }\n }\n}\n'))),Object(o.b)(r.a,{value:"fuza",mdxType:"TabItem"},Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u7c7b ",Object(o.b)("inlineCode",{parentName:"li"},"AppInfoValidation")," \u5e76\u7ee7\u627f ",Object(o.b)("inlineCode",{parentName:"li"},"IValidateOptions")," \u63a5\u53e3\uff0c\u540c\u65f6\u5b9e\u73b0 ",Object(o.b)("inlineCode",{parentName:"li"},"Validate")," \u65b9\u6cd5\u3002")),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,6,8,12,15}","{1,6,8,12,15}":!0}),'using Microsoft.Extensions.Options;\nusing System.Text.RegularExpressions;\n\nnamespace Fur.Application\n{\n public class AppInfoValidation : IValidateOptions\n {\n public ValidateOptionsResult Validate(string name, AppInfoOptions options)\n {\n if (!Regex.IsMatch(options.Version, @"^[0-9][0-9\\.]+[0-9]$"))\n {\n return ValidateOptionsResult.Fail("\u4e0d\u662f\u6709\u6548\u7684\u7248\u672c\u53f7");\n }\n\n return ValidateOptionsResult.Success;\n }\n }\n}\n')),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u9009\u9879\u7c7b\u7ee7\u627f ",Object(o.b)("inlineCode",{parentName:"li"},"IConfigurableOptions")," \u63a5\u53e3\uff0c\u5e76\u5b9e\u73b0\u8be5\u63a5\u53e3\u3002")),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{6,16-18}","{6,16-18}":!0}),'using Fur.ConfigurableOptions;\nusing System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Application\n{\n public class AppInfoOptions : IConfigurableOptions\n {\n [Required(ErrorMessage = "\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a")]\n public string Name { get; set; }\n [Required]\n public string Version { get; set; }\n [Required, MaxLength(100)]\n public string Company { get; set; }\n\n // \u9009\u9879\u540e\u671f\u914d\u7f6e\n public void PostConfigure(AppInfoOptions options)\n {\n }\n }\n}\n')),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"\u5b8c\u6574\u4ee3\u7801\u5982\u4e0b\uff1a")),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{4,9,19,25,27,31,34}","{4,9,19,25,27,31,34}":!0}),'using Fur.ConfigurableOptions;\nusing Microsoft.Extensions.Options;\nusing System.ComponentModel.DataAnnotations;\nusing System.Text.RegularExpressions;\n\nnamespace Fur.Application\n{\n // \u7ee7\u627f IConfigurableOptions \u63a5\u53e3\n public class AppInfoOptions : IConfigurableOptions\n {\n [Required(ErrorMessage = "\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a")]\n public string Name { get; set; }\n [Required]\n public string Version { get; set; }\n [Required, MaxLength(100)]\n public string Company { get; set; }\n\n // \u9009\u9879\u540e\u671f\u914d\u7f6e\n public void PostConfigure(AppInfoOptions options)\n {\n }\n }\n\n // \u521b\u5efa\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u7c7b\n public class AppInfoValidation : IValidateOptions\n {\n public ValidateOptionsResult Validate(string name, AppInfoOptions options)\n {\n if (!Regex.IsMatch(options.Version, @"^[0-9][0-9\\.]+[0-9]$"))\n {\n return ValidateOptionsResult.Fail("\u4e0d\u662f\u6709\u6548\u7684\u7248\u672c\u53f7");\n }\n\n return ValidateOptionsResult.Success;\n }\n }\n}\n')))),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"IConfigurableOptions"))," \u7ee7\u627f\u81ea ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"IConfigurableOptions")),"\uff0c\u4e5f\u5c31\u662f\u81ea\u5b9a\u4e49\u590d\u6742\u9a8c\u8bc1\u9ed8\u8ba4\u5177\u6709 ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"PostConfigure(TOptions options)"))," \u9009\u9879\u540e\u671f\u914d\u7f6e\u65b9\u6cd5\u3002\u5173\u4e8e\u300a",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"#227-%E9%80%89%E9%A1%B9%E5%90%8E%E6%9C%9F%E9%85%8D%E7%BD%AE"}),"4.3.7 \u9009\u9879\u540e\u671f\u914d\u7f6e"),"\u300b\u5c06\u5728\u4e0b\u4e00\u5c0f\u8282\u8bf4\u660e\u3002"))),Object(o.b)("h2",{id:"428-\u9009\u9879\u540e\u671f\u914d\u7f6e"},"4.2.8 \u9009\u9879\u540e\u671f\u914d\u7f6e"),Object(o.b)("p",null,"\u9009\u9879\u540e\u671f\u914d\u7f6e\u901a\u4fd7\u4e00\u70b9\u6765\u8bf4\uff0c\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u89e3\u6790\u503c\u6216\u8bbe\u5b9a\u9ed8\u8ba4\u503c/\u540e\u671f\u914d\u7f6e\u7b49\u3002"),Object(o.b)("p",null,"\u5728 ",Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u914d\u7f6e\u9009\u9879\u540e\u671f\u914d\u7f6e\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u7ee7\u627f ",Object(o.b)("inlineCode",{parentName:"p"},"IConfigurableOptions\n {\n [Required(ErrorMessage = "\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a")]\n public string Name { get; set; }\n [Required]\n public string Version { get; set; }\n [Required, MaxLength(100)]\n public string Company { get; set; }\n\n public void PostConfigure(AppInfoOptions options, IConfiguration configuration)\n {\n options.Name ??= "Fur";\n options.Version ??= "1.0.0";\n options.Version ??= "Baiqian";\n }\n }\n}\n')),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"IConfigurableOptions"))," \u7ee7\u627f\u81ea ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"IConfigurableOptions")),"\uff0c\u4e5f\u5c31\u662f\u81ea\u5b9a\u4e49\u590d\u6742\u9a8c\u8bc1\u9ed8\u8ba4\u5177\u6709 ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"PostConfigure(TOptions options, IConfiguration configuration)"))," \u9009\u9879\u540e\u671f\u914d\u7f6e\u65b9\u6cd5\u3002"))),Object(o.b)("h2",{id:"429-\u9009\u9879\u66f4\u6539\u901a\u77e5\uff08\u70ed\u66f4\u65b0\uff09"},"4.2.9 \u9009\u9879\u66f4\u6539\u901a\u77e5\uff08",Object(o.b)("inlineCode",{parentName:"h2"},"\u70ed\u66f4\u65b0"),"\uff09"),Object(o.b)("p",null,Object(o.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u63d0\u4f9b\u4e86\u975e\u5e38\u7b80\u5355\u4e14\u7075\u6d3b\u7684\u65b9\u5f0f\u76d1\u542c\u9009\u9879\u66f4\u6539\uff0c\u4e5f\u5c31\u662f ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"appsettings.json")," \u6216 \u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u53d1\u751f\u4efb\u4f55\u66f4\u6539\u90fd\u4f1a\u89e6\u53d1\u5904\u7406\u65b9\u6cd5"),"\u3002"),Object(o.b)("p",null,"\u4f7f\u7528\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u7ee7\u627f ",Object(o.b)("inlineCode",{parentName:"p"},"IConfigurableOptionsListener")," \u63a5\u53e3\u5e76\u5b9e\u73b0 ",Object(o.b)("inlineCode",{parentName:"p"},"void OnListener(TOptions options, IConfiguration configuration)")," \u65b9\u6cd5\u5373\u53ef\u3002"),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{5,12-16}","{5,12-16}":!0}),"using Fur.ConfigurableOptions;\n\nnamespace Fur.Application\n{\n public class AppInfoOptions : IConfigurableOptionsListener\n {\n public string Name { get; set; }\n public string Version { get; set; }\n public string Company { get; set; }\n }\n\n public void OnListener(AppInfoOptions options, IConfiguration configuration)\n {\n var name = options.Name; // \u5b9e\u65f6\u7684\u6700\u65b0\u503c\n var version = options.Version; // \u5b9e\u65f6\u7684\u6700\u65b0\u503c\n }\n\n public void PostConfigure(AppInfoOptions options, IConfiguration configuration)\n {\n }\n}\n")),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u7279\u522b\u8bf4\u660e")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"IConfigurableOptionsListener"))," \u7ee7\u627f\u81ea ",Object(o.b)("strong",{parentName:"p"},Object(o.b)("inlineCode",{parentName:"strong"},"IConfigurableOptions")),"\u3002"))),Object(o.b)("h2",{id:"4210-\u9009\u9879\u7684\u4f18\u7f3a\u70b9"},"4.2.10 \u9009\u9879\u7684\u4f18\u7f3a\u70b9"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("p",{parentName:"li"},"\u4f18\u70b9"),Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u5f3a\u7c7b\u578b\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},"\u63d0\u4f9b\u591a\u79cd\u8bfb\u53d6\u65b9\u5f0f"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\u70ed\u52a0\u8f7d"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\u8bbe\u7f6e\u9ed8\u8ba4\u503c/\u540e\u671f\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\u5728\u8fd0\u884c\u73af\u5883\u4e2d\u52a8\u6001\u914d\u7f6e"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\u9a8c\u8bc1\u914d\u7f6e\u6709\u6548\u6027"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\u66f4\u6539\u901a\u77e5"),Object(o.b)("li",{parentName:"ul"},"\u652f\u6301\u547d\u540d\u9009\u9879"))),Object(o.b)("li",{parentName:"ul"},Object(o.b)("p",{parentName:"li"},"\u7f3a\u70b9"),Object(o.b)("ul",{parentName:"li"},Object(o.b)("li",{parentName:"ul"},"\u9700\u8981\u5b9a\u4e49\u5bf9\u5e94\u7c7b\u578b"),Object(o.b)("li",{parentName:"ul"},"\u9700\u8981\u5728\u542f\u52a8\u65f6\u6ce8\u518c")))),Object(o.b)("h2",{id:"4211-\u53cd\u9988\u4e0e\u5efa\u8bae"},"4.2.11 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))),Object(o.b)("hr",null),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(o.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(o.b)("inlineCode",{parentName:"p"},"\u9009\u9879")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/configuration/options?view=aspnetcore-5.0"}),"ASP.NET Core - \u9009\u9879")," \u7ae0\u8282\u3002"))))}O.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return l})),t.d(n,"b",(function(){return m}));var a=t(0),i=t.n(a);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function p(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function r(e){for(var n=1;n=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var c=i.a.createContext({}),b=function(e){var n=i.a.useContext(c),t=n;return e&&(t="function"==typeof e?e(n):r(r({},n),e)),t},l=function(e){var n=b(e.components);return i.a.createElement(c.Provider,{value:n},e.children)},O={inlineCode:"code",wrapper:function(e){var n=e.children;return i.a.createElement(i.a.Fragment,{},n)}},u=i.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,o=e.originalType,p=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),l=b(t),u=a,m=l["".concat(p,".").concat(u)]||l[u]||O[u]||o;return t?i.a.createElement(m,r(r({ref:n},c),{},{components:t})):i.a.createElement(m,r({ref:n},c))}));function m(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var o=t.length,p=new Array(o);p[0]=u;var r={};for(var s in n)hasOwnProperty.call(n,s)&&(r[s]=n[s]);r.originalType=e,r.mdxType="string"==typeof e?e:a,p[1]=r;for(var c=2;c=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=o.a.createContext({}),u=function(e){var r=o.a.useContext(p),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},l=function(e){var r=u(e.components);return o.a.createElement(p.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,c=e.originalType,a=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),l=u(t),d=n,m=l["".concat(a,".").concat(d)]||l[d]||f[d]||c;return t?o.a.createElement(m,i(i({ref:r},p),{},{components:t})):o.a.createElement(m,i({ref:r},p))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var c=t.length,a=new Array(c);a[0]=d;var i={};for(var s in r)hasOwnProperty.call(r,s)&&(i[s]=r[s]);i.originalType=e,i.mdxType="string"==typeof e?e:n,a[1]=i;for(var p=2;p=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var u=o.a.createContext({}),p=function(e){var r=o.a.useContext(u),t=r;return e&&(t="function"==typeof e?e(r):i(i({},r),e)),t},l=function(e){var r=p(e.components);return o.a.createElement(u.Provider,{value:r},e.children)},f={inlineCode:"code",wrapper:function(e){var r=e.children;return o.a.createElement(o.a.Fragment,{},r)}},d=o.a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,c=e.originalType,a=e.parentName,u=s(e,["components","mdxType","originalType","parentName"]),l=p(t),d=n,m=l["".concat(a,".").concat(d)]||l[d]||f[d]||c;return t?o.a.createElement(m,i(i({ref:r},u),{},{components:t})):o.a.createElement(m,i({ref:r},u))}));function m(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var c=t.length,a=new Array(c);a[0]=d;var i={};for(var s in r)hasOwnProperty.call(r,s)&&(i[s]=r[s]);i.originalType=e,i.mdxType="string"==typeof e?e:n,a[1]=i;for(var u=2;u { user, user2 });\n\n// \u793a\u4f8b\u4e09\nrepository.Insert(new[] {user, user2 });\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.InsertAsync(user, user2);\n\n// \u793a\u4f8b\u4e8c\nawait repository.InsertAsync(new List { user, user2 });\n\n// \u793a\u4f8b\u4e09\nawait repository.InsertAsync(new[] {user, user2 });\n")),Object(o.b)("h2",{id:"954-\u65b0\u589e\u591a\u6761\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.5.4 \u65b0\u589e\u591a\u6761\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.InsertNow(user, user2);\n\n// \u793a\u4f8b\u4e8c\nrepository.InsertNow(new List { user, user2 });\n\n// \u793a\u4f8b\u4e09\nrepository.InsertNow(new[] {user, user2 });\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.InsertNowAsync(user, user2);\n\n// \u793a\u4f8b\u4e8c\nawait repository.InsertNowAsync(new List { user, user2 });\n\n// \u793a\u4f8b\u4e09\nawait repository.InsertNowAsync(new[] {user, user2 });\n")),Object(o.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(o.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u6240\u6709\u5e26 ",Object(o.b)("inlineCode",{parentName:"p"},"Now")," \u7ed3\u5c3e\u7684\u8868\u793a\u7acb\u5373\u63d0\u4ea4\u5230\u6570\u636e\u5e93\uff0c\u4e5f\u5c31\u662f\u7acb\u5373\u8c03\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"SaveChanges")," \u6216 ",Object(o.b)("inlineCode",{parentName:"p"},"SaveChangesAsync"),"\u3002"))),Object(o.b)("h2",{id:"955-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.5.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(o.b)("a",Object(r.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return b})),t.d(n,"b",(function(){return m}));var r=t(0),a=t.n(r);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function s(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function c(e){for(var n=1;n=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}var d=a.a.createContext({}),p=function(e){var n=a.a.useContext(d),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},b=function(e){var n=p(e.components);return a.a.createElement(d.Provider,{value:n},e.children)},u={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},l=a.a.forwardRef((function(e,n){var t=e.components,r=e.mdxType,o=e.originalType,s=e.parentName,d=i(e,["components","mdxType","originalType","parentName"]),b=p(t),l=r,m=b["".concat(s,".").concat(l)]||b[l]||u[l]||o;return t?a.a.createElement(m,c(c({ref:n},d),{},{components:t})):a.a.createElement(m,c({ref:n},d))}));function m(e,n){var t=arguments,r=n&&n.mdxType;if("string"==typeof e||r){var o=t.length,s=new Array(o);s[0]=l;var c={};for(var i in n)hasOwnProperty.call(n,i)&&(c[i]=n[i]);c.originalType=e,c.mdxType="string"==typeof e?e:r,s[1]=c;for(var d=2;d { user, user2 });\n\n// \u793a\u4f8b\u4e09\nrepository.Insert(new[] {user, user2 });\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.InsertAsync(user, user2);\n\n// \u793a\u4f8b\u4e8c\nawait repository.InsertAsync(new List { user, user2 });\n\n// \u793a\u4f8b\u4e09\nawait repository.InsertAsync(new[] {user, user2 });\n")),Object(o.b)("h2",{id:"954-\u65b0\u589e\u591a\u6761\uff08\u7acb\u5373\u63d0\u4ea4\uff09"},"9.5.4 \u65b0\u589e\u591a\u6761\uff08\u7acb\u5373\u63d0\u4ea4\uff09"),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"// ==== \u540c\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nrepository.InsertNow(user, user2);\n\n// \u793a\u4f8b\u4e8c\nrepository.InsertNow(new List { user, user2 });\n\n// \u793a\u4f8b\u4e09\nrepository.InsertNow(new[] {user, user2 });\n\n// ==== \u5f02\u6b65\u64cd\u4f5c ====\n\n// \u793a\u4f8b\u4e00\nawait repository.InsertNowAsync(user, user2);\n\n// \u793a\u4f8b\u4e8c\nawait repository.InsertNowAsync(new List { user, user2 });\n\n// \u793a\u4f8b\u4e09\nawait repository.InsertNowAsync(new[] {user, user2 });\n")),Object(o.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(o.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u5c0f\u77e5\u8bc6")),Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u6240\u6709\u5e26 ",Object(o.b)("inlineCode",{parentName:"p"},"Now")," \u7ed3\u5c3e\u7684\u8868\u793a\u7acb\u5373\u63d0\u4ea4\u5230\u6570\u636e\u5e93\uff0c\u4e5f\u5c31\u662f\u7acb\u5373\u8c03\u7528 ",Object(o.b)("inlineCode",{parentName:"p"},"SaveChanges")," \u6216 ",Object(o.b)("inlineCode",{parentName:"p"},"SaveChangesAsync"),"\u3002"))),Object(o.b)("h2",{id:"955-\u53cd\u9988\u4e0e\u5efa\u8bae"},"9.5.5 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(o.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(o.b)("h5",{parentName:"div"},Object(o.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(o.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(o.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(o.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(o.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(o.b)("a",Object(r.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))))}p.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return u})),t.d(n,"b",(function(){return m}));var r=t(0),a=t.n(r);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function s(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function c(e){for(var n=1;n=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}var d=a.a.createContext({}),p=function(e){var n=a.a.useContext(d),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},u=function(e){var n=p(e.components);return a.a.createElement(d.Provider,{value:n},e.children)},b={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},l=a.a.forwardRef((function(e,n){var t=e.components,r=e.mdxType,o=e.originalType,s=e.parentName,d=i(e,["components","mdxType","originalType","parentName"]),u=p(t),l=r,m=u["".concat(s,".").concat(l)]||u[l]||b[l]||o;return t?a.a.createElement(m,c(c({ref:n},d),{},{components:t})):a.a.createElement(m,c({ref:n},d))}));function m(e,n){var t=arguments,r=n&&n.mdxType;if("string"==typeof e||r){var o=t.length,s=new Array(o);s[0]=l;var c={};for(var i in n)hasOwnProperty.call(n,i)&&(c[i]=n[i]);c.originalType=e,c.mdxType="string"==typeof e?e:r,s[1]=c;for(var d=2;dappsettings.json \u4fe1\u606f",id:"4121-\u914d\u7f6e-appsettingsjson-\u4fe1\u606f",children:[]},{value:"4.1.2.2 \u8bfb\u53d6 appsettings.json \u4fe1\u606f",id:"4122-\u8bfb\u53d6-appsettingsjson-\u4fe1\u606f",children:[]},{value:"4.1.2.3 \u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f",id:"4123-\u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f",children:[]}]},{value:"4.1.3 \u8def\u5f84\u7b26 \u67e5\u627e\u8282\u70b9",id:"413-\u8def\u5f84\u7b26-\u67e5\u627e\u8282\u70b9",children:[]},{value:"4.1.4 \u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6",id:"414-\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6",children:[{value:"4.1.4.1 \u8bfb\u53d6 emailsetting.json \u914d\u7f6e",id:"4141-\u8bfb\u53d6-emailsettingjson-\u914d\u7f6e",children:[]}]},{value:"4.1.5 \u4e0d\u540c\u73af\u5883\u8bfb\u53d6",id:"415-\u4e0d\u540c\u73af\u5883\u8bfb\u53d6",children:[]},{value:"4.1.6 \u914d\u7f6e\u66f4\u6539\u901a\u77e5\uff08\u70ed\u66f4\u65b0\uff09",id:"416-\u914d\u7f6e\u66f4\u6539\u901a\u77e5\uff08\u70ed\u66f4\u65b0\uff09",children:[]},{value:"4.1.7 \u914d\u7f6e\u7684\u4f18\u7f3a\u70b9",id:"417-\u914d\u7f6e\u7684\u4f18\u7f3a\u70b9",children:[]},{value:"4.1.8 \u914d\u7f6e\u4f7f\u7528\u573a\u666f",id:"418-\u914d\u7f6e\u4f7f\u7528\u573a\u666f",children:[]},{value:"4.1.9 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"419-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],s={rightToc:p};function u(e){var n=e.components,t=Object(i.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},s,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u6e29\u99a8\u63d0\u793a")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u63a8\u8350\u4f7f\u7528 \u300a",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"/fur/docs/options"}),"4.2 \u9009\u9879"),"\u300b\u4ee3\u66ff\u672c\u7ae0\u8282\u529f\u80fd\u3002\uff08",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"#417-%E9%85%8D%E7%BD%AE%E7%9A%84%E4%BC%98%E7%BC%BA%E7%82%B9"}),"\u4e3a\u4ec0\u4e48"),"\uff09\uff1f"))),Object(r.b)("h2",{id:"411-\u4ec0\u4e48\u662f\u914d\u7f6e"},"4.1.1 \u4ec0\u4e48\u662f\u914d\u7f6e"),Object(r.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u914d\u7f6e\u5c06\u7cfb\u7edf\u5e94\u7528\u53ef\u52a8\u6001\u8c03\u914d\u7684\u9009\u9879\u653e\u5728\u7edf\u4e00\u5730\u65b9\u7ba1\u7406\uff0c\u901a\u8fc7\u4e0d\u540c\u7684\u914d\u7f6e\u8ba9\u7cfb\u7edf\u505a\u51fa\u52a8\u6001\u8c03\u6574\u3002"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u65f6\u9ed8\u8ba4\u52a0\u8f7d ",Object(r.b)("inlineCode",{parentName:"p"},"\u542f\u52a8\u9879\u76ee")," \u4e0b\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u4f5c\u4e3a\u5e94\u7528\u914d\u7f6e\u3002\u540c\u65f6\u8fd8\u652f\u6301",Object(r.b)("strong",{parentName:"p"},"\u4e0d\u540c\u7684\u8fd0\u884c\u73af\u5883"),"\u52a0\u8f7d\u5bf9\u5e94\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Development"),"\uff1a\u52a0\u8f7d ",Object(r.b)("inlineCode",{parentName:"li"},"appsettings.Development.json")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Staging"),"\uff1a\u52a0\u8f7d ",Object(r.b)("inlineCode",{parentName:"li"},"appsettings.Staging.json")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"{Environment}"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"appsettings.{Environment}.json"))),Object(r.b)("h2",{id:"412-\u914d\u7f6e\u7684\u4f7f\u7528"},"4.1.2 \u914d\u7f6e\u7684\u4f7f\u7528"),Object(r.b)("p",null,"\u5047\u8bbe\u6211\u4eec\u9700\u8981\u5728\u7cfb\u7edf\u8fd0\u884c\u65f6\u83b7\u53d6",Object(r.b)("strong",{parentName:"p"},"\u7cfb\u7edf\u540d\u79f0\u3001\u7248\u672c\u53f7\u53ca\u7248\u6743\u4fe1\u606f"),"\uff0c\u8fd9\u4e9b\u4fe1\u606f\u53ef\u80fd\u968f\u65f6\u53d8\u5316\u800c\u4e14\u9700\u8981\u5728\u591a\u4e2a\u5730\u65b9\u4f7f\u7528\u3002\u8fd9\u65f6\u5c31\u9700\u8981\u5c06\u8fd9\u4e9b\u4fe1\u606f\u914d\u7f6e\u8d77\u6765\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a"),Object(r.b)("h3",{id:"4121-\u914d\u7f6e-appsettingsjson-\u4fe1\u606f"},"4.1.2.1 \u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"h3"},"appsettings.json")," \u4fe1\u606f"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:"{2-6}","{2-6}":!0}),'{\n "AppInfo": {\n "Name": "Fur",\n "Version": "1.0.0",\n "Company": "Baiqian"\n }\n}\n')),Object(r.b)("h3",{id:"4122-\u8bfb\u53d6-appsettingsjson-\u4fe1\u606f"},"4.1.2.2 \u8bfb\u53d6 ",Object(r.b)("inlineCode",{parentName:"h3"},"appsettings.json")," \u4fe1\u606f"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u63d0\u4f9b\u4e86\u4e24\u79cd\u8bfb\u53d6\u65b9\u5f0f\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u4f9d\u8d56\u6ce8\u5165 ",Object(r.b)("inlineCode",{parentName:"li"},"IConfiguration")," \u5bf9\u8c61\u8bfb\u53d6"),Object(r.b)("li",{parentName:"ul"},"\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"li"},"App.Configuration[jsonKey]")," \u8bfb\u53d6")),Object(r.b)(o.a,{defaultValue:"App.Configuration[jsonKey]",values:[{label:"App.Configuration[jsonKey]",value:"App.Configuration[jsonKey]"},{label:"\u4f9d\u8d56\u6ce8\u5165\u65b9\u5f0f",value:"\u4f9d\u8d56\u6ce8\u5165\u65b9\u5f0f"}],mdxType:"Tabs"},Object(r.b)(c.a,{value:"App.Configuration[jsonKey]",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{11-13}","{11-13}":!0}),'using Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n public class DefaultController : ControllerBase\n {\n [HttpGet]\n public string Get()\n {\n return $@"\u540d\u79f0\uff1a{App.Configuration["AppInfo:Name"]}\uff0c\n \u7248\u672c\uff1a{App.Configuration["AppInfo:Version"]}\uff0c\n \u516c\u53f8\uff1a{App.Configuration["AppInfo:Company"]}";\n }\n }\n}\n'))),Object(r.b)(c.a,{value:"\u4f9d\u8d56\u6ce8\u5165\u65b9\u5f0f",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,10-15}","{2,10-15}":!0}),'using Microsoft.AspNetCore.Mvc;\nusing Microsoft.Extensions.Configuration;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n public class DefaultController : ControllerBase\n {\n [HttpGet]\n public string Get([FromServices] IConfiguration configuration)\n {\n return $@"\u540d\u79f0\uff1a{configuration["AppInfo:Name"]}\uff0c\n \u7248\u672c\uff1a{configuration["AppInfo:Version"]}\uff0c\n \u516c\u53f8\uff1a{configuration["AppInfo:Company"]}";\n }\n }\n}\n')))),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u4f9d\u8d56\u6ce8\u5165\u7684\u65b9\u5f0f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u901a\u8fc7\u4f9d\u8d56\u6ce8\u5165\u6ce8\u5165\u5b9e\u4f8b\u6709\u51e0\u79cd\u65b9\u5f0f\uff1a"),Object(r.b)("ul",{parentName:"div"},Object(r.b)("li",{parentName:"ul"},"\u6784\u9020\u51fd\u6570\u6ce8\u5165\u65b9\u5f0f")),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2}","{2}":!0}),"private readonly IConfiguration _configuration;\npublic DefaultController(IConfiguration configuration)\n{\n _configuration = configuration;\n}\n")),Object(r.b)("ul",{parentName:"div"},Object(r.b)("li",{parentName:"ul"},"\u53c2\u6570\u6ce8\u5165\u65b9\u5f0f ",Object(r.b)("inlineCode",{parentName:"li"},"[FromServices]"))),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),"public string Get([FromServices] IConfiguration configuration)\n{\n}\n")),Object(r.b)("ul",{parentName:"div"},Object(r.b)("li",{parentName:"ul"},"\u5c5e\u6027\u6ce8\u5165\u65b9\u5f0f")),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),"public IConfiguration Configuration { get; set; }\n")),Object(r.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u300a",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-3.1"}),"ASP.NET Core - \u4f9d\u8d56\u6ce8\u5165"),"\u300b \u77e5\u8bc6"))),Object(r.b)("h3",{id:"4123-\u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f"},"4.1.2.3 \u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u5728\u53ef\u4f9d\u8d56\u6ce8\u5165\u7c7b\u4e2d\uff0c\u4f9d\u8d56\u6ce8\u5165 ",Object(r.b)("inlineCode",{parentName:"li"},"IConfiguration")," \u8bfb\u53d6"),Object(r.b)("li",{parentName:"ul"},"\u5728\u9759\u6001\u7c7b/\u975e\u4f9d\u8d56\u6ce8\u5165\u7c7b\u4e2d\uff0c\u9009\u62e9 ",Object(r.b)("inlineCode",{parentName:"li"},"App.Configuration[jsonKey]")," \u8bfb\u53d6")),Object(r.b)("h2",{id:"413-\u8def\u5f84\u7b26-\u67e5\u627e\u8282\u70b9"},"4.1.3 ",Object(r.b)("inlineCode",{parentName:"h2"},"\u8def\u5f84\u7b26")," \u67e5\u627e\u8282\u70b9"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u4e2d\uff0c\u914d\u7f6e\u91c7\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},":")," \u5206\u9694\u7b26\u6765\u8bfb\u53d6\u5206\u5c42\u914d\u7f6e\u6570\u636e\u3002\u5982\u4e0a\u8ff0\u4f8b\u5b50\u4e2d\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"AppInfo:Name"),"\u3002\u5982\u6709\u66f4\u591a\u5c42\u7ea7\u6570\u636e\u5219\u53ea\u9700\u8981\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},":")," \u8fdb\u5165\u4e0b\u4e00\u5c42\u8282\u70b9\u5373\u53ef\u3002"),Object(r.b)("p",null,"\u5047\u8bbe\u6211\u4eec\u6709\u4ee5\u4e0b\u914d\u7f6e\u4fe1\u606f\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:"{5-12}","{5-12}":!0}),'{\n "AppInfo": {\n "Name": "Fur",\n "Version": "1.0.0",\n "Company": {\n "Name": "Baiqian",\n "Address": {\n "City": "\u4e2d\u56fd",\n "Province": "\u5e7f\u4e1c\u7701",\n "Detail": "\u4e2d\u5c71\u5e02\u4e1c\u533a\u7d2b\u9a6c\u516c\u56ed\u897f\u95e8"\n }\n }\n }\n}\n')),Object(r.b)(o.a,{defaultValue:"two",values:[{label:"\u8bfb\u53d6\u7b2c\u4e8c\u5c42",value:"two"},{label:"\u8bfb\u53d6\u7b2c\u4e09\u5c42",value:"three"},{label:"\u8bfb\u53d6\u7b2c\u56db\u5c42",value:"four"},{label:"\u8bfb\u53d6\u7b2cN\u5c42",value:"n"}],mdxType:"Tabs"},Object(r.b)(c.a,{value:"two",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'var companyName = App.Configuration["AppInfo:Name"]; // => Fur\n'))),Object(r.b)(c.a,{value:"three",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'var companyName = App.Configuration["AppInfo:Company:Name"]; // => Baiqian\n'))),Object(r.b)(c.a,{value:"four",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'var companyName = App.Configuration["AppInfo:Company:Address:Detail"]; // => \u4e2d\u5c71\u5e02\u4e1c\u533a\u7d2b\u9a6c\u516c\u56ed\u897f\u95e8\n'))),Object(r.b)(c.a,{value:"n",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'var companyName = App.Configuration["AppInfo:Tier2:Tier3:Tier4...Tiern1:Tiern3..."]; // => \u4e2d\u5c71\u5e02\u4e1c\u533a\u7d2b\u9a6c\u516c\u56ed\u897f\u95e8\n')))),Object(r.b)("h2",{id:"414-\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6"},"4.1.4 \u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6"),Object(r.b)("p",null,"\u5927\u591a\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u7684\u914d\u7f6e\u53ea\u9700\u8981\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u4e2d\u914d\u7f6e\u5373\u53ef\uff0c\u4f46\u4e00\u4e9b\u7279\u6b8a\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5e0c\u671b\u67d0\u4e9b\u7ec4\u4ef6\u6216\u529f\u80fd\u62e5\u6709\u72ec\u7acb\u7684\u914d\u7f6e\uff0c\u8fd9\u4e2a\u65f6\u5019\u5c31\u9700\u8981\u7528\u5230\u81ea\u5b9a\u4e49\u914d\u7f6e\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u76ee\u524d\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"p"},".json")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},".xml")," \u4e24\u79cd\u65b9\u5f0f\u914d\u7f6e\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:'{2-13} title="Fur.Web.Entry/emailsetting.json"',"{2-13}":!0,title:'"Fur.Web.Entry/emailsetting.json"'}),'{\n "outlook": {\n "smtp": {\n "server": "smtp.office365.com",\n "port": "587",\n "ssl": "STARTTLS"\n },\n "pop": {\n "server": "outlook.office365.com",\n "port": "995",\n "ssl": "TLS"\n }\n }\n}\n')),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-xml"}),'\n\n MyXMLFile Value\n \n Title from MyXMLFile\n Name from MyXMLFile\n \n \n \n Information\n Warning\n \n \n\n')),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"xml \u914d\u7f6e\u4e8b\u9879")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5982\u679c\u91c7\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"xml")," \u914d\u7f6e\uff0c\u90a3\u4e48\u6587\u4ef6\u540d\u5fc5\u987b\u4ee5 ",Object(r.b)("inlineCode",{parentName:"p"},".config.xml")," \u7ed3\u5c3e\uff08\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff09\u3002"))),Object(r.b)("p",null,"\u540c\u65f6 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u7684\u65b9\u5f0f\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u8bfb\u53d6\uff0c\u5982\uff1a"),Object(r.b)("h3",{id:"4141-\u8bfb\u53d6-emailsettingjson-\u914d\u7f6e"},"4.1.4.1 \u8bfb\u53d6 ",Object(r.b)("inlineCode",{parentName:"h3"},"emailsetting.json")," \u914d\u7f6e"),Object(r.b)("p",null,"\u8bfb\u53d6\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u548c\u8bfb\u53d6 ",Object(r.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u4e00\u81f4\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u4ece\u591a\u4e2a\u914d\u7f6e\u6587\u4ef6\u4e2d\u8bfb\u53d6\u8f93\u5165\uff0c\u5982\uff1a"),Object(r.b)(o.a,{defaultValue:"jtl",values:[{label:"App.Configuration[jsonKey]",value:"jtl"},{label:"\u4f9d\u8d56\u6ce8\u5165\u65b9\u5f0f",value:"ylzr"}],mdxType:"Tabs"},Object(r.b)(c.a,{value:"jtl",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'var smtpServer = App.Configuration["outlook:smtp:server"]; // => smtp.office365.com\n'))),Object(r.b)(c.a,{value:"ylzr",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'var smtpServer = _configuration["outlook:smtp:server"]; // => smtp.office365.com\n')))),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u8bf4\u660e")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4f1a\u5728\u542f\u52a8\u65f6\u81ea\u52a8\u626b\u63cf\u6bcf\u4e00\u4e2a\u9879\u76ee\u5c42\u6839\u76ee\u5f55\u4e0b\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"*.json")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"*.xml")," \u6587\u4ef6\u52a0\u5165\u914d\u7f6e\u4e2d\u3002\u6240\u4ee5\u65e0\u9700\u624b\u5de5\u914d\u7f6e\u3002"))),Object(r.b)("h2",{id:"415-\u4e0d\u540c\u73af\u5883\u8bfb\u53d6"},"4.1.5 \u4e0d\u540c\u73af\u5883\u8bfb\u53d6"),Object(r.b)("p",null,"\u5728\u5b9e\u9645\u5e94\u7528\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u6839\u636e\u4e0d\u540c\u7684\u73af\u5883\u52a0\u8f7d\u4e0d\u540c\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"p"},"\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32"),"\u3002"),Object(r.b)("p",null,"\u8fd9\u65f6\u6211\u4eec\u53ea\u9700\u8981\u9075\u5faa\u7279\u5b9a\u547d\u540d\u89c4\u8303 ",Object(r.b)("inlineCode",{parentName:"p"},"{name}.{Environment}.json")," \u5373\u53ef\u3002\u5982\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"appsettings.Development.json")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"appsettings.Staging.json")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"appsettings.Production.json")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"emailsetting.Development.json")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"emailsetting.Staging.json")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"emailsetting.Production.json"))),Object(r.b)("p",null,"\u8fd9\u65f6\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u4f1a\u5728\u5e94\u7528\u542f\u52a8\u65f6\u81ea\u52a8\u52a0\u8f7d\u4e0d\u540c\u73af\u5883\u7684\u914d\u7f6e\u6587\u4ef6\u3002"),Object(r.b)("h2",{id:"416-\u914d\u7f6e\u66f4\u6539\u901a\u77e5\uff08\u70ed\u66f4\u65b0\uff09"},"4.1.6 \u914d\u7f6e\u66f4\u6539\u901a\u77e5\uff08",Object(r.b)("inlineCode",{parentName:"h2"},"\u70ed\u66f4\u65b0"),"\uff09"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},".NET Core")," \u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u914d\u7f6e\u652f\u6301\u66f4\u6539\u901a\u77e5\uff0c\u4e5f\u5c31\u662f\u70ed\u66f4\u65b0\u64cd\u4f5c\u3002",Object(r.b)("strong",{parentName:"p"},"\u4e00\u65e6\u76d1\u542c\u5230 ",Object(r.b)("inlineCode",{parentName:"strong"},"appsetting.json")," \u6216\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u53d1\u751f\u53d8\u52a8\uff0c\u5c31\u4f1a\u89e6\u53d1 ",Object(r.b)("inlineCode",{parentName:"strong"},"OnChange")," \u65b9\u6cd5"),"\u3002\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,4-5}","{2,4-5}":!0}),'var appInfoConfiguration = App.Configuration["AppInfo"];\nChangeToken.OnChange(() => appInfoConfiguration.GetReloadToken(), () =>\n{\n var name = appInfoConfiguration["Name"]; // \u5b9e\u65f6\u7684\u6700\u65b0\u503c\n var version = appInfoConfiguration["Version"]; // \u5b9e\u65f6\u7684\u6700\u65b0\u503c\n});\n')),Object(r.b)("h2",{id:"417-\u914d\u7f6e\u7684\u4f18\u7f3a\u70b9"},"4.1.7 \u914d\u7f6e\u7684\u4f18\u7f3a\u70b9"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u4f18\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u80fd\u591f\u5728\u7cfb\u7edf\u8fd0\u884c\u65f6\u5feb\u901f\u8bfb\u53d6"),Object(r.b)("li",{parentName:"ul"},"\u65e0\u9700\u989d\u5916\u914d\u7f6e"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u7f3a\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u5b58\u5728\u91cd\u590d\u8bfb\u53d6"),Object(r.b)("li",{parentName:"ul"},"\u901a\u8fc7\u786c\u7f16\u7801\u5b57\u7b26\u4e32\u8bfb\u53d6\uff0c\u5bb9\u6613\u51fa\u9519"),Object(r.b)("li",{parentName:"ul"},"\u4e0d\u80fd\u8bbe\u7f6e\u9ed8\u8ba4\u503c"),Object(r.b)("li",{parentName:"ul"},"\u4e0d\u80fd\u5728\u8fd0\u884c\u73af\u5883\u4e2d\u52a8\u6001\u914d\u7f6e"),Object(r.b)("li",{parentName:"ul"},"\u4e0d\u80fd\u9a8c\u8bc1\u914d\u7f6e\u6709\u6548\u6027"),Object(r.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\u66f4\u6539\u901a\u77e5")))),Object(r.b)("h2",{id:"418-\u914d\u7f6e\u4f7f\u7528\u573a\u666f"},"4.1.8 \u914d\u7f6e\u4f7f\u7528\u573a\u666f"),Object(r.b)("p",null,"\u5982\u679c\u53ea\u9700\u8981",Object(r.b)("strong",{parentName:"p"},"\u4e00\u6b21\u6027\u8bfb\u53d6"),"\u914d\u7f6e\u4fe1\u606f\uff0c\u5219\u4f7f\u7528\u914d\u7f6e\uff0c\u5426\u5219\u5e94\u8be5\u4f7f\u7528 \u300a",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"/fur/docs/options"}),"4.2 \u9009\u9879"),"\u300b\u4ee3\u66ff\u3002"),Object(r.b)("h2",{id:"419-\u53cd\u9988\u4e0e\u5efa\u8bae"},"4.1.9 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))),Object(r.b)("hr",null),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(r.b)("inlineCode",{parentName:"p"},"\u914d\u7f6e")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/configuration/?view=aspnetcore-5.0"}),"ASP.NET Core - \u914d\u7f6e")," \u7ae0\u8282\u3002"))))}u.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return s})),t.d(n,"b",(function(){return j}));var a=t(0),i=t.n(a);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function c(e){for(var n=1;n=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var l=i.a.createContext({}),p=function(e){var n=i.a.useContext(l),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},s=function(e){var n=p(e.components);return i.a.createElement(l.Provider,{value:n},e.children)},u={inlineCode:"code",wrapper:function(e){var n=e.children;return i.a.createElement(i.a.Fragment,{},n)}},m=i.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,r=e.originalType,o=e.parentName,l=b(e,["components","mdxType","originalType","parentName"]),s=p(t),m=a,j=s["".concat(o,".").concat(m)]||s[m]||u[m]||r;return t?i.a.createElement(j,c(c({ref:n},l),{},{components:t})):i.a.createElement(j,c({ref:n},l))}));function j(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var r=t.length,o=new Array(r);o[0]=m;var c={};for(var b in n)hasOwnProperty.call(n,b)&&(c[b]=n[b]);c.originalType=e,c.mdxType="string"==typeof e?e:a,o[1]=c;for(var l=2;lappsettings.json \u4fe1\u606f",id:"4121-\u914d\u7f6e-appsettingsjson-\u4fe1\u606f",children:[]},{value:"4.1.2.2 \u8bfb\u53d6 appsettings.json \u4fe1\u606f",id:"4122-\u8bfb\u53d6-appsettingsjson-\u4fe1\u606f",children:[]},{value:"4.1.2.3 \u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f",id:"4123-\u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f",children:[]}]},{value:"4.1.3 \u8def\u5f84\u7b26 \u67e5\u627e\u8282\u70b9",id:"413-\u8def\u5f84\u7b26-\u67e5\u627e\u8282\u70b9",children:[]},{value:"4.1.4 \u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6",id:"414-\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6",children:[{value:"4.1.4.1 \u8bfb\u53d6 emailsetting.json \u914d\u7f6e",id:"4141-\u8bfb\u53d6-emailsettingjson-\u914d\u7f6e",children:[]}]},{value:"4.1.5 \u4e0d\u540c\u73af\u5883\u8bfb\u53d6",id:"415-\u4e0d\u540c\u73af\u5883\u8bfb\u53d6",children:[]},{value:"4.1.6 \u914d\u7f6e\u66f4\u6539\u901a\u77e5\uff08\u70ed\u66f4\u65b0\uff09",id:"416-\u914d\u7f6e\u66f4\u6539\u901a\u77e5\uff08\u70ed\u66f4\u65b0\uff09",children:[]},{value:"4.1.7 \u914d\u7f6e\u7684\u4f18\u7f3a\u70b9",id:"417-\u914d\u7f6e\u7684\u4f18\u7f3a\u70b9",children:[]},{value:"4.1.8 \u914d\u7f6e\u4f7f\u7528\u573a\u666f",id:"418-\u914d\u7f6e\u4f7f\u7528\u573a\u666f",children:[]},{value:"4.1.9 \u53cd\u9988\u4e0e\u5efa\u8bae",id:"419-\u53cd\u9988\u4e0e\u5efa\u8bae",children:[]}],s={rightToc:p};function u(e){var n=e.components,t=Object(i.a)(e,["components"]);return Object(r.b)("wrapper",Object(a.a)({},s,t,{components:n,mdxType:"MDXLayout"}),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u6e29\u99a8\u63d0\u793a")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u63a8\u8350\u4f7f\u7528 \u300a",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"/docs/options"}),"4.2 \u9009\u9879"),"\u300b\u4ee3\u66ff\u672c\u7ae0\u8282\u529f\u80fd\u3002\uff08",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"#417-%E9%85%8D%E7%BD%AE%E7%9A%84%E4%BC%98%E7%BC%BA%E7%82%B9"}),"\u4e3a\u4ec0\u4e48"),"\uff09\uff1f"))),Object(r.b)("h2",{id:"411-\u4ec0\u4e48\u662f\u914d\u7f6e"},"4.1.1 \u4ec0\u4e48\u662f\u914d\u7f6e"),Object(r.b)("p",null,"\u7b80\u5355\u6765\u8bf4\uff0c\u914d\u7f6e\u5c06\u7cfb\u7edf\u5e94\u7528\u53ef\u52a8\u6001\u8c03\u914d\u7684\u9009\u9879\u653e\u5728\u7edf\u4e00\u5730\u65b9\u7ba1\u7406\uff0c\u901a\u8fc7\u4e0d\u540c\u7684\u914d\u7f6e\u8ba9\u7cfb\u7edf\u505a\u51fa\u52a8\u6001\u8c03\u6574\u3002"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u65f6\u9ed8\u8ba4\u52a0\u8f7d ",Object(r.b)("inlineCode",{parentName:"p"},"\u542f\u52a8\u9879\u76ee")," \u4e0b\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u4f5c\u4e3a\u5e94\u7528\u914d\u7f6e\u3002\u540c\u65f6\u8fd8\u652f\u6301",Object(r.b)("strong",{parentName:"p"},"\u4e0d\u540c\u7684\u8fd0\u884c\u73af\u5883"),"\u52a0\u8f7d\u5bf9\u5e94\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Development"),"\uff1a\u52a0\u8f7d ",Object(r.b)("inlineCode",{parentName:"li"},"appsettings.Development.json")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"Staging"),"\uff1a\u52a0\u8f7d ",Object(r.b)("inlineCode",{parentName:"li"},"appsettings.Staging.json")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"{Environment}"),"\uff1a",Object(r.b)("inlineCode",{parentName:"li"},"appsettings.{Environment}.json"))),Object(r.b)("h2",{id:"412-\u914d\u7f6e\u7684\u4f7f\u7528"},"4.1.2 \u914d\u7f6e\u7684\u4f7f\u7528"),Object(r.b)("p",null,"\u5047\u8bbe\u6211\u4eec\u9700\u8981\u5728\u7cfb\u7edf\u8fd0\u884c\u65f6\u83b7\u53d6",Object(r.b)("strong",{parentName:"p"},"\u7cfb\u7edf\u540d\u79f0\u3001\u7248\u672c\u53f7\u53ca\u7248\u6743\u4fe1\u606f"),"\uff0c\u8fd9\u4e9b\u4fe1\u606f\u53ef\u80fd\u968f\u65f6\u53d8\u5316\u800c\u4e14\u9700\u8981\u5728\u591a\u4e2a\u5730\u65b9\u4f7f\u7528\u3002\u8fd9\u65f6\u5c31\u9700\u8981\u5c06\u8fd9\u4e9b\u4fe1\u606f\u914d\u7f6e\u8d77\u6765\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a"),Object(r.b)("h3",{id:"4121-\u914d\u7f6e-appsettingsjson-\u4fe1\u606f"},"4.1.2.1 \u914d\u7f6e ",Object(r.b)("inlineCode",{parentName:"h3"},"appsettings.json")," \u4fe1\u606f"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:"{2-6}","{2-6}":!0}),'{\n "AppInfo": {\n "Name": "Fur",\n "Version": "1.0.0",\n "Company": "Baiqian"\n }\n}\n')),Object(r.b)("h3",{id:"4122-\u8bfb\u53d6-appsettingsjson-\u4fe1\u606f"},"4.1.2.2 \u8bfb\u53d6 ",Object(r.b)("inlineCode",{parentName:"h3"},"appsettings.json")," \u4fe1\u606f"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4e2d\uff0c\u63d0\u4f9b\u4e86\u4e24\u79cd\u8bfb\u53d6\u65b9\u5f0f\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u4f9d\u8d56\u6ce8\u5165 ",Object(r.b)("inlineCode",{parentName:"li"},"IConfiguration")," \u5bf9\u8c61\u8bfb\u53d6"),Object(r.b)("li",{parentName:"ul"},"\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"li"},"App.Configuration[jsonKey]")," \u8bfb\u53d6")),Object(r.b)(o.a,{defaultValue:"App.Configuration[jsonKey]",values:[{label:"App.Configuration[jsonKey]",value:"App.Configuration[jsonKey]"},{label:"\u4f9d\u8d56\u6ce8\u5165\u65b9\u5f0f",value:"\u4f9d\u8d56\u6ce8\u5165\u65b9\u5f0f"}],mdxType:"Tabs"},Object(r.b)(c.a,{value:"App.Configuration[jsonKey]",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{11-13}","{11-13}":!0}),'using Microsoft.AspNetCore.Mvc;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n public class DefaultController : ControllerBase\n {\n [HttpGet]\n public string Get()\n {\n return $@"\u540d\u79f0\uff1a{App.Configuration["AppInfo:Name"]}\uff0c\n \u7248\u672c\uff1a{App.Configuration["AppInfo:Version"]}\uff0c\n \u516c\u53f8\uff1a{App.Configuration["AppInfo:Company"]}";\n }\n }\n}\n'))),Object(r.b)(c.a,{value:"\u4f9d\u8d56\u6ce8\u5165\u65b9\u5f0f",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,10-15}","{2,10-15}":!0}),'using Microsoft.AspNetCore.Mvc;\nusing Microsoft.Extensions.Configuration;\n\nnamespace Fur.Web.Entry.Controllers\n{\n [Route("api/[controller]")]\n public class DefaultController : ControllerBase\n {\n [HttpGet]\n public string Get([FromServices] IConfiguration configuration)\n {\n return $@"\u540d\u79f0\uff1a{configuration["AppInfo:Name"]}\uff0c\n \u7248\u672c\uff1a{configuration["AppInfo:Version"]}\uff0c\n \u516c\u53f8\uff1a{configuration["AppInfo:Company"]}";\n }\n }\n}\n')))),Object(r.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"\u4f9d\u8d56\u6ce8\u5165\u7684\u65b9\u5f0f")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u901a\u8fc7\u4f9d\u8d56\u6ce8\u5165\u6ce8\u5165\u5b9e\u4f8b\u6709\u51e0\u79cd\u65b9\u5f0f\uff1a"),Object(r.b)("ul",{parentName:"div"},Object(r.b)("li",{parentName:"ul"},"\u6784\u9020\u51fd\u6570\u6ce8\u5165\u65b9\u5f0f")),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2}","{2}":!0}),"private readonly IConfiguration _configuration;\npublic DefaultController(IConfiguration configuration)\n{\n _configuration = configuration;\n}\n")),Object(r.b)("ul",{parentName:"div"},Object(r.b)("li",{parentName:"ul"},"\u53c2\u6570\u6ce8\u5165\u65b9\u5f0f ",Object(r.b)("inlineCode",{parentName:"li"},"[FromServices]"))),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),"public string Get([FromServices] IConfiguration configuration)\n{\n}\n")),Object(r.b)("ul",{parentName:"div"},Object(r.b)("li",{parentName:"ul"},"\u5c5e\u6027\u6ce8\u5165\u65b9\u5f0f")),Object(r.b)("pre",{parentName:"div"},Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{1}","{1}":!0}),"public IConfiguration Configuration { get; set; }\n")),Object(r.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u300a",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-3.1"}),"ASP.NET Core - \u4f9d\u8d56\u6ce8\u5165"),"\u300b \u77e5\u8bc6"))),Object(r.b)("h3",{id:"4123-\u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f"},"4.1.2.3 \u5982\u4f55\u9009\u62e9\u8bfb\u53d6\u65b9\u5f0f"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},"\u5728\u53ef\u4f9d\u8d56\u6ce8\u5165\u7c7b\u4e2d\uff0c\u4f9d\u8d56\u6ce8\u5165 ",Object(r.b)("inlineCode",{parentName:"li"},"IConfiguration")," \u8bfb\u53d6"),Object(r.b)("li",{parentName:"ul"},"\u5728\u9759\u6001\u7c7b/\u975e\u4f9d\u8d56\u6ce8\u5165\u7c7b\u4e2d\uff0c\u9009\u62e9 ",Object(r.b)("inlineCode",{parentName:"li"},"App.Configuration[jsonKey]")," \u8bfb\u53d6")),Object(r.b)("h2",{id:"413-\u8def\u5f84\u7b26-\u67e5\u627e\u8282\u70b9"},"4.1.3 ",Object(r.b)("inlineCode",{parentName:"h2"},"\u8def\u5f84\u7b26")," \u67e5\u627e\u8282\u70b9"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u4e2d\uff0c\u914d\u7f6e\u91c7\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},":")," \u5206\u9694\u7b26\u6765\u8bfb\u53d6\u5206\u5c42\u914d\u7f6e\u6570\u636e\u3002\u5982\u4e0a\u8ff0\u4f8b\u5b50\u4e2d\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"AppInfo:Name"),"\u3002\u5982\u6709\u66f4\u591a\u5c42\u7ea7\u6570\u636e\u5219\u53ea\u9700\u8981\u901a\u8fc7 ",Object(r.b)("inlineCode",{parentName:"p"},":")," \u8fdb\u5165\u4e0b\u4e00\u5c42\u8282\u70b9\u5373\u53ef\u3002"),Object(r.b)("p",null,"\u5047\u8bbe\u6211\u4eec\u6709\u4ee5\u4e0b\u914d\u7f6e\u4fe1\u606f\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:"{5-12}","{5-12}":!0}),'{\n "AppInfo": {\n "Name": "Fur",\n "Version": "1.0.0",\n "Company": {\n "Name": "Baiqian",\n "Address": {\n "City": "\u4e2d\u56fd",\n "Province": "\u5e7f\u4e1c\u7701",\n "Detail": "\u4e2d\u5c71\u5e02\u4e1c\u533a\u7d2b\u9a6c\u516c\u56ed\u897f\u95e8"\n }\n }\n }\n}\n')),Object(r.b)(o.a,{defaultValue:"two",values:[{label:"\u8bfb\u53d6\u7b2c\u4e8c\u5c42",value:"two"},{label:"\u8bfb\u53d6\u7b2c\u4e09\u5c42",value:"three"},{label:"\u8bfb\u53d6\u7b2c\u56db\u5c42",value:"four"},{label:"\u8bfb\u53d6\u7b2cN\u5c42",value:"n"}],mdxType:"Tabs"},Object(r.b)(c.a,{value:"two",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'var companyName = App.Configuration["AppInfo:Name"]; // => Fur\n'))),Object(r.b)(c.a,{value:"three",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'var companyName = App.Configuration["AppInfo:Company:Name"]; // => Baiqian\n'))),Object(r.b)(c.a,{value:"four",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'var companyName = App.Configuration["AppInfo:Company:Address:Detail"]; // => \u4e2d\u5c71\u5e02\u4e1c\u533a\u7d2b\u9a6c\u516c\u56ed\u897f\u95e8\n'))),Object(r.b)(c.a,{value:"n",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'var companyName = App.Configuration["AppInfo:Tier2:Tier3:Tier4...Tiern1:Tiern3..."]; // => \u4e2d\u5c71\u5e02\u4e1c\u533a\u7d2b\u9a6c\u516c\u56ed\u897f\u95e8\n')))),Object(r.b)("h2",{id:"414-\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6"},"4.1.4 \u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6"),Object(r.b)("p",null,"\u5927\u591a\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u7684\u914d\u7f6e\u53ea\u9700\u8981\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u4e2d\u914d\u7f6e\u5373\u53ef\uff0c\u4f46\u4e00\u4e9b\u7279\u6b8a\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5e0c\u671b\u67d0\u4e9b\u7ec4\u4ef6\u6216\u529f\u80fd\u62e5\u6709\u72ec\u7acb\u7684\u914d\u7f6e\uff0c\u8fd9\u4e2a\u65f6\u5019\u5c31\u9700\u8981\u7528\u5230\u81ea\u5b9a\u4e49\u914d\u7f6e\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u76ee\u524d\u652f\u6301 ",Object(r.b)("inlineCode",{parentName:"p"},".json")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},".xml")," \u4e24\u79cd\u65b9\u5f0f\u914d\u7f6e\uff0c\u5982\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-json",metastring:'{2-13} title="Fur.Web.Entry/emailsetting.json"',"{2-13}":!0,title:'"Fur.Web.Entry/emailsetting.json"'}),'{\n "outlook": {\n "smtp": {\n "server": "smtp.office365.com",\n "port": "587",\n "ssl": "STARTTLS"\n },\n "pop": {\n "server": "outlook.office365.com",\n "port": "995",\n "ssl": "TLS"\n }\n }\n}\n')),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-xml"}),'\n\n MyXMLFile Value\n \n Title from MyXMLFile\n Name from MyXMLFile\n \n \n \n Information\n Warning\n \n \n\n')),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"xml \u914d\u7f6e\u4e8b\u9879")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u5982\u679c\u91c7\u7528 ",Object(r.b)("inlineCode",{parentName:"p"},"xml")," \u914d\u7f6e\uff0c\u90a3\u4e48\u6587\u4ef6\u540d\u5fc5\u987b\u4ee5 ",Object(r.b)("inlineCode",{parentName:"p"},".config.xml")," \u7ed3\u5c3e\uff08\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff09\u3002"))),Object(r.b)("p",null,"\u540c\u65f6 ",Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u63d0\u4f9b\u4e86\u975e\u5e38\u7075\u6d3b\u7684\u65b9\u5f0f\u652f\u6301\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u8bfb\u53d6\uff0c\u5982\uff1a"),Object(r.b)("h3",{id:"4141-\u8bfb\u53d6-emailsettingjson-\u914d\u7f6e"},"4.1.4.1 \u8bfb\u53d6 ",Object(r.b)("inlineCode",{parentName:"h3"},"emailsetting.json")," \u914d\u7f6e"),Object(r.b)("p",null,"\u8bfb\u53d6\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u548c\u8bfb\u53d6 ",Object(r.b)("inlineCode",{parentName:"p"},"appsettings.json")," \u4e00\u81f4\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u4ece\u591a\u4e2a\u914d\u7f6e\u6587\u4ef6\u4e2d\u8bfb\u53d6\u8f93\u5165\uff0c\u5982\uff1a"),Object(r.b)(o.a,{defaultValue:"jtl",values:[{label:"App.Configuration[jsonKey]",value:"jtl"},{label:"\u4f9d\u8d56\u6ce8\u5165\u65b9\u5f0f",value:"ylzr"}],mdxType:"Tabs"},Object(r.b)(c.a,{value:"jtl",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'var smtpServer = App.Configuration["outlook:smtp:server"]; // => smtp.office365.com\n'))),Object(r.b)(c.a,{value:"ylzr",mdxType:"TabItem"},Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs"}),'var smtpServer = _configuration["outlook:smtp:server"]; // => smtp.office365.com\n')))),Object(r.b)("div",{className:"admonition admonition-important alert alert--info"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u8bf4\u660e")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},Object(r.b)("inlineCode",{parentName:"p"},"Fur")," \u6846\u67b6\u4f1a\u5728\u542f\u52a8\u65f6\u81ea\u52a8\u626b\u63cf\u6bcf\u4e00\u4e2a\u9879\u76ee\u5c42\u6839\u76ee\u5f55\u4e0b\u7684 ",Object(r.b)("inlineCode",{parentName:"p"},"*.json")," \u548c ",Object(r.b)("inlineCode",{parentName:"p"},"*.xml")," \u6587\u4ef6\u52a0\u5165\u914d\u7f6e\u4e2d\u3002\u6240\u4ee5\u65e0\u9700\u624b\u5de5\u914d\u7f6e\u3002"))),Object(r.b)("h2",{id:"415-\u4e0d\u540c\u73af\u5883\u8bfb\u53d6"},"4.1.5 \u4e0d\u540c\u73af\u5883\u8bfb\u53d6"),Object(r.b)("p",null,"\u5728\u5b9e\u9645\u5e94\u7528\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u6839\u636e\u4e0d\u540c\u7684\u73af\u5883\u52a0\u8f7d\u4e0d\u540c\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5982 ",Object(r.b)("inlineCode",{parentName:"p"},"\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32"),"\u3002"),Object(r.b)("p",null,"\u8fd9\u65f6\u6211\u4eec\u53ea\u9700\u8981\u9075\u5faa\u7279\u5b9a\u547d\u540d\u89c4\u8303 ",Object(r.b)("inlineCode",{parentName:"p"},"{name}.{Environment}.json")," \u5373\u53ef\u3002\u5982\uff1a"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"appsettings.Development.json")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"appsettings.Staging.json")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"appsettings.Production.json")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"emailsetting.Development.json")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"emailsetting.Staging.json")),Object(r.b)("li",{parentName:"ul"},Object(r.b)("inlineCode",{parentName:"li"},"emailsetting.Production.json"))),Object(r.b)("p",null,"\u8fd9\u65f6\uff0c",Object(r.b)("inlineCode",{parentName:"p"},"ASP.NET Core")," \u4f1a\u5728\u5e94\u7528\u542f\u52a8\u65f6\u81ea\u52a8\u52a0\u8f7d\u4e0d\u540c\u73af\u5883\u7684\u914d\u7f6e\u6587\u4ef6\u3002"),Object(r.b)("h2",{id:"416-\u914d\u7f6e\u66f4\u6539\u901a\u77e5\uff08\u70ed\u66f4\u65b0\uff09"},"4.1.6 \u914d\u7f6e\u66f4\u6539\u901a\u77e5\uff08",Object(r.b)("inlineCode",{parentName:"h2"},"\u70ed\u66f4\u65b0"),"\uff09"),Object(r.b)("p",null,"\u5728 ",Object(r.b)("inlineCode",{parentName:"p"},".NET Core")," \u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u914d\u7f6e\u652f\u6301\u66f4\u6539\u901a\u77e5\uff0c\u4e5f\u5c31\u662f\u70ed\u66f4\u65b0\u64cd\u4f5c\u3002",Object(r.b)("strong",{parentName:"p"},"\u4e00\u65e6\u76d1\u542c\u5230 ",Object(r.b)("inlineCode",{parentName:"strong"},"appsetting.json")," \u6216\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u53d1\u751f\u53d8\u52a8\uff0c\u5c31\u4f1a\u89e6\u53d1 ",Object(r.b)("inlineCode",{parentName:"strong"},"OnChange")," \u65b9\u6cd5"),"\u3002\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(r.b)("pre",null,Object(r.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cs",metastring:"{2,4-5}","{2,4-5}":!0}),'var appInfoConfiguration = App.Configuration["AppInfo"];\nChangeToken.OnChange(() => appInfoConfiguration.GetReloadToken(), () =>\n{\n var name = appInfoConfiguration["Name"]; // \u5b9e\u65f6\u7684\u6700\u65b0\u503c\n var version = appInfoConfiguration["Version"]; // \u5b9e\u65f6\u7684\u6700\u65b0\u503c\n});\n')),Object(r.b)("h2",{id:"417-\u914d\u7f6e\u7684\u4f18\u7f3a\u70b9"},"4.1.7 \u914d\u7f6e\u7684\u4f18\u7f3a\u70b9"),Object(r.b)("ul",null,Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u4f18\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u80fd\u591f\u5728\u7cfb\u7edf\u8fd0\u884c\u65f6\u5feb\u901f\u8bfb\u53d6"),Object(r.b)("li",{parentName:"ul"},"\u65e0\u9700\u989d\u5916\u914d\u7f6e"))),Object(r.b)("li",{parentName:"ul"},Object(r.b)("p",{parentName:"li"},"\u7f3a\u70b9"),Object(r.b)("ul",{parentName:"li"},Object(r.b)("li",{parentName:"ul"},"\u5b58\u5728\u91cd\u590d\u8bfb\u53d6"),Object(r.b)("li",{parentName:"ul"},"\u901a\u8fc7\u786c\u7f16\u7801\u5b57\u7b26\u4e32\u8bfb\u53d6\uff0c\u5bb9\u6613\u51fa\u9519"),Object(r.b)("li",{parentName:"ul"},"\u4e0d\u80fd\u8bbe\u7f6e\u9ed8\u8ba4\u503c"),Object(r.b)("li",{parentName:"ul"},"\u4e0d\u80fd\u5728\u8fd0\u884c\u73af\u5883\u4e2d\u52a8\u6001\u914d\u7f6e"),Object(r.b)("li",{parentName:"ul"},"\u4e0d\u80fd\u9a8c\u8bc1\u914d\u7f6e\u6709\u6548\u6027"),Object(r.b)("li",{parentName:"ul"},"\u4e0d\u652f\u6301\u66f4\u6539\u901a\u77e5")))),Object(r.b)("h2",{id:"418-\u914d\u7f6e\u4f7f\u7528\u573a\u666f"},"4.1.8 \u914d\u7f6e\u4f7f\u7528\u573a\u666f"),Object(r.b)("p",null,"\u5982\u679c\u53ea\u9700\u8981",Object(r.b)("strong",{parentName:"p"},"\u4e00\u6b21\u6027\u8bfb\u53d6"),"\u914d\u7f6e\u4fe1\u606f\uff0c\u5219\u4f7f\u7528\u914d\u7f6e\uff0c\u5426\u5219\u5e94\u8be5\u4f7f\u7528 \u300a",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"/docs/options"}),"4.2 \u9009\u9879"),"\u300b\u4ee3\u66ff\u3002"),Object(r.b)("h2",{id:"419-\u53cd\u9988\u4e0e\u5efa\u8bae"},"4.1.9 \u53cd\u9988\u4e0e\u5efa\u8bae"),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e0e\u6211\u4eec\u4ea4\u6d41")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u7ed9 Fur \u63d0 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://gitee.com/monksoul/Fur/issues/new?issue"}),"Issue"),"\u3002"))),Object(r.b)("hr",null),Object(r.b)("div",{className:"admonition admonition-note alert alert--secondary"},Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(r.b)("h5",{parentName:"div"},Object(r.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(r.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(r.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})))),"\u4e86\u89e3\u66f4\u591a")),Object(r.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(r.b)("p",{parentName:"div"},"\u60f3\u4e86\u89e3\u66f4\u591a ",Object(r.b)("inlineCode",{parentName:"p"},"\u914d\u7f6e")," \u77e5\u8bc6\u53ef\u67e5\u9605 ",Object(r.b)("a",Object(a.a)({parentName:"p"},{href:"https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/configuration/?view=aspnetcore-5.0"}),"ASP.NET Core - \u914d\u7f6e")," \u7ae0\u8282\u3002"))))}u.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return s})),t.d(n,"b",(function(){return j}));var a=t(0),i=t.n(a);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function c(e){for(var n=1;n=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var l=i.a.createContext({}),p=function(e){var n=i.a.useContext(l),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},s=function(e){var n=p(e.components);return i.a.createElement(l.Provider,{value:n},e.children)},u={inlineCode:"code",wrapper:function(e){var n=e.children;return i.a.createElement(i.a.Fragment,{},n)}},m=i.a.forwardRef((function(e,n){var t=e.components,a=e.mdxType,r=e.originalType,o=e.parentName,l=b(e,["components","mdxType","originalType","parentName"]),s=p(t),m=a,j=s["".concat(o,".").concat(m)]||s[m]||u[m]||r;return t?i.a.createElement(j,c(c({ref:n},l),{},{components:t})):i.a.createElement(j,c({ref:n},l))}));function j(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var r=t.length,o=new Array(r);o[0]=m;var c={};for(var b in n)hasOwnProperty.call(n,b)&&(c[b]=n[b]);c.originalType=e,c.mdxType="string"==typeof e?e:a,o[1]=c;for(var l=2;lFurService \u7c7b",id:"211-\u521b\u5efa-furservice-\u7c7b",children:[]},{value:"2.1.2 \u5728\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b\u6548\u679c",id:"212-\u5728\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b\u6548\u679c",children:[]}]},{value:"2.2 \u6dfb\u52a0\u6570\u636e\u5e93\u652f\u6301",id:"22-\u6dfb\u52a0\u6570\u636e\u5e93\u652f\u6301",children:[{value:"2.2.1 \u6dfb\u52a0 Person \u5b9e\u4f53\u7c7b",id:"221-\u6dfb\u52a0-person-\u5b9e\u4f53\u7c7b",children:[]},{value:"2.2.2 \u521b\u5efa\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"222-\u521b\u5efa\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"2.2.3 \u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"223-\u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"2.2.4 \u901a\u8fc7\u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\u8868",id:"224-\u901a\u8fc7\u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\u8868",children:[]}]},{value:"2.3 \u589e\u5220\u67e5\u6539\u5206\u9875\u4f8b\u5b50",id:"23-\u589e\u5220\u67e5\u6539\u5206\u9875\u4f8b\u5b50",children:[{value:"\u9644\u4e0a PersonDto",id:"\u9644\u4e0a-persondto",children:[]}]}],u={rightToc:p};function b(e){var n=e.components,t=Object(a.a)(e,["components"]);return Object(i.b)("wrapper",Object(r.a)({},u,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"21-hello-fur"},"2.1 Hello Fur"),Object(i.b)("h3",{id:"211-\u521b\u5efa-furservice-\u7c7b"},"2.1.1 \u521b\u5efa ",Object(i.b)("inlineCode",{parentName:"h3"},"FurService")," \u7c7b"),Object(i.b)("p",null,"\u8bbe\u7f6e ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.Web.Entry")," \u4e3a\u542f\u52a8\u9879\uff0c\u5e76\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.Application")," \u4e2d\u521b\u5efa ",Object(i.b)("inlineCode",{parentName:"p"},"FurService")," \u7c7b\uff0c\u5e76\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9:"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,6,12}","{1,5,6,12}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [DynamicApiController] // \u8fd9\u91cc\u4f7f\u7528\u7279\u6027\u65b9\u5f0f\n public class FurService /*: IDynamicApiController*/ // \u4e5f\u53ef\u4ee5\u4f7f\u7528\u63a5\u53e3\u65b9\u5f0f\n {\n /// \n /// \u5411\u4e16\u754c\u95ee\u597d\n /// \n /// \n public string SayHello()\n {\n return $"Hello {nameof(Fur)}";\n }\n }\n}\n')),Object(i.b)("h3",{id:"212-\u5728\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b\u6548\u679c"},"2.1.2 \u5728\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b\u6548\u679c"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.Web.Entry")," \u9879\u76ee\u4e2d\u9009\u62e9 ",Object(i.b)("inlineCode",{parentName:"p"},"wwwroot")," \u53f3\u952e\u9009\u62e9\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b")),Object(i.b)("img",{src:Object(o.a)("img/getstart1.png"),style:{height:400}}),Object(i.b)("p",null,"\u6548\u679c\u5982\u4e0b\uff1a"),Object(i.b)("img",{src:Object(o.a)("img/getstart2.gif")}),Object(i.b)("h2",{id:"22-\u6dfb\u52a0\u6570\u636e\u5e93\u652f\u6301"},"2.2 \u6dfb\u52a0\u6570\u636e\u5e93\u652f\u6301"),Object(i.b)("h3",{id:"221-\u6dfb\u52a0-person-\u5b9e\u4f53\u7c7b"},"2.2.1 \u6dfb\u52a0 ",Object(i.b)("inlineCode",{parentName:"h3"},"Person")," \u5b9e\u4f53\u7c7b"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.Core")," \u4e2d\u65b0\u5efa ",Object(i.b)("inlineCode",{parentName:"p"},"Person")," \u5b9e\u4f53\u7c7b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,7}","{1,7}":!0}),"using Fur.DatabaseAccessor;\nusing System;\nusing System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Core\n{\n public class Person : Entity // \u7ee7\u627f\u81ea Entity \u62bd\u8c61\u7c7b\n {\n /// \n /// \u6784\u9020\u51fd\u6570\n /// \n public Person()\n {\n CreatedTime = DateTime.Now;\n IsDeleted = false;\n }\n\n /// \n /// \u59d3\u540d\n /// \n [MaxLength(32)]\n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n\n /// \n /// \u4f4f\u5740\n /// \n public string Address { get; set; }\n }\n}\n")),Object(i.b)("h3",{id:"222-\u521b\u5efa\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"2.2.2 \u521b\u5efa\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u4e2d\u6dfb\u52a0 ",Object(i.b)("inlineCode",{parentName:"p"},"FurDbContext")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{1-2,6-7,13}","{1-2,6-7,13}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Data Source=./Fur.db")] // \u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32\n public class FurDbContext : AppDbContext // \u7ee7\u627f AppDbContext<> \u7c7b\n {\n /// \n /// \u7ee7\u627f\u7236\u7c7b\u6784\u9020\u51fd\u6570\n /// \n /// \n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(i.b)("h3",{id:"223-\u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"2.2.3 \u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u7684 ",Object(i.b)("inlineCode",{parentName:"p"},"FurEntityFrameworkCoreStartup")," \u4e2d\u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:'{11-14} title="Fur\\framework\\Fur.EntityFramework.Core\\FurEntityFrameworkCoreStartup.cs"',"{11-14}":!0,title:'"Fur\\framework\\Fur.EntityFramework.Core\\FurEntityFrameworkCoreStartup.cs"'}),"using Fur.DatabaseAccessor;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(600)]\n public sealed class FurEntityFrameworkCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddDatabaseAccessor(options =>\n {\n options.AddDbPool(DbProvider.Sqlite);\n });\n }\n }\n}\n")),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u8bf4\u660e")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6f14\u793a\u793a\u4f8b\u4e2d\uff0c\u9ed8\u8ba4\u5df2\u7ecf\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u5c42\u5b89\u88c5\u4e86 ",Object(i.b)("inlineCode",{parentName:"p"},"Microsoft.EntityFrameworkCore.Sqlite")," \u5305\u3002"),Object(i.b)("p",{parentName:"div"},"\u5982\u679c\u4f60\u9700\u8981\u5b89\u88c5\u5bf9\u5e94\u7684\u6570\u636e\u5e93\u7248\u672c\uff0c\u53ef\u4ee5\u67e5\u9605 \u3010",Object(i.b)("a",Object(r.a)({parentName:"p"},{href:"dbcontext-multi-database"}),"9.18 \u591a\u6570\u636e\u5e93\u64cd\u4f5c"),"\u3011 \u7ae0\u8282\u3002"))),Object(i.b)("h3",{id:"224-\u901a\u8fc7\u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\u8868"},"2.2.4 \u901a\u8fc7\u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\u8868"),Object(i.b)("p",null,"\u6253\u5f00 ",Object(i.b)("inlineCode",{parentName:"p"},"\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0"),"\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(i.b)("img",{src:Object(o.a)("img/getstart3.png"),style:{height:400}}),Object(i.b)("p",null,"\u9009\u62e9 ",Object(i.b)("inlineCode",{parentName:"p"},"\u9ed8\u8ba4\u9879\u76ee\u4e3a"),"\uff1a",Object(i.b)("inlineCode",{parentName:"p"},"Fur.Database.Migrations"),"\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(i.b)("img",{src:Object(o.a)("img/getstart4.png")}),Object(i.b)("p",null,Object(i.b)("strong",{parentName:"p"},"\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4"),"\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{}),"Add-Migration v0.0.1\n")),Object(i.b)("img",{src:Object(o.a)("img/getstart5.png")}),Object(i.b)("p",null,Object(i.b)("strong",{parentName:"p"},"\u63d0\u4ea4\u5230\u6570\u636e\u5e93\u66f4\u6539")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{}),"Update-Database\n")),Object(i.b)("img",{src:Object(o.a)("img/getstart6.png")}),Object(i.b)("img",{src:Object(o.a)("img/getstart7.png"),style:{height:400}}),Object(i.b)("h2",{id:"23-\u589e\u5220\u67e5\u6539\u5206\u9875\u4f8b\u5b50"},"2.3 \u589e\u5220\u67e5\u6539\u5206\u9875\u4f8b\u5b50"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{14-19}","{14-19}":!0}),'using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing Fur.DynamicApiController;\nusing Mapster;\nusing Microsoft.EntityFrameworkCore;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\n\nnamespace Fur.Application\n{\n [DynamicApiController] // \u8fd9\u91cc\u4f7f\u7528\u7279\u6027\u65b9\u5f0f\n public class FurService /*: IDynamicApiController*/ // \u4e5f\u53ef\u4ee5\u4f7f\u7528\u63a5\u53e3\u65b9\u5f0f\n {\n // \u521d\u59cb\u5316\u4ed3\u50a8\n private readonly IRepository _personRepository;\n public FurService(IRepository personRepository)\n {\n _personRepository = personRepository;\n }\n\n /// \n /// \u65b0\u589e\u4e00\u6761\n /// \n public async Task Insert(PersonDto personDto)\n {\n // \u5982\u679c\u4e0d\u9700\u8981\u8fd4\u56de\u81ea\u589eId\uff0c\u4f7f\u7528 InsertAsync\u5373\u53ef\n var newEntity = await _personRepository.InsertNowAsync(personDto.Adapt());\n return newEntity.Entity.Id;\n\n // \u8fd8\u53ef\u4ee5\u76f4\u63a5\u64cd\u4f5c\n // await personDto.Adapt().InsertNowAsync();\n }\n\n /// \n /// \u66f4\u65b0\u4e00\u6761\n /// \n /// \n public async Task Update(PersonDto personDto)\n {\n await _personRepository.UpdateAsync(personDto.Adapt());\n\n // \u8fd8\u53ef\u4ee5\u76f4\u63a5\u64cd\u4f5c\n // await personDto.Adapt().UpdateAsync();\n }\n\n /// \n /// \u5220\u9664\u4e00\u6761\n /// \n /// \n public async Task Delete(int id)\n {\n await _personRepository.DeleteAsync(id);\n }\n\n /// \n /// \u67e5\u8be2\u4e00\u6761\n /// \n /// \n public async Task Find(int id)\n {\n var person = await _personRepository.FindAsync(id);\n return person.Adapt();\n }\n\n /// \n /// \u67e5\u8be2\u6240\u6709\n /// \n /// \n public async Task> GetAll()\n {\n var persons = await _personRepository.AsAsyncEnumerable();\n return persons.Adapt>();\n }\n\n /// \n /// \u5206\u9875\u67e5\u8be2\n /// \n /// \n /// \n /// \n public async Task> GetAllByPage(int pageIndex = 1, int pageSize = 10)\n {\n var pageResult = await _personRepository.AsQueryable().ToPagedListAsync(pageIndex, pageSize);\n return pageResult.Adapt>();\n }\n }\n}\n')),Object(i.b)("img",{src:Object(o.a)("img/getstart8.gif")}),Object(i.b)("h3",{id:"\u9644\u4e0a-persondto"},"\u9644\u4e0a ",Object(i.b)("inlineCode",{parentName:"h3"},"PersonDto")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"using System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Application\n{\n public class PersonDto\n {\n /// \n /// Id\n /// \n public int? Id { get; set; }\n\n /// \n /// \u59d3\u540d\n /// \n [StringLength(32, MinimumLength = 2)]\n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n }\n}\n")),Object(i.b)("p",null,"\u8bf4\u597d\u4e00\u5206\u949f\u5165\u95e8\uff0c\u4f60\u4eec\u7528\u4e86\u591a\u957f\u65f6\u95f4\u3002\ud83d\ude01"))}b.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return b})),t.d(n,"b",(function(){return d}));var r=t(0),a=t.n(r);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function s(e){for(var n=1;n=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}var p=a.a.createContext({}),u=function(e){var n=a.a.useContext(p),t=n;return e&&(t="function"==typeof e?e(n):s(s({},n),e)),t},b=function(e){var n=u(e.components);return a.a.createElement(p.Provider,{value:n},e.children)},l={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},m=a.a.forwardRef((function(e,n){var t=e.components,r=e.mdxType,i=e.originalType,o=e.parentName,p=c(e,["components","mdxType","originalType","parentName"]),b=u(t),m=r,d=b["".concat(o,".").concat(m)]||b[m]||l[m]||i;return t?a.a.createElement(d,s(s({ref:n},p),{},{components:t})):a.a.createElement(d,s({ref:n},p))}));function d(e,n){var t=arguments,r=n&&n.mdxType;if("string"==typeof e||r){var i=t.length,o=new Array(i);o[0]=m;var s={};for(var c in n)hasOwnProperty.call(n,c)&&(s[c]=n[c]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var p=2;pFurService \u7c7b",id:"211-\u521b\u5efa-furservice-\u7c7b",children:[]},{value:"2.1.2 \u5728\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b\u6548\u679c",id:"212-\u5728\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b\u6548\u679c",children:[]}]},{value:"2.2 \u6dfb\u52a0\u6570\u636e\u5e93\u652f\u6301",id:"22-\u6dfb\u52a0\u6570\u636e\u5e93\u652f\u6301",children:[{value:"2.2.1 \u6dfb\u52a0 Person \u5b9e\u4f53\u7c7b",id:"221-\u6dfb\u52a0-person-\u5b9e\u4f53\u7c7b",children:[]},{value:"2.2.2 \u521b\u5efa\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"222-\u521b\u5efa\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"2.2.3 \u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",id:"223-\u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587",children:[]},{value:"2.2.4 \u901a\u8fc7\u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\u8868",id:"224-\u901a\u8fc7\u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\u8868",children:[]}]},{value:"2.3 \u589e\u5220\u67e5\u6539\u5206\u9875\u4f8b\u5b50",id:"23-\u589e\u5220\u67e5\u6539\u5206\u9875\u4f8b\u5b50",children:[{value:"\u9644\u4e0a PersonDto",id:"\u9644\u4e0a-persondto",children:[]}]}],u={rightToc:p};function b(e){var n=e.components,t=Object(a.a)(e,["components"]);return Object(i.b)("wrapper",Object(r.a)({},u,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"21-hello-fur"},"2.1 Hello Fur"),Object(i.b)("h3",{id:"211-\u521b\u5efa-furservice-\u7c7b"},"2.1.1 \u521b\u5efa ",Object(i.b)("inlineCode",{parentName:"h3"},"FurService")," \u7c7b"),Object(i.b)("p",null,"\u8bbe\u7f6e ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.Web.Entry")," \u4e3a\u542f\u52a8\u9879\uff0c\u5e76\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.Application")," \u4e2d\u521b\u5efa ",Object(i.b)("inlineCode",{parentName:"p"},"FurService")," \u7c7b\uff0c\u5e76\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9:"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,5,6,12}","{1,5,6,12}":!0}),'using Fur.DynamicApiController;\n\nnamespace Fur.Application\n{\n [DynamicApiController] // \u8fd9\u91cc\u4f7f\u7528\u7279\u6027\u65b9\u5f0f\n public class FurService /*: IDynamicApiController*/ // \u4e5f\u53ef\u4ee5\u4f7f\u7528\u63a5\u53e3\u65b9\u5f0f\n {\n /// \n /// \u5411\u4e16\u754c\u95ee\u597d\n /// \n /// \n public string SayHello()\n {\n return $"Hello {nameof(Fur)}";\n }\n }\n}\n')),Object(i.b)("h3",{id:"212-\u5728\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b\u6548\u679c"},"2.1.2 \u5728\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b\u6548\u679c"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.Web.Entry")," \u9879\u76ee\u4e2d\u9009\u62e9 ",Object(i.b)("inlineCode",{parentName:"p"},"wwwroot")," \u53f3\u952e\u9009\u62e9\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"\u6d4f\u89c8\u5668\u4e2d\u67e5\u770b")),Object(i.b)("img",{src:Object(o.a)("img/getstart1.png"),style:{height:400}}),Object(i.b)("p",null,"\u6548\u679c\u5982\u4e0b\uff1a"),Object(i.b)("img",{src:Object(o.a)("img/getstart2.gif")}),Object(i.b)("h2",{id:"22-\u6dfb\u52a0\u6570\u636e\u5e93\u652f\u6301"},"2.2 \u6dfb\u52a0\u6570\u636e\u5e93\u652f\u6301"),Object(i.b)("h3",{id:"221-\u6dfb\u52a0-person-\u5b9e\u4f53\u7c7b"},"2.2.1 \u6dfb\u52a0 ",Object(i.b)("inlineCode",{parentName:"h3"},"Person")," \u5b9e\u4f53\u7c7b"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.Core")," \u4e2d\u65b0\u5efa ",Object(i.b)("inlineCode",{parentName:"p"},"Person")," \u5b9e\u4f53\u7c7b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{1,7}","{1,7}":!0}),"using Fur.DatabaseAccessor;\nusing System;\nusing System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Core\n{\n public class Person : Entity // \u7ee7\u627f\u81ea Entity \u62bd\u8c61\u7c7b\n {\n /// \n /// \u6784\u9020\u51fd\u6570\n /// \n public Person()\n {\n CreatedTime = DateTime.Now;\n IsDeleted = false;\n }\n\n /// \n /// \u59d3\u540d\n /// \n [MaxLength(32)]\n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n\n /// \n /// \u4f4f\u5740\n /// \n public string Address { get; set; }\n }\n}\n")),Object(i.b)("h3",{id:"222-\u521b\u5efa\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"2.2.2 \u521b\u5efa\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u4e2d\u6dfb\u52a0 ",Object(i.b)("inlineCode",{parentName:"p"},"FurDbContext")," \u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{1-2,6-7,13}","{1-2,6-7,13}":!0}),'using Fur.DatabaseAccessor;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppDbContext("Data Source=./Fur.db")] // \u914d\u7f6e\u8fde\u63a5\u5b57\u7b26\u4e32\n public class FurDbContext : AppDbContext // \u7ee7\u627f AppDbContext<> \u7c7b\n {\n /// \n /// \u7ee7\u627f\u7236\u7c7b\u6784\u9020\u51fd\u6570\n /// \n /// \n public FurDbContext(DbContextOptions options) : base(options)\n {\n }\n }\n}\n')),Object(i.b)("h3",{id:"223-\u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"},"2.2.3 \u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587"),Object(i.b)("p",null,"\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u7684 ",Object(i.b)("inlineCode",{parentName:"p"},"FurEntityFrameworkCoreStartup")," \u4e2d\u914d\u7f6e\u6570\u636e\u5e93\u4e0a\u4e0b\u6587\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:'{11-14} title="Fur\\framework\\Fur.EntityFramework.Core\\FurEntityFrameworkCoreStartup.cs"',"{11-14}":!0,title:'"Fur\\framework\\Fur.EntityFramework.Core\\FurEntityFrameworkCoreStartup.cs"'}),"using Fur.DatabaseAccessor;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Fur.EntityFramework.Core\n{\n [AppStartup(600)]\n public sealed class FurEntityFrameworkCoreStartup : AppStartup\n {\n public void ConfigureServices(IServiceCollection services)\n {\n services.AddDatabaseAccessor(options =>\n {\n options.AddDbPool(DbProvider.Sqlite);\n });\n }\n }\n}\n")),Object(i.b)("div",{className:"admonition admonition-important alert alert--info"},Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-heading"}),Object(i.b)("h5",{parentName:"div"},Object(i.b)("span",Object(r.a)({parentName:"h5"},{className:"admonition-icon"}),Object(i.b)("svg",Object(r.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"}),Object(i.b)("path",Object(r.a)({parentName:"svg"},{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})))),"\u7279\u522b\u8bf4\u660e")),Object(i.b)("div",Object(r.a)({parentName:"div"},{className:"admonition-content"}),Object(i.b)("p",{parentName:"div"},Object(i.b)("inlineCode",{parentName:"p"},"Fur")," \u6f14\u793a\u793a\u4f8b\u4e2d\uff0c\u9ed8\u8ba4\u5df2\u7ecf\u5728 ",Object(i.b)("inlineCode",{parentName:"p"},"Fur.EntityFramework.Core")," \u5c42\u5b89\u88c5\u4e86 ",Object(i.b)("inlineCode",{parentName:"p"},"Microsoft.EntityFrameworkCore.Sqlite")," \u5305\u3002"),Object(i.b)("p",{parentName:"div"},"\u5982\u679c\u4f60\u9700\u8981\u5b89\u88c5\u5bf9\u5e94\u7684\u6570\u636e\u5e93\u7248\u672c\uff0c\u53ef\u4ee5\u67e5\u9605 \u3010",Object(i.b)("a",Object(r.a)({parentName:"p"},{href:"dbcontext-multi-database"}),"9.18 \u591a\u6570\u636e\u5e93\u64cd\u4f5c"),"\u3011 \u7ae0\u8282\u3002"))),Object(i.b)("h3",{id:"224-\u901a\u8fc7\u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\u8868"},"2.2.4 \u901a\u8fc7\u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\u8868"),Object(i.b)("p",null,"\u6253\u5f00 ",Object(i.b)("inlineCode",{parentName:"p"},"\u7a0b\u5e8f\u5305\u7ba1\u7406\u63a7\u5236\u53f0"),"\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(i.b)("img",{src:Object(o.a)("img/getstart3.png"),style:{height:400}}),Object(i.b)("p",null,"\u9009\u62e9 ",Object(i.b)("inlineCode",{parentName:"p"},"\u9ed8\u8ba4\u9879\u76ee\u4e3a"),"\uff1a",Object(i.b)("inlineCode",{parentName:"p"},"Fur.Database.Migrations"),"\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"),Object(i.b)("img",{src:Object(o.a)("img/getstart4.png")}),Object(i.b)("p",null,Object(i.b)("strong",{parentName:"p"},"\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4"),"\uff1a"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{}),"Add-Migration v0.0.1\n")),Object(i.b)("img",{src:Object(o.a)("img/getstart5.png")}),Object(i.b)("p",null,Object(i.b)("strong",{parentName:"p"},"\u63d0\u4ea4\u5230\u6570\u636e\u5e93\u66f4\u6539")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{}),"Update-Database\n")),Object(i.b)("img",{src:Object(o.a)("img/getstart6.png")}),Object(i.b)("img",{src:Object(o.a)("img/getstart7.png"),style:{height:400}}),Object(i.b)("h2",{id:"23-\u589e\u5220\u67e5\u6539\u5206\u9875\u4f8b\u5b50"},"2.3 \u589e\u5220\u67e5\u6539\u5206\u9875\u4f8b\u5b50"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs",metastring:"{14-19}","{14-19}":!0}),'using Fur.Core;\nusing Fur.DatabaseAccessor;\nusing Fur.DynamicApiController;\nusing Mapster;\nusing Microsoft.EntityFrameworkCore;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\n\nnamespace Fur.Application\n{\n [DynamicApiController] // \u8fd9\u91cc\u4f7f\u7528\u7279\u6027\u65b9\u5f0f\n public class FurService /*: IDynamicApiController*/ // \u4e5f\u53ef\u4ee5\u4f7f\u7528\u63a5\u53e3\u65b9\u5f0f\n {\n // \u521d\u59cb\u5316\u4ed3\u50a8\n private readonly IRepository _personRepository;\n public FurService(IRepository personRepository)\n {\n _personRepository = personRepository;\n }\n\n /// \n /// \u65b0\u589e\u4e00\u6761\n /// \n public async Task Insert(PersonDto personDto)\n {\n // \u5982\u679c\u4e0d\u9700\u8981\u8fd4\u56de\u81ea\u589eId\uff0c\u4f7f\u7528 InsertAsync\u5373\u53ef\n var newEntity = await _personRepository.InsertNowAsync(personDto.Adapt());\n return newEntity.Entity.Id;\n\n // \u8fd8\u53ef\u4ee5\u76f4\u63a5\u64cd\u4f5c\n // await personDto.Adapt().InsertNowAsync();\n }\n\n /// \n /// \u66f4\u65b0\u4e00\u6761\n /// \n /// \n public async Task Update(PersonDto personDto)\n {\n await _personRepository.UpdateAsync(personDto.Adapt());\n\n // \u8fd8\u53ef\u4ee5\u76f4\u63a5\u64cd\u4f5c\n // await personDto.Adapt().UpdateAsync();\n }\n\n /// \n /// \u5220\u9664\u4e00\u6761\n /// \n /// \n public async Task Delete(int id)\n {\n await _personRepository.DeleteAsync(id);\n }\n\n /// \n /// \u67e5\u8be2\u4e00\u6761\n /// \n /// \n public async Task Find(int id)\n {\n var person = await _personRepository.FindAsync(id);\n return person.Adapt();\n }\n\n /// \n /// \u67e5\u8be2\u6240\u6709\n /// \n /// \n public async Task> GetAll()\n {\n var persons = await _personRepository.AsAsyncEnumerable();\n return persons.Adapt>();\n }\n\n /// \n /// \u5206\u9875\u67e5\u8be2\n /// \n /// \n /// \n /// \n public async Task> GetAllByPage(int pageIndex = 1, int pageSize = 10)\n {\n var pageResult = await _personRepository.AsQueryable().ToPagedListAsync(pageIndex, pageSize);\n return pageResult.Adapt>();\n }\n }\n}\n')),Object(i.b)("img",{src:Object(o.a)("img/getstart8.gif")}),Object(i.b)("h3",{id:"\u9644\u4e0a-persondto"},"\u9644\u4e0a ",Object(i.b)("inlineCode",{parentName:"h3"},"PersonDto")),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-cs"}),"using System.ComponentModel.DataAnnotations;\n\nnamespace Fur.Application\n{\n public class PersonDto\n {\n /// \n /// Id\n /// \n public int? Id { get; set; }\n\n /// \n /// \u59d3\u540d\n /// \n [StringLength(32, MinimumLength = 2)]\n public string Name { get; set; }\n\n /// \n /// \u5e74\u9f84\n /// \n public int Age { get; set; }\n }\n}\n")),Object(i.b)("p",null,"\u8bf4\u597d\u4e00\u5206\u949f\u5165\u95e8\uff0c\u4f60\u4eec\u7528\u4e86\u591a\u957f\u65f6\u95f4\u3002\ud83d\ude01"))}b.isMDXComponent=!0},142:function(e,n,t){"use strict";t.d(n,"a",(function(){return b})),t.d(n,"b",(function(){return d}));var r=t(0),a=t.n(r);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function s(e){for(var n=1;n=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}var p=a.a.createContext({}),u=function(e){var n=a.a.useContext(p),t=n;return e&&(t="function"==typeof e?e(n):s(s({},n),e)),t},b=function(e){var n=u(e.components);return a.a.createElement(p.Provider,{value:n},e.children)},l={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},m=a.a.forwardRef((function(e,n){var t=e.components,r=e.mdxType,i=e.originalType,o=e.parentName,p=c(e,["components","mdxType","originalType","parentName"]),b=u(t),m=r,d=b["".concat(o,".").concat(m)]||b[m]||l[m]||i;return t?a.a.createElement(d,s(s({ref:n},p),{},{components:t})):a.a.createElement(d,s({ref:n},p))}));function d(e,n){var t=arguments,r=n&&n.mdxType;if("string"==typeof e||r){var i=t.length,o=new Array(i);o[0]=m;var s={};for(var c in n)hasOwnProperty.call(n,c)&&(s[c]=n[c]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var p=2;p=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var l=o.a.createContext({}),p=function(e){var n=o.a.useContext(l),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},s=function(e){var n=p(e.components);return o.a.createElement(l.Provider,{value:n},e.children)},f={inlineCode:"code",wrapper:function(e){var n=e.children;return o.a.createElement(o.a.Fragment,{},n)}},d=o.a.forwardRef((function(e,n){var t=e.components,r=e.mdxType,i=e.originalType,a=e.parentName,l=u(e,["components","mdxType","originalType","parentName"]),s=p(t),d=r,m=s["".concat(a,".").concat(d)]||s[d]||f[d]||i;return t?o.a.createElement(m,c(c({ref:n},l),{},{components:t})):o.a.createElement(m,c({ref:n},l))}));function m(e,n){var t=arguments,r=n&&n.mdxType;if("string"==typeof e||r){var i=t.length,a=new Array(i);a[0]=d;var c={};for(var u in n)hasOwnProperty.call(n,u)&&(c[u]=n[u]);c.originalType=e,c.mdxType="string"==typeof e?e:r,a[1]=c;for(var l=2;l=0||(o[r]=e[r]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var l=o.a.createContext({}),p=function(e){var n=o.a.useContext(l),r=n;return e&&(r="function"==typeof e?e(n):c(c({},n),e)),r},s=function(e){var n=p(e.components);return o.a.createElement(l.Provider,{value:n},e.children)},f={inlineCode:"code",wrapper:function(e){var n=e.children;return o.a.createElement(o.a.Fragment,{},n)}},d=o.a.forwardRef((function(e,n){var r=e.components,t=e.mdxType,i=e.originalType,a=e.parentName,l=u(e,["components","mdxType","originalType","parentName"]),s=p(r),d=t,m=s["".concat(a,".").concat(d)]||s[d]||f[d]||i;return r?o.a.createElement(m,c(c({ref:n},l),{},{components:r})):o.a.createElement(m,c({ref:n},l))}));function m(e,n){var r=arguments,t=n&&n.mdxType;if("string"==typeof e||t){var i=r.length,a=new Array(i);a[0]=d;var c={};for(var u in n)hasOwnProperty.call(n,u)&&(c[u]=n[u]);c.originalType=e,c.mdxType="string"==typeof e?e:t,a[1]=c;for(var l=2;l -Fur 是 .NET 5 平台下极易入门、极速开发的 Web 应用框架。 Fur | Fur - - - - - - +Fur 是 .NET 5 平台下极易入门、极速开发的 Web 应用框架。 Fur | Fur + + + + + +
-

Fur 是 .NET 5 平台下极易入门、极速开发的 Web 应用框架。

[object Object]

.NET 5 新起点

.NET 5 是 .NET 的重要且令人兴奋的新方向。你会看到 .NET 变得更加简单,但也有更广泛的功能和实用程序。所有新的开发和功能都将是 .NET 5 的一部分,包括新的 C# 版本

[object Object]

“六级” 架构

Fur 在设计之初就秉承着 “六极” :极易入门、极速开发、极少依赖、极少配置、极其灵活、极易维护 的设计思想,在架构设计上做了大量的优化,支持各个能力阶层技术员极速上手。

[object Object]

冲一杯咖啡的时间

Fur 除了独具创新的设计理念和灵活的架构设计以外,同时还结合了主流的敏捷开发模式打造的一款极速开发框架。只需冲制一杯咖啡的时间便可完成工作

- - - - - - +

Fur 是 .NET 5 平台下极易入门、极速开发的 Web 应用框架。

[object Object]

.NET 5 新起点

.NET 5 是 .NET 的重要且令人兴奋的新方向。你会看到 .NET 变得更加简单,但也有更广泛的功能和实用程序。所有新的开发和功能都将是 .NET 5 的一部分,包括新的 C# 版本

[object Object]

“六级” 架构

Fur 在设计之初就秉承着 “六极” :极易入门、极速开发、极少依赖、极少配置、极其灵活、极易维护 的设计思想,在架构设计上做了大量的优化,支持各个能力阶层技术员极速上手。

[object Object]

冲一杯咖啡的时间

Fur 除了独具创新的设计理念和灵活的架构设计以外,同时还结合了主流的敏捷开发模式打造的一款极速开发框架。只需冲制一杯咖啡的时间便可完成工作

+ + + + + + \ No newline at end of file diff --git a/handbook/build/main.2cb9d26e.js b/handbook/build/main.2cb9d26e.js deleted file mode 100644 index b1170960ac3..00000000000 --- a/handbook/build/main.2cb9d26e.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[83],[function(e,t,n){"use strict";e.exports=n(30)},function(e,t,n){"use strict";n.d(t,"a",(function(){return y})),n.d(t,"b",(function(){return E})),n.d(t,"c",(function(){return T})),n.d(t,"d",(function(){return _})),n.d(t,"e",(function(){return b})),n.d(t,"f",(function(){return L})),n.d(t,"g",(function(){return F})),n.d(t,"h",(function(){return g})),n.d(t,"i",(function(){return k})),n.d(t,"j",(function(){return C})),n.d(t,"k",(function(){return U})),n.d(t,"l",(function(){return j})),n.d(t,"m",(function(){return B})),n.d(t,"n",(function(){return z})),n.d(t,"o",(function(){return D}));var r=n(3),o=n(0),a=n.n(o),i=(n(7),n(5)),l=n(17),u=n(4),s=n(2),c=n(18),d=n.n(c),f=(n(23),n(6)),p=n(27),m=n.n(p),h=function(e){var t=Object(l.a)();return t.displayName=e,t}("Router-History"),g=function(e){var t=Object(l.a)();return t.displayName=e,t}("Router"),b=function(e){function t(t){var n;return(n=e.call(this,t)||this).state={location:t.history.location},n._isMounted=!1,n._pendingLocation=null,t.staticContext||(n.unlisten=t.history.listen((function(e){n._isMounted?n.setState({location:e}):n._pendingLocation=e}))),n}Object(r.a)(t,e),t.computeRootMatch=function(e){return{path:"/",url:"/",params:{},isExact:"/"===e}};var n=t.prototype;return n.componentDidMount=function(){this._isMounted=!0,this._pendingLocation&&this.setState({location:this._pendingLocation})},n.componentWillUnmount=function(){this.unlisten&&this.unlisten()},n.render=function(){return a.a.createElement(g.Provider,{value:{history:this.props.history,location:this.state.location,match:t.computeRootMatch(this.state.location.pathname),staticContext:this.props.staticContext}},a.a.createElement(h.Provider,{children:this.props.children||null,value:this.props.history}))},t}(a.a.Component);var y=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),o=0;o=0;f--){var p=i[f];"."===p?a(i,f):".."===p?(a(i,f),d++):d&&(a(i,f),d--)}if(!s)for(;d--;d)i.unshift("..");!s||""===i[0]||i[0]&&o(i[0])||i.unshift("");var m=i.join("/");return n&&"/"!==m.substr(-1)&&(m+="/"),m};function l(e){return e.valueOf?e.valueOf():Object.prototype.valueOf.call(e)}var u=function e(t,n){if(t===n)return!0;if(null==t||null==n)return!1;if(Array.isArray(t))return Array.isArray(n)&&t.length===n.length&&t.every((function(t,r){return e(t,n[r])}));if("object"==typeof t||"object"==typeof n){var r=l(t),o=l(n);return r!==t||o!==n?e(r,o):Object.keys(Object.assign({},t,n)).every((function(r){return e(t[r],n[r])}))}return!1},s=n(4);function c(e){return"/"===e.charAt(0)?e:"/"+e}function d(e){return"/"===e.charAt(0)?e.substr(1):e}function f(e,t){return function(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}(e,t)?e.substr(t.length):e}function p(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function m(e){var t=e.pathname,n=e.search,r=e.hash,o=t||"/";return n&&"?"!==n&&(o+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(o+="#"===r.charAt(0)?r:"#"+r),o}function h(e,t,n,o){var a;"string"==typeof e?(a=function(e){var t=e||"/",n="",r="",o=t.indexOf("#");-1!==o&&(r=t.substr(o),t=t.substr(0,o));var a=t.indexOf("?");return-1!==a&&(n=t.substr(a),t=t.substr(0,a)),{pathname:t,search:"?"===n?"":n,hash:"#"===r?"":r}}(e)).state=t:(void 0===(a=Object(r.a)({},e)).pathname&&(a.pathname=""),a.search?"?"!==a.search.charAt(0)&&(a.search="?"+a.search):a.search="",a.hash?"#"!==a.hash.charAt(0)&&(a.hash="#"+a.hash):a.hash="",void 0!==t&&void 0===a.state&&(a.state=t));try{a.pathname=decodeURI(a.pathname)}catch(l){throw l instanceof URIError?new URIError('Pathname "'+a.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):l}return n&&(a.key=n),o?a.pathname?"/"!==a.pathname.charAt(0)&&(a.pathname=i(a.pathname,o.pathname)):a.pathname=o.pathname:a.pathname||(a.pathname="/"),a}function g(e,t){return e.pathname===t.pathname&&e.search===t.search&&e.hash===t.hash&&e.key===t.key&&u(e.state,t.state)}function b(){var e=null;var t=[];return{setPrompt:function(t){return e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,n,r,o){if(null!=e){var a="function"==typeof e?e(t,n):e;"string"==typeof a?"function"==typeof r?r(a,o):o(!0):o(!1!==a)}else o(!0)},appendListener:function(e){var n=!0;function r(){n&&e.apply(void 0,arguments)}return t.push(r),function(){n=!1,t=t.filter((function(e){return e!==r}))}},notifyListeners:function(){for(var e=arguments.length,n=new Array(e),r=0;rt?n.splice(t,n.length-t,o):n.push(o),d({action:r,location:o,index:t,entries:n})}}))},replace:function(e,t){var r="REPLACE",o=h(e,t,f(),E.location);c.confirmTransitionTo(o,r,n,(function(e){e&&(E.entries[E.index]=o,d({action:r,location:o}))}))},go:v,goBack:function(){v(-1)},goForward:function(){v(1)},canGo:function(e){var t=E.index+e;return t>=0&&t=0||(o[n]=e[n]);return o}n.d(t,"a",(function(){return r}))},function(e,t,n){e.exports=n(34)()},function(e,t,n){"use strict";n.d(t,"a",(function(){return l})),n.d(t,"b",(function(){return u}));var r=n(1),o=n(2),a=n(0),i=n.n(a);function l(e,t,n){return void 0===n&&(n=[]),e.some((function(e){var o=e.path?Object(r.j)(t,e):n.length?n[n.length-1].match:r.e.computeRootMatch(t);return o&&(n.push({route:e,match:o}),e.routes&&l(e.routes,t,n)),o})),n}function u(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),e?i.a.createElement(r.g,n,e.map((function(e,n){return i.a.createElement(r.d,{key:e.key||n,path:e.path,exact:e.exact,strict:e.strict,render:function(n){return e.render?e.render(Object(o.a)({},n,{},t,{route:e})):i.a.createElement(e.component,Object(o.a)({},n,t,{route:e}))}})}))):null}},function(e,t,n){"use strict";n.r(t),t.default={title:"Fur",tagline:"Fur \u662f .NET 5 \u5e73\u53f0\u4e0b\u6781\u6613\u5165\u95e8\u3001\u6781\u901f\u5f00\u53d1\u7684 Web \u5e94\u7528\u6846\u67b6\u3002",url:"https://chinadot.net",baseUrl:"/",onBrokenLinks:"throw",favicon:"img/favicon.ico",organizationName:"Baiqian Co.,Ltd.",projectName:"Fur",themeConfig:{prism:{additionalLanguages:["powershell","csharp","sql"]},navbar:{title:"Fur",logo:{alt:"Fur Logo",src:"img/logo.png"},hideOnScroll:!1,items:[{type:"docsVersionDropdown",position:"left"},{to:"docs",activeBasePath:"docs",label:"\u6587\u6863",position:"left"},{to:"blog",label:"\u535a\u5ba2",position:"left"},{label:"\u914d\u7f6e",position:"left"},{label:"\u89c6\u9891",position:"right"},{label:"\u5de5\u5177",position:"right",items:[{label:"\u4ee3\u7801\u751f\u6210\u5668",position:"left"}]},{href:"https://gitee.com/monksoul/Fur/board",label:"\u770b\u677f",position:"right"},{label:"\u4ed3\u5e93",position:"right",items:[{label:"Gitee",href:"https://gitee.com/monksoul/Fur",position:"left"},{label:"GitHub",href:"https://github.com/MonkSoul/Fur",position:"left"}]}]},footer:{style:"dark",links:[{title:"\u6587\u6863",items:[{label:"\u5165\u95e8",to:"docs"},{label:"\u6307\u5357",to:"docs"}]},{title:"\u793e\u533a",items:[{label:"\u8ba8\u8bba",href:"https://gitee.com/monksoul/Fur/issues"},{label:"\u770b\u677f",href:"https://gitee.com/monksoul/Fur/board"}]},{title:"\u66f4\u591a",items:[{label:"\u535a\u5ba2",to:"blog"},{label:"\u4ed3\u5e93",href:"https://gitee.com/monksoul/Fur"}]}],copyright:"Copyright \xa9 2020 Fur, Baiqian Co.,Ltd."},colorMode:{defaultMode:"light",disableSwitch:!1,respectPrefersColorScheme:!1,switchConfig:{darkIcon:"\ud83c\udf1c",darkIconStyle:{},lightIcon:"\ud83c\udf1e",lightIconStyle:{}}},metadatas:[]},presets:[["@docusaurus/preset-classic",{docs:{sidebarPath:"D:\\MONK\\Fur\\handbook\\sidebars.js",editUrl:"https://gitee.com/monksoul/Fur/tree/main/handbook/"},blog:{showReadingTime:!0,editUrl:"https://gitee.com/monksoul/Fur/tree/main/handbook/"},theme:{customCss:"D:\\MONK\\Fur\\handbook\\src\\css\\custom.css"}}]],onDuplicateRoutes:"warn",customFields:{},plugins:[],themes:[],titleDelimiter:"|"}},function(e,t,n){"use strict";var r=!("undefined"==typeof window||!window.document||!window.document.createElement),o={canUseDOM:r,canUseEventListeners:r&&!(!window.addEventListener&&!window.attachEvent),canUseIntersectionObserver:r&&"IntersectionObserver"in window,canUseViewport:r&&!!window.screen};t.a=o},function(e){e.exports=JSON.parse('{"/-d7d":{"component":"ece76bd1","config":"5e9f5e1a"},"/blog-c28":{"component":"a6aa9e1f","items":[{"content":"d3c206bc"}],"metadata":"5c4ee1d6"},"/blog/tags-929":{"component":"01a85c17","tags":"9958fd43"},"/blog/tags/fur-6f6":{"component":"6875c492","items":[{"content":"d3c206bc"}],"metadata":"d63edb86"},"/blog/tags/furos-29c":{"component":"6875c492","items":[{"content":"d3c206bc"}],"metadata":"4e3694ae"},"/blog/tags/net-f21":{"component":"6875c492","items":[{"content":"d3c206bc"}],"metadata":"fde1f028"},"/blog/tags/net-5-98a":{"component":"6875c492","items":[{"content":"d3c206bc"}],"metadata":"d631a3bf"},"/blog/tags/netcore-766":{"component":"6875c492","items":[{"content":"d3c206bc"}],"metadata":"ce4b3b2d"},"/blog/welcome-b88":{"component":"ccc49370","content":"3ab56fdf"},"/docs-5b5":{"component":"1be78505","versionMetadata":"f976f453"},"/docs/-901":{"component":"17896441","content":"4c30b939"},"/docs/answer-903":{"component":"17896441","content":"cb0a942e"},"/docs/appstartup-431":{"component":"17896441","content":"5ce0ebbd"},"/docs/auth-control-d15":{"component":"17896441","content":"904cf40b"},"/docs/author-fcf":{"component":"17896441","content":"b30e5fe3"},"/docs/cache-cd5":{"component":"17896441","content":"2ae73ff4"},"/docs/configuration-ae7":{"component":"17896441","content":"e6c62f29"},"/docs/contribute-2ed":{"component":"17896441","content":"7696a0ae"},"/docs/cors-d1d":{"component":"17896441","content":"70699f3e"},"/docs/data-validation-f02":{"component":"17896441","content":"17256d0f"},"/docs/dbcontext-44b":{"component":"17896441","content":"3e869f93"},"/docs/dbcontext-add-808":{"component":"17896441","content":"e6346b20"},"/docs/dbcontext-add-or-update-4cc":{"component":"17896441","content":"1d7b962e"},"/docs/dbcontext-audit-383":{"component":"17896441","content":"9bdac8f0"},"/docs/dbcontext-batch-b6c":{"component":"17896441","content":"1e961311"},"/docs/dbcontext-code-first-e5c":{"component":"17896441","content":"af3e9b99"},"/docs/dbcontext-db-first-931":{"component":"17896441","content":"902d8112"},"/docs/dbcontext-delete-d3d":{"component":"17896441","content":"d3ee75d5"},"/docs/dbcontext-filter-03c":{"component":"17896441","content":"4930ce4d"},"/docs/dbcontext-function-48e":{"component":"17896441","content":"a133dc31"},"/docs/dbcontext-hight-query-f75":{"component":"17896441","content":"4bfcf3ee"},"/docs/dbcontext-Interceptor-810":{"component":"17896441","content":"7b4b163f"},"/docs/dbcontext-locator-b4b":{"component":"17896441","content":"b80c29d5"},"/docs/dbcontext-multi-database-f7d":{"component":"17896441","content":"59d16f51"},"/docs/dbcontext-proc-78e":{"component":"17896441","content":"1761adf3"},"/docs/dbcontext-query-8f7":{"component":"17896441","content":"7c7b3a8a"},"/docs/dbcontext-read-write-624":{"component":"17896441","content":"4dbcf072"},"/docs/dbcontext-repository-f08":{"component":"17896441","content":"d43b3010"},"/docs/dbcontext-seed-data-9d3":{"component":"17896441","content":"2a4cb773"},"/docs/dbcontext-sql-551":{"component":"17896441","content":"dc10b9c8"},"/docs/dbcontext-sql-proxy-abd":{"component":"17896441","content":"d8f92c54"},"/docs/dbcontext-sql-template-65b":{"component":"17896441","content":"d8c8d2dc"},"/docs/dbcontext-update-dd1":{"component":"17896441","content":"17666df9"},"/docs/dbcontext-view-ec0":{"component":"17896441","content":"408ae89d"},"/docs/dependency-injection-a12":{"component":"17896441","content":"5e077782"},"/docs/deploy-8ea":{"component":"17896441","content":"b0be1305"},"/docs/devops-2bf":{"component":"17896441","content":"a688d5cc"},"/docs/dynamic-api-controller-4ba":{"component":"17896441","content":"0ddd808e"},"/docs/entity-f2d":{"component":"17896441","content":"8231c802"},"/docs/errors-303":{"component":"17896441","content":"654ac364"},"/docs/event-bus-89c":{"component":"17896441","content":"2b04a543"},"/docs/friendly-exception-4b5":{"component":"17896441","content":"62953dcd"},"/docs/get-start-e3d":{"component":"17896441","content":"f9353588"},"/docs/gooduse-9d8":{"component":"17896441","content":"d80bb0e0"},"/docs/grpc-bc2":{"component":"17896441","content":"2792faa0"},"/docs/http-6f4":{"component":"17896441","content":"36793c62"},"/docs/job-90d":{"component":"17896441","content":"97c3ef29"},"/docs/local-language-fbb":{"component":"17896441","content":"24dcd402"},"/docs/logging-7ec":{"component":"17896441","content":"a74774ac"},"/docs/object-mapper-86e":{"component":"17896441","content":"7d3779e7"},"/docs/options-fc3":{"component":"17896441","content":"e1713ffa"},"/docs/performance-d8c":{"component":"17896441","content":"c456980b"},"/docs/process-service-1d4":{"component":"17896441","content":"e50e61ad"},"/docs/reference-050":{"component":"17896441","content":"8bbf9761"},"/docs/saas-226":{"component":"17896441","content":"1ea356f4"},"/docs/signalr-8ba":{"component":"17896441","content":"8e2b7b33"},"/docs/source-e6d":{"component":"17896441","content":"34420422"},"/docs/specification-document-bee":{"component":"17896441","content":"e0678751"},"/docs/split-db-026":{"component":"17896441","content":"03ebb857"},"/docs/tran-260":{"component":"17896441","content":"dea2fede"},"/docs/unittest-98b":{"component":"17896441","content":"3a6dbab2"},"/docs/view-engine-8d2":{"component":"17896441","content":"fa529204"}}')},function(e,t,n){var r,o;void 0===(o="function"==typeof(r=function(){var e,t,n={version:"0.2.0"},r=n.settings={minimum:.08,easing:"ease",positionUsing:"",speed:200,trickle:!0,trickleRate:.02,trickleSpeed:800,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",template:'
'};function o(e,t,n){return en?n:e}function a(e){return 100*(-1+e)}function i(e,t,n){var o;return(o="translate3d"===r.positionUsing?{transform:"translate3d("+a(e)+"%,0,0)"}:"translate"===r.positionUsing?{transform:"translate("+a(e)+"%,0)"}:{"margin-left":a(e)+"%"}).transition="all "+t+"ms "+n,o}n.configure=function(e){var t,n;for(t in e)void 0!==(n=e[t])&&e.hasOwnProperty(t)&&(r[t]=n);return this},n.status=null,n.set=function(e){var t=n.isStarted();e=o(e,r.minimum,1),n.status=1===e?null:e;var a=n.render(!t),s=a.querySelector(r.barSelector),c=r.speed,d=r.easing;return a.offsetWidth,l((function(t){""===r.positionUsing&&(r.positionUsing=n.getPositioningCSS()),u(s,i(e,c,d)),1===e?(u(a,{transition:"none",opacity:1}),a.offsetWidth,setTimeout((function(){u(a,{transition:"all "+c+"ms linear",opacity:0}),setTimeout((function(){n.remove(),t()}),c)}),c)):setTimeout(t,c)})),this},n.isStarted=function(){return"number"==typeof n.status},n.start=function(){n.status||n.set(0);var e=function(){setTimeout((function(){n.status&&(n.trickle(),e())}),r.trickleSpeed)};return r.trickle&&e(),this},n.done=function(e){return e||n.status?n.inc(.3+.5*Math.random()).set(1):this},n.inc=function(e){var t=n.status;return t?("number"!=typeof e&&(e=(1-t)*o(Math.random()*t,.1,.95)),t=o(t+e,0,.994),n.set(t)):n.start()},n.trickle=function(){return n.inc(Math.random()*r.trickleRate)},e=0,t=0,n.promise=function(r){return r&&"resolved"!==r.state()?(0===t&&n.start(),e++,t++,r.always((function(){0==--t?(e=0,n.done()):n.set((e-t)/e)})),this):this},n.render=function(e){if(n.isRendered())return document.getElementById("nprogress");c(document.documentElement,"nprogress-busy");var t=document.createElement("div");t.id="nprogress",t.innerHTML=r.template;var o,i=t.querySelector(r.barSelector),l=e?"-100":a(n.status||0),s=document.querySelector(r.parent);return u(i,{transition:"all 0 linear",transform:"translate3d("+l+"%,0,0)"}),r.showSpinner||(o=t.querySelector(r.spinnerSelector))&&p(o),s!=document.body&&c(s,"nprogress-custom-parent"),s.appendChild(t),t},n.remove=function(){d(document.documentElement,"nprogress-busy"),d(document.querySelector(r.parent),"nprogress-custom-parent");var e=document.getElementById("nprogress");e&&p(e)},n.isRendered=function(){return!!document.getElementById("nprogress")},n.getPositioningCSS=function(){var e=document.body.style,t="WebkitTransform"in e?"Webkit":"MozTransform"in e?"Moz":"msTransform"in e?"ms":"OTransform"in e?"O":"";return t+"Perspective"in e?"translate3d":t+"Transform"in e?"translate":"margin"};var l=function(){var e=[];function t(){var n=e.shift();n&&n(t)}return function(n){e.push(n),1==e.length&&t()}}(),u=function(){var e=["Webkit","O","Moz","ms"],t={};function n(e){return e.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,(function(e,t){return t.toUpperCase()}))}function r(t){var n=document.body.style;if(t in n)return t;for(var r,o=e.length,a=t.charAt(0).toUpperCase()+t.slice(1);o--;)if((r=e[o]+a)in n)return r;return t}function o(e){return e=n(e),t[e]||(t[e]=r(e))}function a(e,t,n){t=o(t),e.style[t]=n}return function(e,t){var n,r,o=arguments;if(2==o.length)for(n in t)void 0!==(r=t[n])&&t.hasOwnProperty(n)&&a(e,n,r);else a(e,o[1],o[2])}}();function s(e,t){return("string"==typeof e?e:f(e)).indexOf(" "+t+" ")>=0}function c(e,t){var n=f(e),r=n+t;s(n,t)||(e.className=r.substring(1))}function d(e,t){var n,r=f(e);s(e,t)&&(n=r.replace(" "+t+" "," "),e.className=n.substring(1,n.length-1))}function f(e){return(" "+(e.className||"")+" ").replace(/\s+/gi," ")}function p(e){e&&e.parentNode&&e.parentNode.removeChild(e)}return n})?r.call(t,n,t,e):r)||(e.exports=o)},function(e,t,n){"use strict";n.d(t,"a",(function(){return d})),n.d(t,"b",(function(){return f})),n.d(t,"c",(function(){return y})),n.d(t,"e",(function(){return w}));var r=n(1);n.d(t,"d",(function(){return r.a})),n.d(t,"f",(function(){return r.b})),n.d(t,"g",(function(){return r.c})),n.d(t,"h",(function(){return r.d})),n.d(t,"i",(function(){return r.e})),n.d(t,"j",(function(){return r.f})),n.d(t,"k",(function(){return r.g})),n.d(t,"l",(function(){return r.i})),n.d(t,"m",(function(){return r.j})),n.d(t,"n",(function(){return r.k})),n.d(t,"o",(function(){return r.l})),n.d(t,"p",(function(){return r.m})),n.d(t,"q",(function(){return r.n})),n.d(t,"r",(function(){return r.o}));var o=n(3),a=n(0),i=n.n(a),l=n(5),u=(n(7),n(2)),s=n(6),c=n(4),d=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),o=0;oe.length)return;if(!(w instanceof u)){if(h&&v!=t.length-1){if(f.lastIndex=E,!(C=f.exec(e)))break;for(var x=C.index+(m?C[1].length:0),k=C.index+C[0].length,T=v,S=E,O=t.length;T=(S+=t[T].length)&&(++v,E=S);if(t[v]instanceof u)continue;_=T-v,w=e.slice(E,S),C.index-=E}else{f.lastIndex=0;var C=f.exec(w),_=1}if(C){m&&(g=C[1]?C[1].length:0),k=(x=C.index+g)+(C=C[0].slice(g)).length;var N=w.slice(0,x),R=w.slice(k),I=[v,_];N&&(++v,E+=N.length,I.push(N));var A=new u(s,p?o.tokenize(C,p):C,b,C,h);if(I.push(A),R&&I.push(R),Array.prototype.splice.apply(t,I),1!=_&&o.matchGrammar(e,t,n,v,E,!0,s),i)break}else if(i)break}}}}},hooks:{add:function(){}},tokenize:function(e,t,n){var r=[e],a=t.rest;if(a){for(var i in a)t[i]=a[i];delete t.rest}return o.matchGrammar(e,r,t,0,0,!1),r}},(a=o.Token=function(e,t,n,r,o){this.type=e,this.content=t,this.alias=n,this.length=0|(r||"").length,this.greedy=!!o}).stringify=function(e,t,n){if("string"==typeof e)return e;if("Array"===o.util.type(e))return e.map((function(n){return a.stringify(n,t,e)})).join("");var r={type:e.type,content:a.stringify(e.content,t,n),tag:"span",classes:["token",e.type],attributes:{},language:t,parent:n};if(e.alias){var i="Array"===o.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(r.classes,i)}var l=Object.keys(r.attributes).map((function(e){return e+'="'+(r.attributes[e]||"").replace(/"/g,""")+'"'})).join(" ");return"<"+r.tag+' class="'+r.classes.join(" ")+'"'+(l?" "+l:"")+">"+r.content+""},o);i.languages.markup={comment://,prolog:/<\?[\s\S]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,inside:{punctuation:[/^=/,{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},i.languages.markup.tag.inside["attr-value"].inside.entity=i.languages.markup.entity,i.hooks.add("wrap",(function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))})),Object.defineProperty(i.languages.markup.tag,"addInlined",{value:function(e,t){var n={};n["language-"+t]={pattern:/(^$)/i,lookbehind:!0,inside:i.languages[t]},n.cdata=/^$/i;var r={"included-cdata":{pattern://i,inside:n}};r["language-"+t]={pattern:/[\s\S]+/,inside:i.languages[t]};var o={};o[e]={pattern:RegExp(/(<__[\s\S]*?>)(?:\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g,e),"i"),lookbehind:!0,greedy:!0,inside:r},i.languages.insertBefore("markup","cdata",o)}}),i.languages.xml=i.languages.extend("markup",{}),i.languages.html=i.languages.markup,i.languages.mathml=i.languages.markup,i.languages.svg=i.languages.markup,function(e){var t="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={environment:{pattern:RegExp("\\$"+t),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+t),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|x[0-9a-fA-F]{1,2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})/};e.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)\w+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b\w+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+t),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+?)\s*(?:\r?\n|\r)(?:[\s\S])*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:n},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s*(?:\r?\n|\r)(?:[\s\S])*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0},{pattern:/(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/,greedy:!0,inside:n}],environment:{pattern:RegExp("\\$?"+t),alias:"constant"},variable:n.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|aptitude|apt-cache|apt-get|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:if|then|else|elif|fi|for|while|in|case|esac|function|select|do|done|until)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|break|cd|continue|eval|exec|exit|export|getopts|hash|pwd|readonly|return|shift|test|times|trap|umask|unset|alias|bind|builtin|caller|command|declare|echo|enable|help|let|local|logout|mapfile|printf|read|readarray|source|type|typeset|ulimit|unalias|set|shopt)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:true|false)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|==?|!=?|=~|<<[<-]?|[&\d]?>>|\d?[<>]&?|&[>&]?|\|[&|]?|<=?|>=?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}};for(var r=["comment","function-name","for-or-select","assign-left","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],o=n.variable[1].inside,a=0;a=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/},i.languages.c=i.languages.extend("clike",{"class-name":{pattern:/(\b(?:enum|struct)\s+)\w+/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/,number:/(?:\b0x(?:[\da-f]+\.?[\da-f]*|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i}),i.languages.insertBefore("c","string",{macro:{pattern:/(^\s*)#\s*[a-z]+(?:[^\r\n\\]|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,alias:"property",inside:{string:{pattern:/(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/,lookbehind:!0},directive:{pattern:/(#\s*)\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/,lookbehind:!0,alias:"keyword"}}},constant:/\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/}),delete i.languages.c.boolean,i.languages.cpp=i.languages.extend("c",{"class-name":{pattern:/(\b(?:class|enum|struct)\s+)\w+/,lookbehind:!0},keyword:/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+\.?[\da-f']*|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+\.?[\d']*|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]*/i,greedy:!0},operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:true|false)\b/}),i.languages.insertBefore("cpp","string",{"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:"string",greedy:!0}}),function(e){var t=/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-]+[\s\S]*?(?:;|(?=\s*\{))/,inside:{rule:/@[\w-]+/}},url:{pattern:RegExp("url\\((?:"+t.source+"|[^\n\r()]*)\\)","i"),inside:{function:/^url/i,punctuation:/^\(|\)$/}},selector:RegExp("[^{}\\s](?:[^{};\"']|"+t.source+")*?(?=\\s*\\{)"),string:{pattern:t,greedy:!0},property:/[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,important:/!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined("style","css"),e.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:n.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:e.languages.css}},alias:"language-css"}},n.tag))}(i),i.languages.css.selector={pattern:i.languages.css.selector,inside:{"pseudo-element":/:(?:after|before|first-letter|first-line|selection)|::[-\w]+/,"pseudo-class":/:[-\w]+/,class:/\.[-:.\w]+/,id:/#[-:.\w]+/,attribute:{pattern:/\[(?:[^[\]"']|("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1)*\]/,greedy:!0,inside:{punctuation:/^\[|\]$/,"case-sensitivity":{pattern:/(\s)[si]$/i,lookbehind:!0,alias:"keyword"},namespace:{pattern:/^(\s*)[-*\w\xA0-\uFFFF]*\|(?!=)/,lookbehind:!0,inside:{punctuation:/\|$/}},attribute:{pattern:/^(\s*)[-\w\xA0-\uFFFF]+/,lookbehind:!0},value:[/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,{pattern:/(=\s*)[-\w\xA0-\uFFFF]+(?=\s*$)/,lookbehind:!0}],operator:/[|~*^$]?=/}},"n-th":[{pattern:/(\(\s*)[+-]?\d*[\dn](?:\s*[+-]\s*\d+)?(?=\s*\))/,lookbehind:!0,inside:{number:/[\dn]+/,operator:/[+-]/}},{pattern:/(\(\s*)(?:even|odd)(?=\s*\))/i,lookbehind:!0}],punctuation:/[()]/}},i.languages.insertBefore("css","property",{variable:{pattern:/(^|[^-\w\xA0-\uFFFF])--[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*/i,lookbehind:!0}}),i.languages.insertBefore("css","function",{operator:{pattern:/(\s)[+\-*\/](?=\s)/,lookbehind:!0},hexcode:/#[\da-f]{3,8}/i,entity:/\\[\da-f]{1,8}/i,unit:{pattern:/(\d)(?:%|[a-z]+)/,lookbehind:!0},number:/-?[\d.]+/}),i.languages.javascript=i.languages.extend("clike",{"class-name":[i.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,lookbehind:!0}],keyword:[{pattern:/((?:^|})\s*)(?:catch|finally)\b/,lookbehind:!0},{pattern:/(^|[^.])\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],number:/\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/,function:/#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,operator:/-[-=]?|\+[+=]?|!=?=?|<>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/}),i.languages.javascript["class-name"][0].pattern=/(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/,i.languages.insertBefore("javascript","keyword",{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=\s*($|[\r\n,.;})\]]))/,lookbehind:!0,greedy:!0},"function-variable":{pattern:/#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,lookbehind:!0,inside:i.languages.javascript},{pattern:/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,inside:i.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,lookbehind:!0,inside:i.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,lookbehind:!0,inside:i.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),i.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}|(?!\${)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},rest:i.languages.javascript}},string:/[\s\S]+/}}}),i.languages.markup&&i.languages.markup.tag.addInlined("script","javascript"),i.languages.js=i.languages.javascript,function(e){var t=e.util.clone(e.languages.javascript);e.languages.jsx=e.languages.extend("markup",t),e.languages.jsx.tag.pattern=/<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^}]*\}|[^{}])*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}))*\s*\/?)?>/i,e.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/i,e.languages.jsx.tag.inside["attr-value"].pattern=/=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i,e.languages.jsx.tag.inside.tag.inside["class-name"]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,e.languages.insertBefore("inside","attr-name",{spread:{pattern:/\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}/,inside:{punctuation:/\.{3}|[{}.]/,"attr-value":/\w+/}}},e.languages.jsx.tag),e.languages.insertBefore("inside","attr-value",{script:{pattern:/=(\{(?:\{(?:\{[^}]*\}|[^}])*\}|[^}])+\})/i,inside:{"script-punctuation":{pattern:/^=(?={)/,alias:"punctuation"},rest:e.languages.jsx},alias:"language-javascript"}},e.languages.jsx.tag);var n=function(e){return e?"string"==typeof e?e:"string"==typeof e.content?e.content:e.content.map(n).join(""):""},r=function(t){for(var o=[],a=0;a0&&o[o.length-1].tagName===n(i.content[0].content[1])&&o.pop():"/>"===i.content[i.content.length-1].content||o.push({tagName:n(i.content[0].content[1]),openedBraces:0}):o.length>0&&"punctuation"===i.type&&"{"===i.content?o[o.length-1].openedBraces++:o.length>0&&o[o.length-1].openedBraces>0&&"punctuation"===i.type&&"}"===i.content?o[o.length-1].openedBraces--:l=!0),(l||"string"==typeof i)&&o.length>0&&0===o[o.length-1].openedBraces){var u=n(i);a0&&("string"==typeof t[a-1]||"plain-text"===t[a-1].type)&&(u=n(t[a-1])+u,t.splice(a-1,1),a--),t[a]=new e.Token("plain-text",u,null,u)}i.content&&"string"!=typeof i.content&&r(i.content)}};e.hooks.add("after-tokenize",(function(e){"jsx"!==e.language&&"tsx"!==e.language||r(e.tokens)}))}(i),function(e){var t=e.languages.javadoclike={parameter:{pattern:/(^\s*(?:\/{3}|\*|\/\*\*)\s*@(?:param|arg|arguments)\s+)\w+/m,lookbehind:!0},keyword:{pattern:/(^\s*(?:\/{3}|\*|\/\*\*)\s*|\{)@[a-z][a-zA-Z-]+\b/m,lookbehind:!0},punctuation:/[{}]/};Object.defineProperty(t,"addSupport",{value:function(t,n){"string"==typeof t&&(t=[t]),t.forEach((function(t){!function(t,n){var r="doc-comment",o=e.languages[t];if(o){var a=o[r];if(!a){var i={"doc-comment":{pattern:/(^|[^\\])\/\*\*[^/][\s\S]*?(?:\*\/|$)/,alias:"comment"}};a=(o=e.languages.insertBefore(t,"comment",i))[r]}if(a instanceof RegExp&&(a=o[r]={pattern:a}),Array.isArray(a))for(var l=0,u=a.length;l>>?=?|->|([-+&|])\2|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0}}),e.languages.insertBefore("java","class-name",{annotation:{alias:"punctuation",pattern:/(^|[^.])@\w+/,lookbehind:!0},namespace:{pattern:/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)[a-z]\w*(\.[a-z]\w*)+/,lookbehind:!0,inside:{punctuation:/\./}},generics:{pattern:/<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<[\w\s,.&?]*>)*>)*>)*>/,inside:{"class-name":n,keyword:t,punctuation:/[<>(),.:]/,operator:/[?&|]/}}})}(i),function(e){function t(e,t){return"___"+e.toUpperCase()+t+"___"}Object.defineProperties(e.languages["markup-templating"]={},{buildPlaceholders:{value:function(n,r,o,a){if(n.language===r){var i=n.tokenStack=[];n.code=n.code.replace(o,(function(e){if("function"==typeof a&&!a(e))return e;for(var o,l=i.length;-1!==n.code.indexOf(o=t(r,l));)++l;return i[l]=e,o})),n.grammar=e.languages.markup}}},tokenizePlaceholders:{value:function(n,r){if(n.language===r&&n.tokenStack){n.grammar=e.languages[r];var o=0,a=Object.keys(n.tokenStack);!function i(l){for(var u=0;u=a.length);u++){var s=l[u];if("string"==typeof s||s.content&&"string"==typeof s.content){var c=a[o],d=n.tokenStack[c],f="string"==typeof s?s:s.content,p=t(r,c),m=f.indexOf(p);if(m>-1){++o;var h=f.substring(0,m),g=new e.Token(r,e.tokenize(d,n.grammar),"language-"+r,d),b=f.substring(m+p.length),y=[];h&&y.push.apply(y,i([h])),y.push(g),b&&y.push.apply(y,i([b])),"string"==typeof s?l.splice.apply(l,[u,1].concat(y)):s.content=y}}else s.content&&i(s.content)}return l}(n.tokens)}}}})}(i),function(e){e.languages.php=e.languages.extend("clike",{keyword:/\b(?:__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|finally|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|new|or|parent|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i,boolean:{pattern:/\b(?:false|true)\b/i,alias:"constant"},constant:[/\b[A-Z_][A-Z0-9_]*\b/,/\b(?:null)\b/i],comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,lookbehind:!0}}),e.languages.insertBefore("php","string",{"shell-comment":{pattern:/(^|[^\\])#.*/,lookbehind:!0,alias:"comment"}}),e.languages.insertBefore("php","comment",{delimiter:{pattern:/\?>$|^<\?(?:php(?=\s)|=)?/i,alias:"important"}}),e.languages.insertBefore("php","keyword",{variable:/\$+(?:\w+\b|(?={))/i,package:{pattern:/(\\|namespace\s+|use\s+)[\w\\]+/,lookbehind:!0,inside:{punctuation:/\\/}}}),e.languages.insertBefore("php","operator",{property:{pattern:/(->)[\w]+/,lookbehind:!0}});var t={pattern:/{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[.+?]|->\w+)*)/,lookbehind:!0,inside:{rest:e.languages.php}};e.languages.insertBefore("php","string",{"nowdoc-string":{pattern:/<<<'([^']+)'(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;/,greedy:!0,alias:"string",inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},"heredoc-string":{pattern:/<<<(?:"([^"]+)"(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;|([a-z_]\w*)(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\2;)/i,greedy:!0,alias:"string",inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:t}},"single-quoted-string":{pattern:/'(?:\\[\s\S]|[^\\'])*'/,greedy:!0,alias:"string"},"double-quoted-string":{pattern:/"(?:\\[\s\S]|[^\\"])*"/,greedy:!0,alias:"string",inside:{interpolation:t}}}),delete e.languages.php.string,e.hooks.add("before-tokenize",(function(t){if(/<\?/.test(t.code)){e.languages["markup-templating"].buildPlaceholders(t,"php",/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#)(?:[^?\n\r]|\?(?!>))*|\/\*[\s\S]*?(?:\*\/|$))*?(?:\?>|$)/gi)}})),e.hooks.add("after-tokenize",(function(t){e.languages["markup-templating"].tokenizePlaceholders(t,"php")}))}(i),function(e){var t=e.languages.javascript,n=/{(?:[^{}]|{(?:[^{}]|{[^{}]*})*})+}/.source,r="(@(?:param|arg|argument|property)\\s+(?:"+n+"\\s+)?)";e.languages.jsdoc=e.languages.extend("javadoclike",{parameter:{pattern:RegExp(r+/[$\w\xA0-\uFFFF.]+(?=\s|$)/.source),lookbehind:!0,inside:{punctuation:/\./}}}),e.languages.insertBefore("jsdoc","keyword",{"optional-parameter":{pattern:RegExp(r+/\[[$\w\xA0-\uFFFF.]+(?:=[^[\]]+)?\](?=\s|$)/.source),lookbehind:!0,inside:{parameter:{pattern:/(^\[)[$\w\xA0-\uFFFF\.]+/,lookbehind:!0,inside:{punctuation:/\./}},code:{pattern:/(=)[\s\S]*(?=\]$)/,lookbehind:!0,inside:t,alias:"language-javascript"},punctuation:/[=[\]]/}},"class-name":[{pattern:RegExp("(@[a-z]+\\s+)"+n),lookbehind:!0,inside:{punctuation:/[.,:?=<>|{}()[\]]/}},{pattern:/(@(?:augments|extends|class|interface|memberof!?|this)\s+)[A-Z]\w*(?:\.[A-Z]\w*)*/,lookbehind:!0,inside:{punctuation:/\./}}],example:{pattern:/(@example\s+)[^@]+?(?=\s*(?:\*\s*)?(?:@\w|\*\/))/,lookbehind:!0,inside:{code:{pattern:/^(\s*(?:\*\s*)?).+$/m,lookbehind:!0,inside:t,alias:"language-javascript"}}}}),e.languages.javadoclike.addSupport("javascript",e.languages.jsdoc)}(i),i.languages.actionscript=i.languages.extend("javascript",{keyword:/\b(?:as|break|case|catch|class|const|default|delete|do|else|extends|finally|for|function|if|implements|import|in|instanceof|interface|internal|is|native|new|null|package|private|protected|public|return|super|switch|this|throw|try|typeof|use|var|void|while|with|dynamic|each|final|get|include|namespace|native|override|set|static)\b/,operator:/\+\+|--|(?:[+\-*\/%^]|&&?|\|\|?|<>?>?|[!=]=?)=?|[~?@]/}),i.languages.actionscript["class-name"].alias="function",i.languages.markup&&i.languages.insertBefore("actionscript","string",{xml:{pattern:/(^|[^.])<\/?\w+(?:\s+[^\s>\/=]+=("|')(?:\\[\s\S]|(?!\2)[^\\])*\2)*\s*\/?>/,lookbehind:!0,inside:{rest:i.languages.markup}}}),function(e){var t=/#(?!\{).+/,n={pattern:/#\{[^}]+\}/,alias:"variable"};e.languages.coffeescript=e.languages.extend("javascript",{comment:t,string:[{pattern:/'(?:\\[\s\S]|[^\\'])*'/,greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,greedy:!0,inside:{interpolation:n}}],keyword:/\b(?:and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,"class-member":{pattern:/@(?!\d)\w+/,alias:"variable"}}),e.languages.insertBefore("coffeescript","comment",{"multiline-comment":{pattern:/###[\s\S]+?###/,alias:"comment"},"block-regex":{pattern:/\/{3}[\s\S]*?\/{3}/,alias:"regex",inside:{comment:t,interpolation:n}}}),e.languages.insertBefore("coffeescript","string",{"inline-javascript":{pattern:/`(?:\\[\s\S]|[^\\`])*`/,inside:{delimiter:{pattern:/^`|`$/,alias:"punctuation"},rest:e.languages.javascript}},"multiline-string":[{pattern:/'''[\s\S]*?'''/,greedy:!0,alias:"string"},{pattern:/"""[\s\S]*?"""/,greedy:!0,alias:"string",inside:{interpolation:n}}]}),e.languages.insertBefore("coffeescript","keyword",{property:/(?!\d)\w+(?=\s*:(?!:))/}),delete e.languages.coffeescript["template-string"],e.languages.coffee=e.languages.coffeescript}(i),function(e){e.languages.insertBefore("javascript","function-variable",{"method-variable":{pattern:RegExp("(\\.\\s*)"+e.languages.javascript["function-variable"].pattern.source),lookbehind:!0,alias:["function-variable","method","function","property-access"]}}),e.languages.insertBefore("javascript","function",{method:{pattern:RegExp("(\\.\\s*)"+e.languages.javascript.function.source),lookbehind:!0,alias:["function","property-access"]}}),e.languages.insertBefore("javascript","constant",{"known-class-name":[{pattern:/\b(?:(?:(?:Uint|Int)(?:8|16|32)|Uint8Clamped|Float(?:32|64))?Array|ArrayBuffer|BigInt|Boolean|DataView|Date|Error|Function|Intl|JSON|Math|Number|Object|Promise|Proxy|Reflect|RegExp|String|Symbol|(?:Weak)?(?:Set|Map)|WebAssembly)\b/,alias:"class-name"},{pattern:/\b(?:[A-Z]\w*)Error\b/,alias:"class-name"}]}),e.languages.javascript.keyword.unshift({pattern:/\b(?:as|default|export|from|import)\b/,alias:"module"},{pattern:/\bnull\b/,alias:["null","nil"]},{pattern:/\bundefined\b/,alias:"nil"}),e.languages.insertBefore("javascript","operator",{spread:{pattern:/\.{3}/,alias:"operator"},arrow:{pattern:/=>/,alias:"operator"}}),e.languages.insertBefore("javascript","punctuation",{"property-access":{pattern:/(\.\s*)#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*/,lookbehind:!0},"maybe-class-name":{pattern:/(^|[^$\w\xA0-\uFFFF])[A-Z][$\w\xA0-\uFFFF]+/,lookbehind:!0},dom:{pattern:/\b(?:document|location|navigator|performance|(?:local|session)Storage|window)\b/,alias:"variable"},console:{pattern:/\bconsole(?=\s*\.)/,alias:"class-name"}});for(var t=["function","function-variable","method","method-variable","property-access"],n=0;n))/i,delete e.languages.flow.parameter,e.languages.insertBefore("flow","operator",{"flow-punctuation":{pattern:/\{\||\|\}/,alias:"punctuation"}}),Array.isArray(e.languages.flow.keyword)||(e.languages.flow.keyword=[e.languages.flow.keyword]),e.languages.flow.keyword.unshift({pattern:/(^|[^$]\b)(?:type|opaque|declare|Class)\b(?!\$)/,lookbehind:!0},{pattern:/(^|[^$]\B)\$(?:await|Diff|Exact|Keys|ObjMap|PropertyType|Shape|Record|Supertype|Subtype|Enum)\b(?!\$)/,lookbehind:!0})}(i),i.languages.n4js=i.languages.extend("javascript",{keyword:/\b(?:any|Array|boolean|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|module|new|null|number|package|private|protected|public|return|set|static|string|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/}),i.languages.insertBefore("n4js","constant",{annotation:{pattern:/@+\w+/,alias:"operator"}}),i.languages.n4jsd=i.languages.n4js,i.languages.typescript=i.languages.extend("javascript",{keyword:/\b(?:abstract|as|async|await|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|module|namespace|new|null|of|package|private|protected|public|readonly|return|require|set|static|super|switch|this|throw|try|type|typeof|var|void|while|with|yield)\b/,builtin:/\b(?:string|Function|any|number|boolean|Array|symbol|console|Promise|unknown|never)\b/}),i.languages.ts=i.languages.typescript,function(e){var t=e.languages.javascript["template-string"],n=t.pattern.source,r=t.inside.interpolation,o=r.inside["interpolation-punctuation"],a=r.pattern.source;function i(t,r){if(e.languages[t])return{pattern:RegExp("((?:"+r+")\\s*)"+n),lookbehind:!0,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},"embedded-code":{pattern:/[\s\S]+/,alias:t}}}}function l(e,t){return"___"+t.toUpperCase()+"_"+e+"___"}function u(t,n,r){var o={code:t,grammar:n,language:r};return e.hooks.run("before-tokenize",o),o.tokens=e.tokenize(o.code,o.grammar),e.hooks.run("after-tokenize",o),o.tokens}function s(t){var n={};n["interpolation-punctuation"]=o;var a=e.tokenize(t,n);if(3===a.length){var i=[1,1];i.push.apply(i,u(a[1],e.languages.javascript,"javascript")),a.splice.apply(a,i)}return new e.Token("interpolation",a,r.alias,t)}function c(t,n,r){var o=e.tokenize(t,{interpolation:{pattern:RegExp(a),lookbehind:!0}}),i=0,c={},d=u(o.map((function(e){if("string"==typeof e)return e;for(var n,o=e.content;-1!==t.indexOf(n=l(i++,r)););return c[n]=o,n})).join(""),n,r),f=Object.keys(c);return i=0,function e(t){for(var n=0;n=f.length)return;var r=t[n];if("string"==typeof r||"string"==typeof r.content){var o=f[i],a="string"==typeof r?r:r.content,l=a.indexOf(o);if(-1!==l){++i;var u=a.substring(0,l),d=s(c[o]),p=a.substring(l+o.length),m=[];if(u&&m.push(u),m.push(d),p){var h=[p];e(h),m.push.apply(m,h)}"string"==typeof r?(t.splice.apply(t,[n,1].concat(m)),n+=m.length-1):r.content=m}}else{var g=r.content;Array.isArray(g)?e(g):e([g])}}}(d),new e.Token(r,d,"language-"+r,t)}e.languages.javascript["template-string"]=[i("css",/\b(?:styled(?:\([^)]*\))?(?:\s*\.\s*\w+(?:\([^)]*\))*)*|css(?:\s*\.\s*(?:global|resolve))?|createGlobalStyle|keyframes)/.source),i("html",/\bhtml|\.\s*(?:inner|outer)HTML\s*\+?=/.source),i("svg",/\bsvg/.source),i("markdown",/\b(?:md|markdown)/.source),i("graphql",/\b(?:gql|graphql(?:\s*\.\s*experimental)?)/.source),t].filter(Boolean);var d={javascript:!0,js:!0,typescript:!0,ts:!0,jsx:!0,tsx:!0};function f(e){return"string"==typeof e?e:Array.isArray(e)?e.map(f).join(""):f(e.content)}e.hooks.add("after-tokenize",(function(t){t.language in d&&function t(n){for(var r=0,o=n.length;r/g,t),n&&(e=e+"|"+e.replace(/_/g,"\\*")),RegExp(/((?:^|[^\\])(?:\\{2})*)/.source+"(?:"+e+")")}var r=/(?:\\.|``.+?``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,o=/\|?__(?:\|__)+\|?(?:(?:\r?\n|\r)|$)/.source.replace(/__/g,r),a=/\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\r?\n|\r)/.source;e.languages.markdown=e.languages.extend("markup",{}),e.languages.insertBefore("markdown","prolog",{blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:"punctuation"},table:{pattern:RegExp("^"+o+a+"(?:"+o+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+o+a+")(?:"+o+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:e.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+o+")"+a+"$"),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp("^"+o+"$"),inside:{"table-header":{pattern:RegExp(r),alias:"important",inside:e.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/(^[ \t]*(?:\r?\n|\r))(?: {4}|\t).+(?:(?:\r?\n|\r)(?: {4}|\t).+)*/m,lookbehind:!0,alias:"keyword"},{pattern:/``.+?``|`[^`\r\n]+`/,alias:"keyword"},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\r?\n|\r))[\s\S]+?(?=(?:\r?\n|\r)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\r?\n|\r)(?:==+|--+)(?=[ \t]*$)/m,alias:"important",inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#+.+/m,lookbehind:!0,alias:"important",inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:"punctuation"},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:"punctuation"},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:"url"},bold:{pattern:n(/__(?:(?!_)|_(?:(?!_))+_)+__/.source,!0),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(/_(?:(?!_)|__(?:(?!_))+__)+_/.source,!0),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(/(~~?)(?:(?!~))+?\2/.source,!1),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},url:{pattern:n(/!?\[(?:(?!\]))+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)| ?\[(?:(?!\]))+\])/.source,!1),lookbehind:!0,greedy:!0,inside:{variable:{pattern:/(\[)[^\]]+(?=\]$)/,lookbehind:!0},content:{pattern:/(^!?\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},string:{pattern:/"(?:\\.|[^"\\])*"(?=\)$)/}}}}),["url","bold","italic","strike"].forEach((function(t){["url","bold","italic","strike"].forEach((function(n){t!==n&&(e.languages.markdown[t].inside.content.inside[n]=e.languages.markdown[n])}))})),e.hooks.add("after-tokenize",(function(e){"markdown"!==e.language&&"md"!==e.language||function e(t){if(t&&"string"!=typeof t)for(var n=0,r=t.length;n",unchanged:" ",diff:"!"};Object.keys(t).forEach((function(n){var r=t[n],o=[];/^\w+$/.test(n)||o.push(/\w+/.exec(n)[0]),"diff"===n&&o.push("bold"),e.languages.diff[n]={pattern:RegExp("^(?:["+r+"].*(?:\r\n?|\n|(?![\\s\\S])))+","m"),alias:o}})),Object.defineProperty(e.languages.diff,"PREFIXES",{value:t})}(i),i.languages.git={comment:/^#.*/m,deleted:/^[-\u2013].*/m,inserted:/^\+.*/m,string:/("|')(?:\\.|(?!\1)[^\\\r\n])*\1/m,command:{pattern:/^.*\$ git .*$/m,inside:{parameter:/\s--?\w+/m}},coord:/^@@.*@@$/m,commit_sha1:/^commit \w{40}$/m},i.languages.go=i.languages.extend("clike",{keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,builtin:/\b(?:bool|byte|complex(?:64|128)|error|float(?:32|64)|rune|string|u?int(?:8|16|32|64)?|uintptr|append|cap|close|complex|copy|delete|imag|len|make|new|panic|print(?:ln)?|real|recover)\b/,boolean:/\b(?:_|iota|nil|true|false)\b/,operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,number:/(?:\b0x[a-f\d]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[-+]?\d+)?)i?/i,string:{pattern:/(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,greedy:!0}}),delete i.languages.go["class-name"],function(e){e.languages.handlebars={comment:/\{\{![\s\S]*?\}\}/,delimiter:{pattern:/^\{\{\{?|\}\}\}?$/i,alias:"punctuation"},string:/(["'])(?:\\.|(?!\1)[^\\\r\n])*\1/,number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,boolean:/\b(?:true|false)\b/,block:{pattern:/^(\s*~?\s*)[#\/]\S+?(?=\s*~?\s*$|\s)/i,lookbehind:!0,alias:"keyword"},brackets:{pattern:/\[[^\]]+\]/,inside:{punctuation:/\[|\]/,variable:/[\s\S]+/}},punctuation:/[!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~]/,variable:/[^!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~\s]+/},e.hooks.add("before-tokenize",(function(t){e.languages["markup-templating"].buildPlaceholders(t,"handlebars",/\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/g)})),e.hooks.add("after-tokenize",(function(t){e.languages["markup-templating"].tokenizePlaceholders(t,"handlebars")}))}(i),i.languages.json={property:{pattern:/"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,greedy:!0},string:{pattern:/"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,greedy:!0},comment:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,number:/-?\d+\.?\d*(e[+-]?\d+)?/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:true|false)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},i.languages.less=i.languages.extend("css",{comment:[/\/\*[\s\S]*?\*\//,{pattern:/(^|[^\\])\/\/.*/,lookbehind:!0}],atrule:{pattern:/@[\w-]+?(?:\([^{}]+\)|[^(){};])*?(?=\s*\{)/i,inside:{punctuation:/[:()]/}},selector:{pattern:/(?:@\{[\w-]+\}|[^{};\s@])(?:@\{[\w-]+\}|\([^{}]*\)|[^{};@])*?(?=\s*\{)/,inside:{variable:/@+[\w-]+/}},property:/(?:@\{[\w-]+\}|[\w-])+(?:\+_?)?(?=\s*:)/i,operator:/[+\-*\/]/}),i.languages.insertBefore("less","property",{variable:[{pattern:/@[\w-]+\s*:/,inside:{punctuation:/:/}},/@@?[\w-]+/],"mixin-usage":{pattern:/([{;]\s*)[.#](?!\d)[\w-]+.*?(?=[(;])/,lookbehind:!0,alias:"function"}}),i.languages.makefile={comment:{pattern:/(^|[^\\])#(?:\\(?:\r\n|[\s\S])|[^\\\r\n])*/,lookbehind:!0},string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},builtin:/\.[A-Z][^:#=\s]+(?=\s*:(?!=))/,symbol:{pattern:/^[^:=\r\n]+(?=\s*:(?!=))/m,inside:{variable:/\$+(?:[^(){}:#=\s]+|(?=[({]))/}},variable:/\$+(?:[^(){}:#=\s]+|\([@*%<^+?][DF]\)|(?=[({]))/,keyword:[/-include\b|\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|include|override|private|sinclude|undefine|unexport|vpath)\b/,{pattern:/(\()(?:addsuffix|abspath|and|basename|call|dir|error|eval|file|filter(?:-out)?|findstring|firstword|flavor|foreach|guile|if|info|join|lastword|load|notdir|or|origin|patsubst|realpath|shell|sort|strip|subst|suffix|value|warning|wildcard|word(?:s|list)?)(?=[ \t])/,lookbehind:!0}],operator:/(?:::|[?:+!])?=|[|@]/,punctuation:/[:;(){}]/},i.languages.objectivec=i.languages.extend("c",{keyword:/\b(?:asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while|in|self|super)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/,string:/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|@"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,operator:/-[->]?|\+\+?|!=?|<>?=?|==?|&&?|\|\|?|[~^%?*\/@]/}),delete i.languages.objectivec["class-name"],i.languages.ocaml={comment:/\(\*[\s\S]*?\*\)/,string:[{pattern:/"(?:\\.|[^\\\r\n"])*"/,greedy:!0},{pattern:/(['`])(?:\\(?:\d+|x[\da-f]+|.)|(?!\1)[^\\\r\n])\1/i,greedy:!0}],number:/\b(?:0x[\da-f][\da-f_]+|(?:0[bo])?\d[\d_]*\.?[\d_]*(?:e[+-]?[\d_]+)?)/i,type:{pattern:/\B['`]\w*/,alias:"variable"},directive:{pattern:/\B#\w+/,alias:"function"},keyword:/\b(?:as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|match|method|module|mutable|new|object|of|open|prefix|private|rec|then|sig|struct|to|try|type|val|value|virtual|where|while|with)\b/,boolean:/\b(?:false|true)\b/,operator:/:=|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lxor|lsl|lsr|mod|nor|or)\b/,punctuation:/[(){}\[\]|_.,:;]/},i.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0},"string-interpolation":{pattern:/(?:f|rf|fr)(?:("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:{{)*){(?!{)(?:[^{}]|{(?!{)(?:[^{}]|{(?!{)(?:[^{}])+})+})+}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|rb|br)?("""|''')[\s\S]+?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|rb|br)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^\s*)@\w+(?:\.\w+)*/i,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:and|as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:True|False|None)\b/,number:/(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},i.languages.python["string-interpolation"].inside.interpolation.inside.rest=i.languages.python,i.languages.py=i.languages.python,i.languages.reason=i.languages.extend("clike",{comment:{pattern:/(^|[^\\])\/\*[\s\S]*?\*\//,lookbehind:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^\\\r\n"])*"/,greedy:!0},"class-name":/\b[A-Z]\w*/,keyword:/\b(?:and|as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|method|module|mutable|new|nonrec|object|of|open|or|private|rec|sig|struct|switch|then|to|try|type|val|virtual|when|while|with)\b/,operator:/\.{3}|:[:=]|\|>|->|=(?:==?|>)?|<=?|>=?|[|^?'#!~`]|[+\-*\/]\.?|\b(?:mod|land|lor|lxor|lsl|lsr|asr)\b/}),i.languages.insertBefore("reason","class-name",{character:{pattern:/'(?:\\x[\da-f]{2}|\\o[0-3][0-7][0-7]|\\\d{3}|\\.|[^'\\\r\n])'/,alias:"string"},constructor:{pattern:/\b[A-Z]\w*\b(?!\s*\.)/,alias:"variable"},label:{pattern:/\b[a-z]\w*(?=::)/,alias:"symbol"}}),delete i.languages.reason.function,function(e){e.languages.sass=e.languages.extend("css",{comment:{pattern:/^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t]+.+)*/m,lookbehind:!0}}),e.languages.insertBefore("sass","atrule",{"atrule-line":{pattern:/^(?:[ \t]*)[@+=].+/m,inside:{atrule:/(?:@[\w-]+|[+=])/m}}}),delete e.languages.sass.atrule;var t=/\$[-\w]+|#\{\$[-\w]+\}/,n=[/[+*\/%]|[=!]=|<=?|>=?|\b(?:and|or|not)\b/,{pattern:/(\s+)-(?=\s)/,lookbehind:!0}];e.languages.insertBefore("sass","property",{"variable-line":{pattern:/^[ \t]*\$.+/m,inside:{punctuation:/:/,variable:t,operator:n}},"property-line":{pattern:/^[ \t]*(?:[^:\s]+ *:.*|:[^:\s]+.*)/m,inside:{property:[/[^:\s]+(?=\s*:)/,{pattern:/(:)[^:\s]+/,lookbehind:!0}],punctuation:/:/,variable:t,operator:n,important:e.languages.sass.important}}}),delete e.languages.sass.property,delete e.languages.sass.important,e.languages.insertBefore("sass","punctuation",{selector:{pattern:/([ \t]*)\S(?:,?[^,\r\n]+)*(?:,(?:\r?\n|\r)\1[ \t]+\S(?:,?[^,\r\n]+)*)*/,lookbehind:!0}})}(i),i.languages.scss=i.languages.extend("css",{comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,lookbehind:!0},atrule:{pattern:/@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,inside:{rule:/@[\w-]+/}},url:/(?:[-a-z]+-)?url(?=\()/i,selector:{pattern:/(?=\S)[^@;{}()]?(?:[^@;{}()]|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}]+[:{][^}]+))/m,inside:{parent:{pattern:/&/,alias:"important"},placeholder:/%[-\w]+/,variable:/\$[-\w]+|#\{\$[-\w]+\}/}},property:{pattern:/(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/,inside:{variable:/\$[-\w]+|#\{\$[-\w]+\}/}}}),i.languages.insertBefore("scss","atrule",{keyword:[/@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,{pattern:/( +)(?:from|through)(?= )/,lookbehind:!0}]}),i.languages.insertBefore("scss","important",{variable:/\$[-\w]+|#\{\$[-\w]+\}/}),i.languages.insertBefore("scss","function",{placeholder:{pattern:/%[-\w]+/,alias:"selector"},statement:{pattern:/\B!(?:default|optional)\b/i,alias:"keyword"},boolean:/\b(?:true|false)\b/,null:{pattern:/\bnull\b/,alias:"keyword"},operator:{pattern:/(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,lookbehind:!0}}),i.languages.scss.atrule.inside.rest=i.languages.scss,i.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURNS?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:TRUE|FALSE|NULL)\b/i,number:/\b0x[\da-f]+\b|\b\d+\.?\d*|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/},function(e){var t={url:/url\((["']?).*?\1\)/i,string:{pattern:/("|')(?:(?!\1)[^\\\r\n]|\\(?:\r\n|[\s\S]))*\1/,greedy:!0},interpolation:null,func:null,important:/\B!(?:important|optional)\b/i,keyword:{pattern:/(^|\s+)(?:(?:if|else|for|return|unless)(?=\s+|$)|@[\w-]+)/,lookbehind:!0},hexcode:/#[\da-f]{3,6}/i,number:/\b\d+(?:\.\d+)?%?/,boolean:/\b(?:true|false)\b/,operator:[/~|[+!\/%<>?=]=?|[-:]=|\*[*=]?|\.+|&&|\|\||\B-\B|\b(?:and|in|is(?: a| defined| not|nt)?|not|or)\b/],punctuation:/[{}()\[\];:,]/};t.interpolation={pattern:/\{[^\r\n}:]+\}/,alias:"variable",inside:{delimiter:{pattern:/^{|}$/,alias:"punctuation"},rest:t}},t.func={pattern:/[\w-]+\([^)]*\).*/,inside:{function:/^[^(]+/,rest:t}},e.languages.stylus={comment:{pattern:/(^|[^\\])(\/\*[\s\S]*?\*\/|\/\/.*)/,lookbehind:!0},"atrule-declaration":{pattern:/(^\s*)@.+/m,lookbehind:!0,inside:{atrule:/^@[\w-]+/,rest:t}},"variable-declaration":{pattern:/(^[ \t]*)[\w$-]+\s*.?=[ \t]*(?:(?:\{[^}]*\}|.+)|$)/m,lookbehind:!0,inside:{variable:/^\S+/,rest:t}},statement:{pattern:/(^[ \t]*)(?:if|else|for|return|unless)[ \t]+.+/m,lookbehind:!0,inside:{keyword:/^\S+/,rest:t}},"property-declaration":{pattern:/((?:^|\{)([ \t]*))(?:[\w-]|\{[^}\r\n]+\})+(?:\s*:\s*|[ \t]+)[^{\r\n]*(?:;|[^{\r\n,](?=$)(?!(\r?\n|\r)(?:\{|\2[ \t]+)))/m,lookbehind:!0,inside:{property:{pattern:/^[^\s:]+/,inside:{interpolation:t.interpolation}},rest:t}},selector:{pattern:/(^[ \t]*)(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:\([^)\r\n]*\))?|\{[^}\r\n]+\})+)(?:(?:\r?\n|\r)(?:\1(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:\([^)\r\n]*\))?|\{[^}\r\n]+\})+)))*(?:,$|\{|(?=(?:\r?\n|\r)(?:\{|\1[ \t]+)))/m,lookbehind:!0,inside:{interpolation:t.interpolation,punctuation:/[{},]/}},func:t.func,string:t.string,interpolation:t.interpolation,punctuation:/[{}()\[\];:.]/}}(i);var l=i.util.clone(i.languages.typescript);i.languages.tsx=i.languages.extend("jsx",l),i.languages.wasm={comment:[/\(;[\s\S]*?;\)/,{pattern:/;;.*/,greedy:!0}],string:{pattern:/"(?:\\[\s\S]|[^"\\])*"/,greedy:!0},keyword:[{pattern:/\b(?:align|offset)=/,inside:{operator:/=/}},{pattern:/\b(?:(?:f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))?|memory\.(?:grow|size))\b/,inside:{punctuation:/\./}},/\b(?:anyfunc|block|br(?:_if|_table)?|call(?:_indirect)?|data|drop|elem|else|end|export|func|get_(?:global|local)|global|if|import|local|loop|memory|module|mut|nop|offset|param|result|return|select|set_(?:global|local)|start|table|tee_local|then|type|unreachable)\b/],variable:/\$[\w!#$%&'*+\-./:<=>?@\\^_`|~]+/i,number:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/,punctuation:/[()]/},i.languages.yaml={scalar:{pattern:/([\-:]\s*(?:![^\s]+)?[ \t]*[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)[^\r\n]+(?:\2[^\r\n]+)*)/,lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:/(\s*(?:^|[:\-,[{\r\n?])[ \t]*(?:![^\s]+)?[ \t]*)[^\r\n{[\]},#\s]+?(?=\s*:\s)/,lookbehind:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:/([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?)?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?)(?=[ \t]*(?:$|,|]|}))/m,lookbehind:!0,alias:"number"},boolean:{pattern:/([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:true|false)[ \t]*(?=$|,|]|})/im,lookbehind:!0,alias:"important"},null:{pattern:/([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:null|~)[ \t]*(?=$|,|]|})/im,lookbehind:!0,alias:"important"},string:{pattern:/([:\-,[{]\s*(?:![^\s]+)?[ \t]*)("|')(?:(?!\2)[^\\\r\n]|\\.)*\2(?=[ \t]*(?:$|,|]|}|\s*#))/m,lookbehind:!0,greedy:!0},number:{pattern:/([:\-,[{]\s*(?:![^\s]+)?[ \t]*)[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+\.?\d*|\.?\d+)(?:e[+-]?\d+)?|\.inf|\.nan)[ \t]*(?=$|,|]|})/im,lookbehind:!0},tag:/![^\s]+/,important:/[&*][\w]+/,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},i.languages.yml=i.languages.yaml,t.a=i},function(e,t,n){"use strict";var r=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function i(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(o){return!1}}()?Object.assign:function(e,t){for(var n,l,u=i(e),s=1;sR.length&&R.push(e)}function P(e,t,n,r){var o=typeof e;"undefined"!==o&&"boolean"!==o||(e=null);var l=!1;if(null===e)l=!0;else switch(o){case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case a:case i:l=!0}}if(l)return n(r,e,""===t?"."+F(e,0):t),1;if(l=0,t=""===t?".":t+":",Array.isArray(e))for(var u=0;u