AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-889562

Don Tomato's questions

Martin Hope
Don Tomato
Asked: 2024-11-29 01:58:35 +0800 CST

MongoDB.Driver.MongoIncompatibleDriverException:服务器报告线路版本 4,但此版本的驱动程序至少需要 7

  • 5

我正在尝试使用实体框架和 MongoDB。

这是我的docker compose:

services:
  mongo-db:
    container_name: mongo-db
    image: mongo
    restart: always
    ports:
      - "27017:27017"

实体和上下文:

public class Order
{
    public string Id { get; set; }
    public string Name { get; set; }
}

public class OrdersDbContext(DbContextOptions options) : DbContext(options)
{
    public DbSet<Order> Orders { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);
        modelBuilder.Entity<Order>().ToCollection("orders");
    }
}

这就是我尝试使用它的方式:

var order = new Order
{
    Id = Helpers.GetNewId(),
    Name = "Some order"
};

var mongoClient = new MongoClient("mongodb://localhost:27017");
var dbContextOptions =
    new DbContextOptionsBuilder<OrdersDbContext>().UseMongoDB(mongoClient, "orders");
var ordersDb = new OrdersDbContext(dbContextOptions.Options);
ordersDb.Orders.Add(order);
ordersDb.SaveChanges();

调用时SaveChanges,我收到此错误:

未处理的异常。MongoDB.Driver.MongoIncompatibleDriverException:localhost:27017 上的服务器报告线路版本 4,但此版本的驱动程序至少需要 7(MongoDB 4.0.0)。

在 MongoDB.Driver.MongoIncompatibleDriverException.ThrowIfNotSupported(ClusterDescription 描述)
在 MongoDB.Driver.Core.Clusters.Cluster.SelectServerHelper.SelectServer()
在 MongoDB.Driver.Core.Clusters.Cluster.SelectServer(IServerSelector 选择器,CancellationToken cancellationToken)
在 MongoDB.Driver.Core.Clusters.IClusterExtensions.SelectServerAndPinIfNeeded(IClusterInternal 集群,ICoreSessionHandle 会话,IServerSelector 选择器,IReadOnlyCollection 1 deprioritizedServers, CancellationToken cancellationToken) at MongoDB.Driver.Core.Bindings.WritableServerBinding.GetWriteChannelSource(IReadOnlyCollection1 deprioritizedServers,CancellationToken cancellationToken)
在 MongoDB.Driver.Core.Bindings.WritableServerBinding.GetWriteChannelSource(CancellationToken cancellationToken) 在 MongoDB.Driver.Core.Bindings.ReadWriteBindingHandle.GetWriteChannelSource(CancellationToken cancellationToken)

这对我来说毫无意义,因为容器中实际的 mongodb 版本是 8.0.3。有什么办法可以修复它吗?

c#
  • 1 个回答
  • 34 Views
Martin Hope
Don Tomato
Asked: 2024-09-11 02:23:32 +0800 CST

如何从同一文件夹下的另一个脚本导入函数?

  • 5

假设我有 babashka 脚本 common.clj:

#!/usr/bin/env bb

(ns common)

(defn my-function []
  (println "do something"))

当我尝试从另一个脚本导入它时:

#!/usr/bin/env bb

(ns example
  (:require [common :as c]))

(c/my-function)

尽管common.clj我得到了一个错误:

(:require [common :as c]))
^--- Could not locate common.bb, common.clj or common.cljc on classpath.

可以修复吗?

clojure
  • 1 个回答
  • 19 Views
Martin Hope
Don Tomato
Asked: 2024-05-27 18:56:53 +0800 CST

如何从 clojure 与 java varargs 方法进行互操作

  • 5

根据文档我必须使用into-array但它不起作用。

(java.nio.file.Paths/get (into-array ["myfolder" "aaa.txt"]))
; Execution error (ClassCastException) at msm.config/eval10595 (form-init12148349852569231555.clj:153).
; class [Ljava.lang.String; cannot be cast to class java.net.URI ([Ljava.lang.String; and java.net.URI are in module java.base of loader 'bootstrap')

所以,我不完全明白该怎么做......

clojure
  • 1 个回答
  • 31 Views
Martin Hope
Don Tomato
Asked: 2024-05-25 19:54:20 +0800 CST

如何将参数列表传递给可变参数宏

  • 5

我有一个宏(我已经简化了一切):

(defmacro m1 [error & messages]
  `(if ~error
     (str "Error: " ~@messages)
     (str ~@messages)))

它运作得很好。但现在我想在带有 args 的函数中重用它[& messages]:

如果我按以下方式定义这个函数:

(defn error [& messages]
  (m1 true messages))

它有效,但当然是错误的。如果我调用(error "msg")它返回"Error: (\"msg\")"

但如果我做类似的事情:

(defn error [& messages]
  (apply m1 true messages))

它会导致错误

; 语法错误编译于...; 无法获取宏的值

所以问题是如何将消息列表传递给可变参数宏?

clojure
  • 1 个回答
  • 32 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve