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, API controllers, and GraphQL schema, queries, and types from database tables.
- Node.js
- .NET 8.0 SDK
- MSSQL Database
-
Clone the repository:
git clone https://github.com/NazimMertBilgi/NTier-SqlKata-GraphQL cd NTier-SqlKata-GraphQL
-
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 controllersSchema/
: GraphQL schema, queries, and typesProgram.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 classesModels/
: Data models
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, API controllers, and GraphQL schema, queries, and types 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.generateGraphQLSchemaFiles(tables)
: Generates GraphQL schema files.generateGraphQLQueryFiles(tables)
: Generates GraphQL query files.generateGraphQLTypeFiles(tables)
: Generates GraphQL type files.generateGraphQLSchemaDependencyInjection(tables)
: Generates GraphQL schema dependency injection registrations.
Star and fork the project. Thank you.