0% found this document useful (0 votes)
3 views5 pages

Dotnet SQL Interview Guide

This document serves as a technical interview guide for .NET and SQL developers with three years of experience, focusing on core concepts and coding challenges. It covers foundational topics in ASP.NET Core, C#, LINQ, and SQL Server, including dependency injection, logging, and index types, along with practical coding challenges. The guide emphasizes hands-on problem-solving skills and includes specific coding examples for data transformation and middleware implementation.

Uploaded by

yogikj94
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Dotnet SQL Interview Guide

This document serves as a technical interview guide for .NET and SQL developers with three years of experience, focusing on core concepts and coding challenges. It covers foundational topics in ASP.NET Core, C#, LINQ, and SQL Server, including dependency injection, logging, and index types, along with practical coding challenges. The guide emphasizes hands-on problem-solving skills and includes specific coding examples for data transformation and middleware implementation.

Uploaded by

yogikj94
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

.

NET & SQL Developer Technical Interview


Guide
TAILORED FOR 3 YEARS OF EXPERIENCE | CORE CONCEPTS & CODING
CHALLENGES

Targeted Focus Areas: [Link] Core 6/8, C# Core & LINQ, SQL Server Architecture, and Hands-on
Technical Problem Solving. JQuery has been omitted to focus exclusively on backend & modern
architecture.

Section 1: Foundational Review (Based on Screened Assessment)

Q1. Explain the architectural difference between [Link]() and [Link]() in


[Link].
[Link]() sends an HTTP 302 status code back to the client browser, forcing it to make a new
HTTP GET request to the target URL. This updates the browser's address bar and involves an extra round-
trip. [Link](), however, happens completely on the server side. It preserves the HTTP context and
shifts processing to a new page without updating the browser's address bar, saving network latency but
keeping the old URL visible.

Q2. How does dependency injection resolve dependencies in [Link] Core, and how do service
lifetimes differ?

[Link] Core uses a built-in container managed by an IServiceProvider implementation. When a type
requests a dependency via a constructor, the framework checks its registration configuration. At 3 YOE, you
must know the three lifetimes precisely:

• Transient: Instantiated every time they are requested. Ideal for lightweight, stateless services.
• Scoped: Instantiated once per client HTTP connection/request lifetime. Standard configuration for
Entity Framework Database Contexts.
• Singleton: Instantiated exactly once on app launch and shared across all incoming requests globally.

Q3. What occurs when [Link] is evaluated in Web API methods?


During model binding, the framework takes incoming request data (from JSON, route parameters, or query
string) and binds it to a data model. Simultaneously, it evaluates data validation attributes (like [Required],
[StringLength]). [Link] verifies if all parameters satisfied these validations. In modern
[Link] Core controllers decorated with [ApiController], this check occurs automatically and returns an
HTTP 400 Bad Request error if validation fails.

3+ YOE .NET & SQL Interview Prep Guide 1


Q4. Detail the default logging configuration pipeline in [Link] Core 6/8.

When executing [Link](args), the host sets up default logging providers:


Console, Debug, EventSource, and (on Windows machines) EventLog. The Console provider is the
foundational component in cloud-native microservices because container platforms (Docker/Kubernetes)
scrape stdout from console outputs directly.

Section 2: C# & LINQ Mid-Level Deep Dive

Q5. Contrast the internal mechanics of IEnumerable vs. IQueryable in LINQ.

IEnumerable represents an in-memory collection. Filtering expressions (like .Where()) executed against an
IEnumerable use delegate functions and process calculations inside client memory—meaning all source
records are fetched from a database. IQueryable is intended for out-of-memory databases. It translates
expressions directly into expression trees, converting them into optimized SQL native queries to process
filtering directly on the database engine.

Q6. What is the difference between Nullable Value Types and Nullable Reference Types?

