SQL Dotnet Notes
SQL Dotnet Notes
Key Concepts:
1. Indexes:
2. Clustered Index:
3. Non-Clustered Index:
4. Stored Procedures:
1. Triggers:
1
CREATE TRIGGER trgUpdateInventory
ON Orders
AFTER INSERT
AS
BEGIN
UPDATE Inventory
SET Quantity = Quantity - inserted.Quantity
FROM Inventory INNER JOIN inserted ON Inventory.ProductID =
inserted.ProductID;
END;
1. Transactions:
3. Example:
BEGIN TRANSACTION;
UPDATE Account SET Balance = Balance - 500 WHERE AccountID = 1;
UPDATE Account SET Balance = Balance + 500 WHERE AccountID = 2;
COMMIT TRANSACTION;
1. Performance Tuning:
Key Concepts:
1. RESTful APIs:
3. Example endpoints:
◦ GET /api/employees
◦ POST /api/employees
6. Example:
2
app.Use(async (context, next) => {
Console.WriteLine("Request incoming");
await next();
Console.WriteLine("Response outgoing");
});
3. Example:
3. Example:
3. Diagram:
3
4. Exception Handling & Logging:
6. Example:
app.UseExceptionHandler(appError =>
{
appError.Run(async context =>
{
context.Response.StatusCode = 500;
await context.Response.WriteAsync("An unexpected error occurred.");
});
});
Practice:
Good luck with your SQL Server and .NET API interview preparation!