Skip to content

Commit 12e9274

Browse files
Updated ORM docs
1 parent dea8a37 commit 12e9274

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

docs/.vitepress/config.mts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default defineConfig({
7373
// { text: 'Records', link: '/pages/intermediate/records' },
7474
{ text: 'Extension Methods', link: '/pages/intermediate/extension-methods' },
7575
{ text: 'Iterators and Enumerables', link: '/pages/intermediate/iterators-enumerables' },
76-
{ text: 'Unit Testing', link: '/pages/intermediate/unit-testing' },
76+
{ text: '🚧 Unit Testing', link: '/pages/intermediate/unit-testing' },
7777
{ text: 'Express vs Minimal API', link: '/pages/intermediate/express-vs-minimal-api' },
7878
{ text: 'Nest.js vs Controller API', link: '/pages/intermediate/nest-vs-controller-api' },
7979
{ text: 'Decorators vs Attributes', link: '/pages/intermediate/decorators-vs-attributes' },
@@ -88,9 +88,9 @@ export default defineConfig({
8888
{ text: 'Generators and Yield', link: '/pages/advanced/generators-yield' },
8989
// { text: 'dynamic (ExpandoObject)', link: '/pages/advanced/dynamic' },
9090
{ text: 'JSON Serialization', link: '/pages/advanced/json-serialization' },
91-
{ text: 'Reflection', link: '/pages/advanced/reflection' },
92-
{ text: 'Channels', link: '/pages/advanced/channels' },
93-
{ text: 'Source Generation (Roslyn)', link: '/pages/advanced/source-generation-roslyn' },
91+
{ text: '🚧 Reflection', link: '/pages/advanced/reflection' },
92+
{ text: '🚧 Channels', link: '/pages/advanced/channels' },
93+
{ text: '🚧 Source Generation (Roslyn)', link: '/pages/advanced/source-generation-roslyn' },
9494
]
9595
},
9696
{
@@ -99,16 +99,16 @@ export default defineConfig({
9999
items: [
100100
{ text: 'Switch Expression', link: '/pages/bonus/switch-expression' },
101101
{ text: 'Partial Classes', link: '/pages/bonus/partial-classes' },
102-
{ text: 'Global Using', link: '/pages/bonus/global-usings' }
102+
{ text: '🚧 Global Using', link: '/pages/bonus/global-usings' }
103103
]
104104
},
105105
{
106106
text: 'How Do I...',
107107
collapsed: true,
108108
items: [
109-
{ text: 'Set up Formatters?', link: '/pages/how-to/code-formatting' },
110-
{ text: 'Interface with the Backend?', link: '/pages/how-to/openapi-bindings' },
111-
{ text: 'Build for other Platforms?', link: '/pages/how-to/cross-platform-build' }
109+
{ text: '🚧 Set up Formatters?', link: '/pages/how-to/code-formatting' },
110+
{ text: '🚧 Interface with the Backend?', link: '/pages/how-to/openapi-bindings' },
111+
{ text: '🚧 Build for Other Platforms?', link: '/pages/how-to/cross-platform-build' }
112112
]
113113
},
114114
]

docs/pages/intermediate/databases-and-orms.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ model RaceResult {
240240
</template>
241241
<template #right>
242242

243-
```csharp{3,4,11,17-20,25,31-35,42,45,46}
243+
```csharp{3,4,11,17-20,25,31-34,42,45,46}
244244
public class Database(DbConfig config) : DbContext {
245245
// 👇 These two define our schema
246246
public DbSet<Runner> Runners { get; set; } = null!;
@@ -777,7 +777,7 @@ export class AppController {
777777
</template>
778778
<template #right>
779779

780-
```csharp{42,50,55-61}
780+
```csharp{42,50,55-60}
781781
// 📄 ResultsRepository.cs: Sample repository
782782
public class ResultsRepository(
783783
Database db // 👈 Injected via DI
@@ -836,8 +836,7 @@ public class AppController(
836836
public async Task<
837837
List<RunnerRaceResult>
838838
> GetTop10FinishesByRunner(string email) {
839-
var results = await resultsRepository.Top10FinishesByRunner(email);
840-
return [.. results];
839+
return [.. await resultsRepository.Top10FinishesByRunner(email)];
841840
}
842841
}
843842
```

docs/pages/intermediate/nest-vs-controller-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**Nest.js** builds on top of Express (or optionally Fastify) and introduces a **structured, modular architecture** with features like **decorator-based routing, dependency injection (DI), and controllers**, making it more comparable to **.NET Controller APIs** than plain Express.js. By enforcing a convention-driven approach similar to ASP.NET Core, Nest.js simplifies the development of scalable applications while integrating well with TypeScript’s strong typing. Its use of decorators for defining routes and DI for managing services closely resembles the approach used in .NET, making it feel more structured and maintainable than raw Express.
44

5-
However, **Nest.js does not match .NET in performance**. Since Nest.js runs on Node.js, it inherits the limitations of JavaScript’s single-threaded event loop, leading to potential bottlenecks in CPU-bound workloads. While Fastify can improve Nest’s performance over Express, it still cannot compete with **.NET’s high-performance Kestrel server**, which is optimized for multi-threading and asynchronous processing. That said, **Nest.js is more production-ready than Express**, as it includes built-in support for **authentication, validation, middleware, and structured DI**, reducing the need for third-party dependencies.
5+
Since Nest.js runs on Node.js, it inherits the limitations of JavaScript’s single-threaded event loop, leading to potential bottlenecks in CPU-bound workloads. While Fastify can improve Nest’s performance over Express, it still comes up short against **.NET’s high-performance Kestrel server**, which is optimized for multi-threading and asynchronous processing. That said, Nest.js is more production-ready than Express, as it includes built-in support for **authentication, validation, middleware, and structured DI**, reducing the need for third-party dependencies and more "batteries included".
66

77
::: tip If you're already using Nest.js
88
If your team is already using Nest.js, chances are that there is a need for the more structured approach of Nest.js over Express.js. In this case, you will find that .NET controller web APIs are conceptually similar, but probably overall easier to work with because of the type system (e.g. parameter type checking is automatic, OpenAPI schema bindings are "free")

docs/pages/intro-and-motivation.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ Over the years, .NET and C# have evolved heavily (as has Microsoft) and now ***"
66

77
During that time, the language design of both C# and TypeScript (JavaScript as well) have *converged* more than other languages. The two languages are now remarkably similar in their core syntax such that developers that know one can typically pick up the other fairly easily.
88

9-
This guide aims to provide a walkthrough of just how similar these two languages are, but also highlight where C# and .NET can solve some of the pain points that many teams using TypeScript *on the backend* will no doubt encounter.
9+
This guide aims to provide a walkthrough of just how similar these two languages are and in fact can be used bi-directionally. In many cases, it will highlight where C# and .NET can solve some of the pain points that many teams using TypeScript *on the backend* will no doubt encounter.
1010

1111
::: tip Don't forget to check the repo!
1212
Many of the code examples in this guide are actually in [the GitHub repo](https://github.com/CharlieDigital/typescript-is-like-csharp). Be sure to check it out so you can see the full examples and play around with the code yourself.
1313
:::
1414

15+
::: info
16+
This guide was inspired by the [Kotlin is Like C#](https://ttu.github.io/kotlin-is-like-csharp/) guide I came across while learning Kotlin.
17+
:::
18+
1519
## Are They *Really* Similar?
1620

1721
Before you ready your pitchforks, check out some of the similarities between TypeScript and C#:

src/csharp/ef-api/Controllers/AppController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ ResultsRepository resultsRepository
1414

1515
[HttpGet("/top10/{email}")]
1616
public async Task<List<RunnerRaceResult>> GetTop10FinishesByRunner(string email) {
17-
var results = await resultsRepository.Top10FinishesByRunner(email);
18-
return [.. results];
17+
return [.. await resultsRepository.Top10FinishesByRunner(email)];
1918
}
2019

2120
[HttpGet("/results/{email}")]

0 commit comments

Comments
 (0)