Nullable Value Types (like int? or bool?) wrap primitive structs in a [Link]<T> container,
dedicating extra memory bytes to support a valid boolean flag tracking instantiation state. Nullable Reference
Types (introduced in C# 8) do not modify runtime structure. Instead, they provide compiler annotations to emit
build-time warnings when reference types (like string) risk generating a NullReferenceException.

Section 3: Practical Coding Challenges (.NET & C#)

Challenge 1: LINQ Data Transformation

Given a collection of Employee records, write a optimized LINQ query to select the Top 3 highest-earning
unique departments along with their total combined payroll cost, filtering out employees who are currently
inactive.

3+ YOE .NET & SQL Interview Prep Guide 2


public class Employee {
public string Name { get; set; }
public string Department { get; set; }
public decimal Salary { get; set; }
public bool IsActive { get; set; }
}

public List<object> GetTopDepartments(List<Employee> employees) {


return employees
.Where(e => [Link])
.GroupBy(e => [Link])
.Select(g => new {
DepartmentName = [Link],
TotalPayroll = [Link](e => [Link])
})
.OrderByDescending(d => [Link])
.Take(3)
.Cast<object>()
.ToList();
}

Challenge 2: Custom Middleware Implementation

Write an [Link] Core custom middleware component to intercept incoming API requests, measure
execution latency, and log requests that exceed a 500ms SLA threshold.

3+ YOE .NET & SQL Interview Prep Guide 3


using [Link];
using [Link];
using [Link];

public class PerformanceMonitorMiddleware {


private readonly RequestDelegate _next;
private readonly ILogger<PerformanceMonitorMiddleware> _logger;

public PerformanceMonitorMiddleware(RequestDelegate next,


ILogger<PerformanceMonitorMiddleware> logger) {
_next = next;
_logger = logger;
}

public async Task InvokeAsync(HttpContext context) {


var stopwatch = [Link]();

await _next(context); // Forward request downstream

[Link]();
if ([Link] > 500) {
_logger.LogWarning($"SLA Violation: {[Link]}
{[Link]} took {[Link]}ms");
}
}
}

Section 4: SQL Database & Query Architecture

Q7. Explain Clustered vs. Non-Clustered Indexes and how they alter table layout.
A Clustered Index defines the physical storage sorting order of rows directly inside data pages. A table can
only have one clustered index (typically assigned to the Primary Key). A Non-Clustered Index is entirely
separate from the row tables. It builds a distinct B-Tree structures containing pointers (row keys or heap
identifiers) back to physical records.

Q8. How do you isolate performance bottlenecks via execution plans?


Look for operators like Table Scan or Clustered Index Scan, which point to the engine inspecting every data
page instead of looking up precise indices. High-cost warning emblems, thick connectors indicating
disproportionate row transfers, and explicit Key Lookup operations (where non-clustered indexes force
queries back to base tables for non-covered columns) represent main optimization avenues.

3+ YOE .NET & SQL Interview Prep Guide 4


Challenge 3: SQL Advanced Manipulation & Performance Tuning

Consider an Orders table with columns (OrderId, CustomerId, OrderDate, TotalAmount). Write
a robust SQL Server query utilizing common table expressions (CTEs) or window functions to identify the
highest single order placed by each client, sorting clients by total lifetime spend.

-- Step 1: Calculate total client lifetime spend and rank rows natively
WITH RankedOrders AS (
SELECT
OrderId,
CustomerId,
OrderDate,
TotalAmount,
ROW_NUMBER() OVER (PARTITION BY CustomerId ORDER BY TotalAmount DESC) as
OrderRank
FROM Orders
),
LifetimeSpend AS (
SELECT
CustomerId,
SUM(TotalAmount) as TotalLifetimeSpend
FROM Orders
GROUP BY CustomerId
)
SELECT
[Link],
[Link],
[Link],
[Link] AS HighestSingleOrderAmount,
[Link]
FROM RankedOrders ro
JOIN LifetimeSpend ls ON [Link] = [Link]
WHERE [Link] = 1
ORDER BY [Link] DESC;

Optimization Note: To maximize execution speeds, ensure a composite index exists covering (CustomerId,
TotalAmount DESC) INCLUDE (OrderId, OrderDate).

3+ YOE .NET & SQL Interview Prep Guide 5

You might also like