MongoHead 0.2.0
See the version list below for details.
dotnet add package MongoHead --version 0.2.0
NuGet\Install-Package MongoHead -Version 0.2.0
<PackageReference Include="MongoHead" Version="0.2.0" />
paket add MongoHead --version 0.2.0
#r "nuget: MongoHead, 0.2.0"
// Install MongoHead as a Cake Addin #addin nuget:?package=MongoHead&version=0.2.0 // Install MongoHead as a Cake Tool #tool nuget:?package=MongoHead&version=0.2.0
MongoHead
Provides the layer for MongoDB operations over .NET driver 2.7.0. Also MongoHead includes a BaseData and BaseEntity class to speed up your application development process MongoHead is a .NET Standart 2.0 Library
Installation
Available on NuGet: https://www.nuget.org/packages/MongoHead/
Dependencies
Here is the list of installed NuGet packages and versions
- MongoDB.Driver (v2.7.0)
- Microsoft.Extensions.Options (v2.1.1)
- Microsoft.Extensions.Configuration (v2.1.1)
Classes
MongoDBHelper
Helper for mongodb operations. Provides CRUD operations. Needs MongoDBConfig instance to configure connection to Db and and a Type to operate with it. Type names are equal to the collection names in MongoHead ecosystem.
📢 We assume that your entity (type) has inherited BaseEntity and these some properties by defalt. Please check BaseEntity class
MongoDBConfig
Simple class used to transfer database connection parameters to our MongoDBhelper class These parameters are "ConnectionString" and "DatabaseName"
Filter and ExpressionBuilder
Filter used in MongoDBHelper and BaseData class to define query parameters and ExpressionBuilder is used as a helper class to convert filter object to linq expressions
BaseData
An implementation of IBaseData and aims to provide base CRUD methods to your data layer classes
BaseEntity Classes (BaseEntitySimple, BaseEntityLight, BaseEntity, BaseEntityComplex)
Each class adds some fields to entity provide to support to eliminating unnecessary properties on your entities and keeps your database collections lighter. Latest base entity hierarchy (inheritence) is: BaseEntitySimple < BaseEntityLight < BaseEntity < BaseEntityComplex
BaseEntitySimple adds this property
- _id
BaseEntityLight adds this property
- _DateUtcCreated
BaseEntity adds these properties
- _DateUtcModified
- _IsActive
BaseEntityComplex adds this property
- _UserId
Sample Application
MongoHead Configuration
Add Mongo DB settings to you appsettings.json setting file
Sample JSON settings:
{
"MongoDBConfig": {
"ConnectionString": "mongodb://localhost",
"DatabaseName": "MongoHeadDB"
}
}
❗:exclamation::exclamation: Information given after this line is draft at the moment ❗:exclamation::exclamation:
Sample Application Organization
Of course there may be lots of different achitectures. We are going to keep it simple and follow n-layered architecture. Different samples using different aproches are appreciated. 😃
Entities
You need entities to interact with mongodb collection. If you have an entity named X you are going a have collection with name X in your database. Your entity classes may inherit our "BaseEntity" class provided by MongoHead. With this inheritence all your class will have same base fiels in your database. To show a simple entity implementation, our sample application contains an entity named "Test".
Data Layers
Coming soon
Business Layers
Coming soon
PS: To keep things in one place we've placed entity, data layer and business layer in to the same class file
MongoDB
Setup and installation details can be obtained from official web site.
MongoDB Community Server Download
For setup please visit https://www.mongodb.com/download-center?jmp=nav#community
MongoDB Community Server Installation steps for Windows
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/
AutoMapper
In our sample projects we prefer to use automapper to map our objects between presentation and data layer
NuGet package installation
PM> Install-Package AutoMapper
When I'm trying to configure a had difficulty to find 'AddAutoMapper' extension method. To have it install this package too
PM> install-package AutoMapper.Extensions.Microsoft.DependencyInjection
If you don't install and try to use method you will have this error. 💥
'IServiceCollection' does not contain a definition for 'AddAutoMapper'
and no extension method 'AddAutoMapper' accepting a first argument of type 'IServiceCollection' could be found
are you missing a using directive or an assembly reference?
References
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Configuration (>= 2.1.1)
- Microsoft.Extensions.Options (>= 2.1.1)
- MongoDB.Driver (>= 2.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.