DocumentFramework 0.0.6-alpha
This is a prerelease version of DocumentFramework.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package DocumentFramework --version 0.0.6-alpha
NuGet\Install-Package DocumentFramework -Version 0.0.6-alpha
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DocumentFramework" Version="0.0.6-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DocumentFramework --version 0.0.6-alpha
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DocumentFramework, 0.0.6-alpha"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DocumentFramework as a Cake Addin #addin nuget:?package=DocumentFramework&version=0.0.6-alpha&prerelease // Install DocumentFramework as a Cake Tool #tool nuget:?package=DocumentFramework&version=0.0.6-alpha&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Document Framework
A light weight ORM for moongo and dotnet.
Notable features
- EF style registration and usage
- Migrations
Usage
- Add a model
public class Foo
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
public string Text { get; set; }
}
- Create a
MongoContext
public class BarMongoContext : MongoContext
{
public readonly IMongoCollection<Foo> Foos;
public BarMongoContext(IMongoDatabase database, IEnumerable<IMongoMigration> migrations, ILogger<MongoContext> logger)
: base(migrations, database, logger)
{
Foos = GetOrAddCollection<Foo>("foos");
}
}
- Create a migration
public class SeedFoos : IMongoMigration
{
public string MigrationName => "20210420000000_Foos";
private readonly IMongoDatabase _database;
public SeedFoos(IMongoDatabase database)
{
_database = database;
}
public void MigrateForward()
{
var fooCollection = _database.GetCollection<Foo>("foos");
fooCollection.InsertMany(new Foo[] {
new Foo { Text = "document-1" },
new Foo { Text = "document-2" }
});
}
}
- Register Context and mongo database in the
ConfigureServices
method in yourStartup.cs
services
.AddMongoContext<BarMongoContext>()
.AddTransient<IMongoDatabase>()
- Sync migrations in the
Configure
method in yourStartup.cs
app.ApplicationServices
.GetRequiredService<BarMongoContext>()
.SyncMigrations();
- Use the Mongo context to query collections
public class SomeService
{
private readonly BarMongoContext _context;
public SomeService(BarMongoContext context)
{
_context = context;
}
public IEnumerable<Foo> GetSomeFooStuff(string text)
{
_context.Foos.Find(f => f.Text == text).ToEnumerable();
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net5.0
- Microsoft.Extensions.Logging (>= 5.0.0)
- MongoDB.Driver (>= 2.13.1)
- Newtonsoft.Json (>= 13.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.1.1-alpha | 188 | 10/26/2021 |
0.1.0-alpha | 150 | 10/26/2021 |
0.0.7-alpha | 168 | 10/14/2021 |
0.0.6-alpha | 174 | 10/12/2021 |
0.0.5-alpha | 153 | 10/12/2021 |
0.0.4-alpha | 142 | 10/11/2021 |
0.0.3-alpha | 146 | 10/11/2021 |
0.0.2-alpha | 149 | 10/11/2021 |
0.0.1-alpha | 175 | 10/11/2021 |