This project aims to generate a multi-tier architecture using SqlKata for dynamic SQL query generation and management. The project automatically generates C# classes, Data Access Layer (DAL), Business Layer, and API controllers from database tables.
- Node.js
- .NET 8.0 SDK
- MSSQL Database
-
Clone the repository:
git clone https://github.com/NazimMertBilgi/NTier-SqlKata-Example.git cd NTier-SqlKata-Example
-
Install the required Node.js dependencies:
npm install
-
Configure the
packageSettings.json
file:!IMPORTANT! Do not change the packageName and slnFileName values, this is handled by changePackageName.js.
{ "dbConnection": { "server": "YOUR_SERVER", "database": "YOUR_DATABASE", "options": { //example //"trustedConnection": true } } }
-
Change Solution Package Name
npm run change-package-name
and follow the steps that appear on the screen.
-
Run the code generator:
npm run generate
now you are ready 😊 look at your project files and see the changes for yourself.
NTier-SqlKata.sln
: Solution fileNTier.API/
: API layerControllers/
: API controllersProgram.cs
: Main entry point for the API
NTier.Business/
: Business layerAbstract/
: Abstract business servicesConcrete/
: Concrete business services
NTier.Core/
: Core layerClasses/
: Core classesEntities/
: Entity interfaces and classes
NTier.DataAccess/
: Data access layerAbstract/
: Abstract data access servicesConcrete/
: Concrete data access services
NTier.Entities/
: Entity classes
This file is responsible for generating C# classes, Data Access Layer (DAL), Business Layer, and API controllers from database tables.
getTablesAndColumns()
: Retrieves tables and columns from the database.generateEntities(tables)
: Generates entity classes.generateAbstractDALFiles(tables)
: Generates abstract DAL files.generateConcreteDALFiles(tables)
: Generates concrete DAL files.generateServiceFiles(tables)
: Generates business service files.generateManagerFiles(tables)
: Generates business manager files.generateDependencyInjectionRegistrations(tables)
: Generates dependency injection registrations.generateControllerFiles(tables)
: Generates API controller files.generateModelFiles(tables)
: Generates model files.
Star and fork the project. Thank you.