Saturday, 14 March 2026

.Net and SQL interview ( AI generated)

A combined SQL and .NET interview will cover topics from both areas, often focusing on how the two technologies interact, such as using Entity Framework (EF) Core for data access in a C# application. [1, 2]

SQL Interview Questions
  • Explain the difference between and clauses. The clause filters rows before any grouping occurs, while the clause filters groups after an aggregate function (like or ) has been applied.
  • What are SQL joins, and what are the differences between , , , and joins? Joins combine rows from two or more tables based on a related column.
    • : Returns only rows with matching values in both tables.
    • : Returns all rows from the left table, and the matched rows from the right table (unmatched right rows will have values).
    • : Returns all rows from the right table, and the matched rows from the left table (unmatched left rows will have values).
    • : Returns all rows when there is a match in either the left or the right table.
  • Describe clustered and non-clustered indexes. A clustered index determines the physical storage order of data in a table and can only have one per table, while a non-clustered index is a separate structure that stores pointers to the physical data rows, allowing for multiple non-clustered indexes per table.
  • How do you optimize a slow query? A systematic approach involves analyzing the query execution plan to identify bottlenecks (like table scans), ensuring proper indexing, rewriting inefficient query logic (e.g., using instead of when appropriate), and reducing the amount of data fetched.
  • Explain the ACID properties of a database transaction. ACID stands for Atomicity (all or nothing operations), Consistency (maintaining data integrity rules), Isolation (concurrent transactions don't interfere with each other), and Durability (committed data is permanent, even after a system crash). [1, 3, 4, 5, 6]
.NET Interview Questions
  • How does the .NET framework (or Core/5+) work? Code written in languages like C# is compiled into Common Intermediate Language (CIL), which is then converted into native machine code at runtime by the Just-In-Time (JIT) compiler within the Common Language Runtime (CLR). The CLR manages memory, garbage collection, and security.
  • What is the difference between an and an ?
    • An defines a contract that implementing classes must follow, but cannot provide any implementation details. A class can implement multiple interfaces.
    • An can provide both abstract methods (which must be implemented by subclasses) and concrete methods (with implementation). A class can only inherit from one abstract class.
  • Explain Dependency Injection (DI) in ASP.NET Core. DI is a pattern used to achieve loose coupling between components. The built-in DI container in ASP.NET Core manages the creation of services and injects them into classes (like controllers) that need them. You should be familiar with the three service lifetimes: Transient, Scoped, and Singleton.
  • What is the difference between , , and commands?
    • : A Data Manipulation Language (DML) command that removes rows based on a condition and can be rolled back.
    • : A Data Definition Language (DDL) command that quickly removes all rows from a table and cannot be rolled back easily (it also resets identity columns).
    • : A DDL command that removes the entire table structure (schema) and all its data permanently.
  • How do you prevent SQL injection attacks in a .NET application? The primary method is using parameterized queries or stored procedures.
    Entity Framework Core

    uses parameterized queries by default, which is a key security best practice.
What specific experience level are you interviewing for (e.g., junior, senior), as this will determine the complexity of the follow-up questions?


AI can make mistakes, so double-check responses

No comments:

Post a Comment