This project is a Dynamic Object API built using .NET Core and Entity Framework, which allows users to create, read, update, and delete dynamic objects such as Products, Customers, Orders, OrderProduct, etc. All object types are dynamically handled, supporting flexible data structures and transaction management for master objects and their related sub-objects.
- Create any type of object (e.g.,
Product,Customer,Order,OrderProduct) with flexible fields. - Objects are managed dynamically within defined tables, ensuring data consistency and schema validation.
- Create: Dynamically add new objects and define their structure.
- Read: Retrieve objects based on type and ID, with optional filters for specific queries, such as retrieving all orders by a specific customer.
- Update: Modify existing objects dynamically based on their defined structure.
- Delete: Remove an object along with its sub-objects (if applicable) in a single operation.
- Transactions ensure that all related objects (master and sub-objects) are created, updated, or deleted together.
- If any part of a transaction fails, the entire operation is rolled back to maintain data integrity.
- Each object type (e.g.,
Product,Customer) requires specific fields (ProductId,Name, etc.). - Validation logic dynamically checks that required fields are present before processing the request.
POST /api/DynamicCrud
Body:
{
"objectType": "product",
"fields": {
"ProductName": "Sample Product",
"ProductDescription": "This is a sample product.",
"Price": 99.99,
"Status": "Available"
}
}POST /api/DynamicCrud
Body:
{
"objectType": "customer",
"fields": {
"FirstName": "Ahmet",
"LastName": "Yılmaz",
"Email": "ahmet.yilmaz@example.com",
"Phone": "555-1234",
"Address": "Istanbul, Turkey"
}
}GET /api/DynamicCrud/product
GET /api/DynamicCrud/product/1
GET /api/DynamicCrud/product?ProductName=Sample%20Product
PUT /api/DynamicCrud/product/1
Body:
{
"Price": 79.99
}DELETE /api/DynamicCrud/product/1
POST /api/DynamicCrud
Body:
{
"objectType": "order",
"fields": {
"CustomerId": 1,
"OrderDate": "2023-10-02T14:00:00",
"TotalAmount": 299.97,
"Status": "Processing",
"SubObjects": [
{
"objectType": "orderProduct",
"fields": {
"ProductId": 1,
"Quantity": 3,
"Price": 79.99
}
}
]
}
}GET /api/DynamicCrud/order?CustomerId=1
- ASP.NET Core for building the API.
- Entity Framework Core for data access and transaction management.
- SQL Server as the database.
- Newtonsoft.Json for handling dynamic JSON fields.
This project is licensed under the MIT License.