मुख्य सामग्री पर जाएँ

Inventory and Orders API for .NET C# and MySQL

ASP.NET Core और MySQL का ऐसा कोड जो आख़िरी यूनिट दो बार नहीं बेचता, किसी बदलाव को दोहराता नहीं और डेटाबेस कनेक्शन पर बोझ नहीं बढ़ने देता।

  • .NET SDK
  • C#
  • ASP.NET Core
  • EF Core
  • MySql.EntityFrameworkCore

स्क्रीनशॉट

11 में से स्क्रीनशॉट 1: टाइटल कार्ड: Inventory and Orders API, .NET C# सोर्स कोड, तकनीकों की सूची और एक कोड विंडो के साथ जिसमें आख़िरी यूनिट के दो ऑर्डर हैं: एक का जवाब 201 Created और दूसरे का 409 Conflict।

टाइटल कार्ड: Inventory and Orders API, .NET C# सोर्स कोड, तकनीकों की सूची और एक कोड विंडो के साथ जिसमें आख़िरी यूनिट के दो ऑर्डर हैं: एक का जवाब 201 Created और दूसरे का 409 Conflict।

एक बार का मूल्य

  • ₹999+ GST, चेकआउट पर
  • $19
  • भुगतान की पुष्टि होते ही इसे अपनी लाइब्रेरी से डाउनलोड करें।
  • इस प्रोजेक्ट का हर बाद वाला रिलीज़ बिना अतिरिक्त शुल्क के शामिल है।
नवीनतम रिलीज़
1.0.0 · 6 नव॰ 2026
लाइसेंस
Source Code Licence

अवलोकन

ASP.NET Core, EF Core और MySQL में बनी इन्वेंटरी और ऑर्डर API का पूरा सोर्स कोड: कैटेगरी, प्रोडक्ट, स्टॉक मूवमेंट और ऑर्डर, 20 एंडपॉइंट के साथ। दो खरीदार आख़िरी यूनिट एक साथ नहीं ले सकते, दोबारा भेजा गया अनुरोध किसी बदलाव को दोहरा नहीं सकता, और अनुरोधों की बाढ़ डेटाबेस कनेक्शन पर हावी नहीं हो सकती। यह छह चरणों में आपके अपने कंप्यूटर पर चलने लगता है।

इन्वेंटरी के ज़्यादातर सैंपल तब तक चलते हैं जब तक दो लोग एक ही पल में आख़िरी यूनिट न ख़रीदें, कोई क्लाइंट जवाब खो जाने पर दोबारा अनुरोध न भेजे, या ट्रैफ़िक की बाढ़ डेटाबेस तक न पहुँचे। Inventory and Orders API for .NET C# and MySQL इन्हीं पलों के लिए पूरा कोड है, जिसके नतीजे MySQL 9.7 पर असली रन से आए हैं।

यह API क्या करती है

  • कैटेगरी और प्रोडक्ट। प्रोडक्ट खोजें, फ़िल्टर करें, क्रम से लगाएँ और पेज में बाँटें, उन्हें आर्काइव और रीस्टोर करें, और वे प्रोडक्ट देखें जो अपने रीऑर्डर लेवल पर या उससे नीचे हैं।
  • स्टॉक। डिलीवरी और सुधार दर्ज करें, हर प्रोडक्ट के हर बदलाव के पूरे इतिहास के साथ।
  • ऑर्डर। ऑर्डर दें, फिर उसे पूरा करें या रद्द करें। रद्द करने पर स्टॉक वापस आ जाता है।
  • 20 एंडपॉइंट और 2 हेल्थ चेक। एक .http फ़ाइल में हर एंडपॉइंट के लिए एक अनुरोध है, और Scalar, Development में इंटरैक्टिव डॉक्यूमेंटेशन देता है।

