Silmoon.Data.MongoDB 3.4.0-alpha.0

Prefix Reserved
This is a prerelease version of Silmoon.Data.MongoDB.
dotnet add package Silmoon.Data.MongoDB --version 3.4.0-alpha.0
                    
NuGet\Install-Package Silmoon.Data.MongoDB -Version 3.4.0-alpha.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="Silmoon.Data.MongoDB" Version="3.4.0-alpha.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Silmoon.Data.MongoDB" Version="3.4.0-alpha.0" />
                    
Directory.Packages.props
<PackageReference Include="Silmoon.Data.MongoDB" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Silmoon.Data.MongoDB --version 3.4.0-alpha.0
                    
#r "nuget: Silmoon.Data.MongoDB, 3.4.0-alpha.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.
#:package Silmoon.Data.MongoDB@3.4.0-alpha.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Silmoon.Data.MongoDB&version=3.4.0-alpha.0&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Silmoon.Data.MongoDB&version=3.4.0-alpha.0&prerelease
                    
Install as a Cake Tool

Silmoon.Data.MongoDB

MongoDB 数据访问封装,提供 MongoExecuter、MongoService、表达式查询、局部更新、集合名称映射和模型索引管理。

安装

当前版本为预览版。

dotnet add package Silmoon.Data.MongoDB --prerelease

本包提供 .NET Standard 2.1 和 .NET Framework 4.7.2 目标。下面的控制台示例使用现代 C# 语法,需要可访问的 MongoDB 服务。

查询与局部更新

using System;
using System.Linq.Expressions;
using Silmoon.Data;
using Silmoon.Data.Attributes;
using Silmoon.Data.MongoDB;
using Silmoon.Data.MongoDB.Models;

var executer = new MongoExecuter("mongodb://localhost:27017/example");
var symbol = new Symbol { Name = "DEMO", Price = 12.5m, Enabled = true };
executer.AddObject(default, symbol);

Expression<WhereAction<Symbol>> where = x => x._id == symbol._id;
Expression<SetAction<Symbol>> set = x => new Symbol { Price = 0m, Enabled = false };
var update = executer.SetObjects(default, where, set);
var saved = executer.GetObject(default, where);
Console.WriteLine($"{saved.Name}: {saved.Price}; modified: {update.ModifiedCount}");

[ModelToMongoCollection("symbols")]
public sealed class Symbol : IdObject
{
    public string Name { get; set; } = string.Empty;
    public decimal Price { get; set; }
    public bool Enabled { get; set; }
}

WhereAction<T> 表达筛选条件,SetAction<T> 只更新初始化器中明确赋值的属性,支持 0、false 和 null。示例中的 Name 和 _id 保留原值。

  • 集合名称依次使用显式非空名称、ModelToMongoCollection 特性和类型默认名称。
  • 排序、分页通过 Silmoon.Data.MongoDB.Query.QueryOptions 传入查询方法。
  • 空筛选条件表示无筛选,单条操作作用于一条匹配记录,批量操作作用于全部匹配记录。
  • 事务操作通过 sessionHandle 参数传递调用方管理的 MongoDB 会话。
  • 模型索引通过 EnsureModelIndexes<T>() 显式创建,并检查返回结果。

项目源码 · NuGet 包

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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 (2)

Showing the top 2 NuGet packages that depend on Silmoon.Data.MongoDB:

Package Downloads
Silmoon.AspNetCore.Extension

Silmoon SDK

Silmoon.AspNetCore.Extensions

Silmoon SDK

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.4.0-alpha.0 0 11/12/2026
3.3.0 159 9/25/2026
3.2.1 184 6/22/2026
3.2.0 170 3/1/2026
2.0.0 305 9/21/2025
1.8.4 196 8/23/2025
1.8.1 254 5/25/2025
1.8.0 215 3/2/2025
1.7.4 323 2/2/2025
1.7.3 230 2/1/2025
1.7.2 201 1/21/2025
1.7.1 241 12/29/2024
1.7.0 215 12/28/2024
1.6.6 208 12/22/2024
1.6.5 240 12/22/2024
1.6.4 220 12/22/2024
Loading failed