MongoHead 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MongoHead --version 0.1.0                
NuGet\Install-Package MongoHead -Version 0.1.0                
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="MongoHead" Version="0.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MongoHead --version 0.1.0                
#r "nuget: MongoHead, 0.1.0"                
#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 MongoHead as a Cake Addin
#addin nuget:?package=MongoHead&version=0.1.0

// Install MongoHead as a Cake Tool
#tool nuget:?package=MongoHead&version=0.1.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

Dependencies

Here is the list of installed NuGet packages and versions

  1. MongoDB.Driver (v2.7.0)
  2. Microsoft.NETCore.App (v2.0.0)
  3. Microsoft.Extensions.Options (v2.1.1)
  4. 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

Bases a foundation for your entities by providing base properties like id, date and basic status fields.

  • _id
  • _DateUtcCreated
  • _DateUtcModified
  • _IsActive

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.5.2 470 4/12/2022
0.5.1 405 3/14/2022
0.5.0 420 3/12/2022
0.4.0 502 4/30/2022
0.3.0 1,134 2/22/2019
0.2.0 1,166 10/26/2018
0.1.0 1,251 9/12/2018