उन पलों के लिए बनी जो डेमो को तोड़ देते हैं

  • दो खरीदार, एक आख़िरी यूनिट। एक ही स्टेटमेंट रो को लॉक करता है, मात्रा जाँचता है और स्टॉक लेता है। एक ही पल में भेजे गए दो ऑर्डर में से एक को 201 Created मिला और दूसरे को 409 Conflict।
  • दोबारा भेजा गया अनुरोध बदलाव को नहीं दोहराता। ऑर्डर और स्टॉक बदलाव Idempotency-Key लेते हैं। दो बार भेजने पर वही ऑर्डर लौटा, और स्टॉक एक ही बार लिया गया।
  • अनुरोधों की बाढ़ प्रोसेस को बंद नहीं कर सकती। MySql.Data के डिफ़ॉल्ट पूल पर, अभी-अभी शुरू हुई API पर एक साथ 150 अनुरोधों ने 26 में से 17 रन में पूरा प्रोसेस बंद कर दिया। यह API एक साथ उतने ही अनुरोध चलने देती है जितने कनेक्शन पूल अनुमति देता है, और वही बाढ़ 8 में से 8 रन में बिना गड़बड़ी के निकली। एक साथ भेजे गए 600 ऑर्डर 5.5 सेकंड में सभी बन गए, और स्टॉक बिल्कुल सही रहा।
  • बदलाव एक-दूसरे को नहीं मिटाते। प्रोडक्ट के पुराने वर्ज़न पर आधारित बदलाव को 409 मिलता है, और ऑर्डर सिर्फ़ एक बार पूरा या रद्द हो सकता है।
  • MySQL बंद होने पर साफ़ जवाब। क्लाइंट को Retry-After के साथ 503 मिलता है, कोई स्टैक ट्रेस नहीं, और MySQL लौटने पर API अपने आप चलती रहती है।

MySQL का सोच-समझकर बनाया कनेक्शन

  • एन्क्रिप्टेड। सेटअप SslMode=Required इस्तेमाल करता है, README बताता है कि VerifyFull पर कैसे जाएँ, और Development के बाहर ऐप शुरू होते समय चेतावनी देता है अगर वह सर्वर की जाँच नहीं कर रहा।
  • कम से कम अधिकार। API के लिए एक अकाउंट, जो सिर्फ़ रो पढ़ और बदल सकता है, और माइग्रेशन के लिए दूसरा।
  • सर्वर पर समय सीमाएँ। डिफ़ॉल्ट रूप से कोई स्टेटमेंट रो लॉक के लिए ज़्यादा से ज़्यादा 5 सेकंड रुकता है, और कोई SELECT ज़्यादा से ज़्यादा 30 सेकंड चलता है। ये सर्वर पर हैं क्योंकि MySql.Data के async कॉल CommandTimeout पर नहीं रुकते।
  • काम करने वाले रीट्राई। Oracle का प्रोवाइडर किसी MySQL एरर को तब तक अस्थायी नहीं मानता जब तक वह सूची में न हो। यह कोड उन्हें सूची में रखता है और हर रीट्राई साफ़ कनेक्शन पर शुरू करता है।
  • माइग्रेशन अलग चरण के रूप में। EF Core के पाँच माइग्रेशन पाँचों टेबल बनाते हैं, और ऐप कभी ख़ुद माइग्रेशन नहीं चलाता।

आगे बढ़ाने लायक कोड

  • साफ़ ढाँचा। Minimal APIs, हर फ़ीचर के लिए एक फ़ोल्डर, और API व डेटा के अलग-अलग प्रोजेक्ट वाला सॉल्यूशन।
  • सख़्त बिल्ड। चेतावनियाँ एरर मानी जाती हैं, सुझाए गए एनालाइज़र चालू हैं, और हर पैकेज का वर्ज़न एक ही फ़ाइल में है।
  • एक जैसे एरर और सुरक्षित लॉग। हर एरर problem details फ़ॉर्मेट में आता है, Development के बाहर लॉग JSON में होते हैं, और पासवर्ड उन तक कभी नहीं पहुँचता।
  • सीक्रेट कोड से बाहर। लोकल MySQL के लिए .env, डेवलपमेंट में user-secrets और बाकी हर जगह एनवायरनमेंट वेरिएबल।

इसमें क्या शामिल नहीं है

यह सिर्फ़ API का कोड है, ताकि आपको पता रहे कि क्या जोड़ना है:

  • कोई UI नहीं। यह JSON में जवाब देती है।
  • कोई साइन-इन नहीं। इसके आगे अपना ऑथेंटिकेशन या गेटवे लगाएँ।
  • कोई टेस्ट प्रोजेक्ट नहीं। ऊपर के नतीजे इसे MySQL पर चलाकर मिले हैं, आर्काइव में शामिल ऑटोमेटेड टेस्ट से नहीं।
  • कोई होस्टिंग नहीं। इसे कैसे डिप्लॉय करना है यह आप तय करें, और README बताता है कि कोड जहाँ चलता है वहाँ से क्या चाहता है।

छह चरणों में चलाएँ

  1. लोकल पासवर्ड बनाएँ।
  2. Docker Compose से MySQL शुरू करें।
  3. API और माइग्रेशन को उनके अपने अकाउंट दें।
  4. टेबल बनाएँ।
  5. कनेक्शन स्ट्रिंग सेव करें।
  6. API शुरू करें और उसका डॉक्यूमेंटेशन खोलें।

