@@ -31,7 +31,8 @@ The following steps describe how to create a JSON:API project with MongoDB.
31
31
1 . Configure MongoDB and JsonApiDotNetCore in ` Program.cs ` , seeding the database with sample data:
32
32
``` c#
33
33
var builder = WebApplication .CreateBuilder (args );
34
- builder .Services .AddSingleton (_ => new MongoClient (" mongodb://localhost:27017" ).GetDatabase (" ExampleDbName" ));
34
+ builder .Services .AddSingleton (_ =>
35
+ new MongoClient (" mongodb://localhost:27017" ).GetDatabase (" ExampleDbName" ));
35
36
builder .Services .AddJsonApi (options =>
36
37
{
37
38
options .UseRelativeLinks = true ;
@@ -74,19 +75,6 @@ The following steps describe how to create a JSON:API project with MongoDB.
74
75
}
75
76
```
76
77
77
- > [ !TIP]
78
- > If your API project uses MongoDB only (so not in combination with EF Core), then instead of
79
- > registering all MongoDB resources and repositories individually, you can use:
80
- >
81
- > ``` c#
82
- > builder .Services .AddJsonApi (facade => facade .AddCurrentAssembly ());
83
- > builder .Services .AddJsonApiMongoDb ();
84
- >
85
- > builder .Services .AddScoped (typeof (IResourceReadRepository <,>), typeof (MongoRepository <,>));
86
- > builder .Services .AddScoped (typeof (IResourceWriteRepository <,>), typeof (MongoRepository <,>));
87
- > builder .Services .AddScoped (typeof (IResourceRepository <,>), typeof (MongoRepository <,>));
88
- > ```
89
-
90
78
1 . Start your API
91
79
``` bash
92
80
dotnet run
@@ -137,6 +125,19 @@ The following steps describe how to create a JSON:API project with MongoDB.
137
125
138
126
</details >
139
127
128
+ > [ !TIP]
129
+ > If your API project uses MongoDB only (so not in combination with EF Core), then instead of
130
+ > registering all MongoDB resources and repositories individually, you can use:
131
+ >
132
+ > ``` c#
133
+ > builder .Services .AddJsonApi (facade => facade .AddCurrentAssembly ());
134
+ > builder .Services .AddJsonApiMongoDb ();
135
+ >
136
+ > builder .Services .AddScoped (typeof (IResourceReadRepository <,>), typeof (MongoRepository <,>));
137
+ > builder .Services .AddScoped (typeof (IResourceWriteRepository <,>), typeof (MongoRepository <,>));
138
+ > builder .Services .AddScoped (typeof (IResourceRepository <,>), typeof (MongoRepository <,>));
139
+ > ```
140
+
140
141
## Using client-generated IDs
141
142
142
143
Resources that inherit from `HexStringMongoIdentifiable ` use auto - generated (high - performance ) 12 - byte hexadecimal
0 commit comments