Imato.MongoDb.Repository
1.0.1
dotnet add package Imato.MongoDb.Repository --version 1.0.1
NuGet\Install-Package Imato.MongoDb.Repository -Version 1.0.1
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="Imato.MongoDb.Repository" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Imato.MongoDb.Repository --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Imato.MongoDb.Repository, 1.0.1"
#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 Imato.MongoDb.Repository as a Cake Addin #addin nuget:?package=Imato.MongoDb.Repository&version=1.0.1 // Install Imato.MongoDb.Repository as a Cake Tool #tool nuget:?package=Imato.MongoDb.Repository&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Imato.MongoDb.Repository
Generic MongoDb repository
How to use id
Add reference
using Imato.MongoDb.Repository;
Configure DB
var db = new MongoDb();
db.Configure(new MongoConfiguration
{
DataBase = "testDb"
});
Define type for repository
public class TestEntity : IEntity
{
public string Id { get; set; } = string.Empty;
[WithIndex]
public string Name { get; set; } = string.Empty;
public DateTime Date { get; set; }
public int Count { get; set; }
}
// Or use Base type
public class TestEntity : BaseEintity
{
public DateTime Date { get; set; }
public int Count { get; set; }
public TestEntity Copy()
{
return (TestEntity)MemberwiseClone();
}
}
Create and use repository
var repository = db.GetRepository<TestEntity>();
var ne = await repository.CreateAsync(new TestEntity
{
Name = "Test entry 1",
Date = DateTime.Now,
Count = 1
});
var result = await repository.FindAsync(x => x.Id == ne.Id);
await repository.DeleteAsync(result);
Save app parameters
// Save new parameter
var app = new AppName();
await db.SetParameterAsync(app);
// Load from DB
var dbApp = await db.GetParameterAsync<AppName>();
Save logs to DB
ILogEntry log = new LogEntry
{
Message = "Test message",
Parameters = app,
Source = "Tests",
Level = LogLevel.Error
};
await db.WriteLogAsync(log);
Get logs
var logs = await db.GetLogsAsync(level: LogLevel.Error)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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.
-
net6.0
- Imato.JsonConfiguration (>= 1.0.1)
- MongoDB.Driver (>= 2.15.0)
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 |
---|---|---|
1.0.1 | 264 | 4/20/2022 |
Ready to use