README में हर कमांड है, macOS और Linux के लिए और PowerShell के लिए। How to Set Up and Run the Inventory and Orders API (नए टैब में खुलता है) (अंग्रेज़ी में) हर चरण दिखाता है, साथ में यह भी कि वह क्या प्रिंट करेगा। इसे macOS पर एक साफ़ कॉपी से zsh और PowerShell 7 में टेस्ट किया गया है।

यह कैसे बना

5 भागों वाली मुफ़्त ट्यूटोरियल सीरीज़ How to Connect a .NET C# Web API to a MySQL Database (नए टैब में खुलता है) (अंग्रेज़ी में) इस कोड के पीछे का कनेक्शन, माइग्रेशन, डेटा पढ़ना और लिखना, ट्रांज़ैक्शन और लॉक, और प्रोडक्शन चेकलिस्ट समझाती है।

मुफ़्त ट्यूटोरियल सीरीज़

How to Connect a .NET C# Web API to a MySQL Database

बनाते हुए सीखना पसंद है? हमारे ब्लॉग पर यह मुफ़्त, कदम-दर-कदम गाइड दिखाती है कि यह प्रोजेक्ट कैसे बनता है।

सीरीज़ पढ़ें (नए टैब में खुलता है)

आपको क्या मिलता है

संग्रह में जो कुछ है, एक नज़र में।

  • पूरे सोर्स कोड का वर्ज़न 1.0.0: API प्रोजेक्ट और डेटा प्रोजेक्ट वाला .NET 10 सॉल्यूशन
  • कैटेगरी, प्रोडक्ट, स्टॉक और ऑर्डर के लिए 20 एंडपॉइंट, साथ में liveness और readiness हेल्थ चेक
  • EF Core के पाँच माइग्रेशन जो MySQL की पाँचों टेबल बनाते हैं
  • ऐसे ऑर्डर जो आख़िरी यूनिट दो बार नहीं बेचते, और ऑर्डर व स्टॉक बदलावों पर Idempotency-Key
  • एक साथ चलने वाले अनुरोधों की सीमा जो कनेक्शन पूल से तय होती है, साथ में प्रति क्लाइंट सीमा और अनुरोध के आकार की सीमा
  • Oracle के MySQL प्रोवाइडर के लिए बनी रीट्राई रणनीति और सर्वर पर समय सीमाएँ
  • डेवलपमेंट के लिए MySQL 9.7 चलाने वाली compose.yaml, और एक .env.example
  • हर एंडपॉइंट के अनुरोध वाली .http फ़ाइल, और Development में Scalar डॉक्यूमेंटेशन
  • macOS, Linux और PowerShell के सेटअप कमांड, हर सेटिंग और प्रोडक्शन से पहले के काम बताने वाला README

किससे बना है

जिन सटीक रनटाइम और संस्करणों पर इसे बनाया और परखा गया।

  • .NET SDK10.0.403
  • C#14
  • ASP.NET Core10.0.14
  • EF Core10.0.14
  • MySql.EntityFrameworkCore10.0.12
  • MySql.Data26.10.0
  • Scalar.AspNetCore2.19.0
  • dotnet-ef10.0.14
  • MySQL9.7.4
  • Docker Compose5.6.1

संग्रह में क्या है

खोलने पर आपको मिलने वाली फ़ाइलों की संरचना।

inventory-orders-api-dotnet-csharp-mysql/

  • src/
  • .editorconfig
  • .env.example
  • .gitattributes
  • .gitignore
  • compose.yaml
  • Directory.Build.props
  • Directory.Packages.props
  • dotnet-tools.json
  • global.json
  • README.md

आपसे क्या चाहिए

जिन खातों और सेवाओं की इसे ज़रूरत है, ताकि कुछ भी अचानक सामने न आए।

  • .NET 10 SDK
  • लोकल MySQL के लिए Docker Compose, Docker Desktop या किसी और इंस्टॉल के ज़रिए
  • प्रोडक्शन के लिए MySQL सर्वर: इसे Docker में MySQL 9.7 LTS पर टेस्ट किया गया है, किसी मैनेज्ड सर्विस पर नहीं
  • जिस पर भरोसा न हो उसके सामने लाने से पहले अपना साइन-इन या गेटवे, क्योंकि API खुली है
  • ऐसी होस्टिंग जो प्रोसेस बंद होने पर उसे फिर शुरू करे: अटका हुआ TLS हैंडशेक MySql.Data में ऐसा एक्सेप्शन देता है जिसे कोई कोड पकड़ नहीं सकता
  • वैकल्पिक: VS Code या Visual Studio

संस्करण

अब तक के सभी संस्करण, नए से पुराने क्रम में।

  1. 1.0.0नवीनतम

    पूरे सोर्स कोड का पहला रिलीज़।

    • ASP.NET Core और MySQL में इन्वेंटरी और ऑर्डर API, कैटेगरी, प्रोडक्ट, स्टॉक और ऑर्डर के 20 एंडपॉइंट के साथ।
    • दो खरीदार आख़िरी यूनिट एक साथ नहीं ले सकते, और उसी Idempotency-Key से दोबारा भेजा गया अनुरोध बदलाव को नहीं दोहराता।
    • अनुरोधों की बाढ़ डेटाबेस कनेक्शन पर हावी होने के बजाय अपनी बारी का इंतज़ार करती है।
    • कम से कम अधिकार वाले MySQL अकाउंट, एन्क्रिप्टेड कनेक्शन, EF Core माइग्रेशन और ऐसा README जो आर्काइव से चलती हुई API तक ले जाता है।

Source Code Licence

आप इसका क्या कर सकते हैं

What you may and may not do with the source code you buy.

पूरा लाइसेंस पढ़ें
  1. What this licence covers

This licence governs every file included in a product you buy from Dewiride Store: source code, configuration, database scripts, sample data, documentation and any other file in the download. It takes effect when your payment is confirmed and applies to every release of that product that reaches your library. Files that reach your library through an annual updates membership are governed in exactly the same way.

It forms part of the Terms of Sale and Use. Where a product page states different or additional licence terms for that product, those terms prevail for that product. The membership page may likewise state different or additional licence terms for the files a membership carries, and those terms then prevail for those files.

  1. The licence we grant you

We grant you a perpetual, worldwide, non-exclusive, non-transferable licence to use, reproduce, adapt, translate and modify the files, and to include the result in your own work, on the conditions set out below.

Perpetual means it does not expire. Worldwide means it is not limited to any country. Non-exclusive means we license the same product to other customers. Non-transferable means you cannot pass it on to someone else.

The licence is granted to you — either you personally, or the organisation you identified when buying. Everyone working within that organisation may use the files for that organisation’s projects. Nobody outside it may.

  1. What you may do
  • Use and change the files in your own projects, commercial or otherwise, with no limit on the number of projects.
  • Build a product or a service on them and charge your own customers for it.
  • Deploy the result for a client, as part of work you are doing for that client.
  • Distribute the result in compiled, deployed or otherwise non-source form.
  • Keep as many back-up copies as you reasonably need.
  • Study, observe and test how the code works, and obtain the information you need to make it work with your own software.

The last two are yours by law under sections 52(1)(aa) to (ac) of the Indian Copyright Act, 1957, and nothing in this licence is intended to take them away.

  1. What you may not do
  • Resell, sublicense, redistribute or publish the files themselves, in whole or in substantial part, in source form.
  • Include them in a template, starter kit, course, tutorial repository or component library that you sell or give away, where the code is the thing being supplied.
  • Share your account, your download links or your invoices with anyone outside your organisation.
  • Publish the files in a public repository, or in any other place where they can be obtained without buying them.
  • Remove or obscure the copyright and attribution notices in the source files.
  • Use the files to build something whose main purpose is to compete with Dewiride Store as a supplier of the same code.

The distinction that matters is simple: you may sell what you build with the code; you may not sell the code.

  1. Third-party components

Our products depend on open-source libraries, frameworks and services that we did not write. Those remain under their own licences, which we do not and cannot change. Where a product includes or requires such a component, its licence is named in the product’s documentation, and complying with it is your responsibility.

  1. Releases

Every release of a product you own is covered by this same licence and appears in your library at no extra cost. A release you have already downloaded remains licensed to you even if we later stop publishing the product. A release that reached your library through an annual updates membership is licensed to you on these same terms, and stays licensed after the period that carried it has ended.

  1. Ownership

We keep ownership of the files and of the copyright in them. You own whatever you create with them: your changes, your additions and the product you build are yours.

  1. If this licence ends

This licence ends if you materially breach it and do not put the breach right within thirty days of us asking you to in writing. It also ends if your payment is reversed or refunded, because the purchase it depends on no longer stands. Where a membership period is refunded or reversed, the licence ends for the releases that period carried and for nothing else: anything you bought separately, or that another period carried, is unaffected.

If it ends, you must stop using the files and delete the copies you hold. Work you had already delivered to a client before that point may continue in use, so that ending this licence never breaks something your own customer relies on.

  1. No warranty beyond the description

The warranties and limits in section 19 and section 20 of the Terms of Sale and Use apply to this licence as well.

  1. Governing law

This licence is governed by the law of India, and section 24 of the Terms of Sale and Use applies to any dispute about it. If a translation and the English version differ in meaning, the English version governs.