问题标签 [litedb]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
151 浏览

system.io.file - LiteDB 是否支持连接字符串中的长文件名(>=260 字符)

我使用 litedb 作为文件索引,借此我重新创建文件共享的目录结构并将 litedb.db 文件拖放到我的层次结构中的每个目录中。我遇到的问题似乎是目录结构长度超过 260 个字符(请参阅下面的错误消息)。连接到 litedb 时,有没有办法在连接字符串中启用对长文件名的支持?或者,有没有一种方法可以使用其他方法(例如 file.open AlphaFS)来实例化我的 litedb 实例。

0 投票
2 回答
1844 浏览

c# - 如何在 DataGridView 中显示 LiteDB 数据?

我是 LiteDB 的新手,但在使用繁琐的 CSV 文件后,它似乎非常适合我的应用程序,但我无法在 Windows 窗体 DataGridView 中显示数据。

我的 LiteDB 数据库在存储数据方面运行良好,但需要帮助来显示数据。

这是我的 POCO 和用户数据存储方法:

我只是尝试将 DataGridView 与对象作为数据源链接,但它不显示数据,只显示标题。我也上网寻找类似的问题或答案,但它似乎是一个相当原始的。

任何有关让数据显示在 DataGridView 中的帮助表示赞赏。

0 投票
1 回答
27 浏览

nosql - 根据以前的记录检索文档结构

写这个问题我正在使用 .Net 的LiteDB,但我认为这个问题适用于整个 NoSQL 问题。

我的数据库中的一个集合包含没有固定结构的文档。我想让用户添加他自己的值,无论他想要什么名称和值。

因此,例如,文档最初将具有以下结构:

但是用户将能够指定新值并选择它是int还是boolean

下次用户打开我的应用程序时,他可能会想要使用与他以前使用过的相同类型的值,所以我需要向他展示某种形式的输入,这些输入是基于他之前的活动命名的。因此,如果他之前添加了名为“customValue”的值,我想在他下次打开带有表单的页面时向他展示名为“customValue”的 TextView。

有没有一种方法可以根据集合中的每条记录来检索此类文档的结构?或者我是否需要以某种方式跟踪附加值的名称并将它们保存在单独的集合中?

0 投票
2 回答
1092 浏览

c# - 如何正确实现为异步使用而设计的接口?

从下面考虑到 async/await 的(简化)接口开始,我想通过使用 LiteDB 数据库来实现它。

不幸的是,LiteDB 目前不支持异步方法。所有方法都是同步的。

我尝试了以下方法,但后来遇到了一些问题(过程并没有真正等待任何原因)。在那之后,我读到你应该只Task.Run()用于 CPU 绑定算法,因此不能用于数据库访问。

尽管我阅读了几篇博客文章和 SO 问题,但我仍然不清楚如何为基于同步 IO 的代码制作一个正确编写的可等待方法。

那么我怎样才能编写一个正确的等待方法呢?

注意:我无法更改界面。这是给的。

0 投票
2 回答
186 浏览

c# - LiteDB-如何在两个不同的项目中添加 LiteDB 的 2 个 DLL,但它们被一个主项目引用

我创建了 3 个项目:

  1. V_1_OperationProject:(
    类库项目)处理 LiteDb 版本 1 上的操作
  2. V_4_OperationProject :(
    类库项目)处理 LiteDb 版本 4 上的操作
  3. MainProject:
    调用 V_1_OperationProject 和 V_4_OperationProject 项目中的方法

V_1_OperationProject 包含打开和插入从 LiteDB v1 dll 创建的 DB 文件的逻辑,与 V_4_OperationProject 类似。

当我要从 V_1_OperationProject 在 DB 中插入值时,出现以下异常:

System.IO.FileLoadException:'无法加载文件或程序集'LiteDB,版本 = 1.0.0.0,文化 = 中性,PublicKeyToken = null'或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(来自 HRESULT 的异常:0x80131040)'

当我删除 V_4_OperationProject 及其关联的 DLL 后,它就开始工作了。但我希望两者都能工作。

所以我尝试在主项目中添加以下内容:

这也不适合我。有人可以帮我吗?提前致谢

0 投票
1 回答
152 浏览

c# - 如何知道创建了哪个 LiteDB 版本的 DB 文件?

我正在使用 LiteDB 创建 db 文件。但有时我使用 LiteDB 版本 1,有时使用 v4。使用任何版本我正在创建相同的文件。那么如何检测使用哪个版本的 LiteDB 在 C# 代码中创建 db 文件呢?注意:我不想要数据库文件的用户版本。提前致谢。

0 投票
1 回答
283 浏览

c# - 我可以动态选择 LiteCollection 的类型吗在方法签名中?

我有一个自定义类 Customer 并在另一个类中返回一个基于来自 LiteDB 的 LiteCollection 的列表,该列表使用签名中的 Customer 类进行典型化。我想知道的是是否可以创建一个动态选择哪个类使用类型的方法,这意味着如果我可以将 LiteCollection 的类类型作为参数传递,以便在我调用该方法时返回。

代码如下:

0 投票
1 回答
121 浏览

c# - LiteDB 插入或检索 master 的详细信息列表

我们如何Detail使用 LiteDB (LiteDatabase) C#.net 库从下面表示的属性中插入或检索主人的详细信息?

请注意,我尝试LiteDatabase.Insert()使用项目填充属性,但是当我调用任何myEntityMaster函数时,该属性将为空。DetailLiteDatabase.FindDetail

0 投票
1 回答
67 浏览

c# - 如何插入/更新列表作为 SQLite 中实体的成员?

假设我有一个非常简单的课程:

每当我尝试myClass从数据库中检索实体时,ListOfStrings即使我已经准确地调试到 CRU D进程以确保在实体上调用或方法ListOfStrings之前填充得很好,也会为空Insert()Update()

0 投票
1 回答
101 浏览

mysql - Database design with user data and central database updates

I am designing a windows desktop app. It uses LiteDB as the single file local db for users - using it very much as a relational database with foreign keys etc (each Table having an integer ID as primary key and references to other tables via FK integers).

It's a retro-gaming app, so 'tables' will include things such as:

System (e.g. "Sony PlayStation", "Nintendo 64")

Controller (e.g. "Sony Dual Shock")

Control (e.g. "Cross", "Start", "Select")

Because of the above, I will have to stick to using integer IDs as the primary key - I though about using the 'name', but this wouldn't work for Controls (i.e. Start will be found on many controllers).

User should be able to add and delete records as they wish (although there will be a discouraging of deleting 'standards')

The challenge is that I'm also going to host a mysql database on my server, allowing users to update their tables from this. Now this is the bit I can't get my head around.

Say they add a System "Casio Watch" to their local table. This will get an auto-gen ID (say '94'). At the same time, some updates occur on the server database and a new system is added (e.g. "Commodore Calculator") this also gets the auto-gen ID of '94.' That's conflict number 1.

You could get around the above by just appending it as a new row in the user db - getting a new ID in that. But my second worry is around foreign keys. Let's say there's a 'Manufacturers' table with a 'Biggest Seller' field. Now on the server, for Manufacturer = Commodore, the 'Biggest Seller' FK is 94 for "Commodore Calculator" However, if this Manufacturer table is imported into the user local db, then Commodore's biggest seller would be "Casio watch" - it's ID being 94 on the user db.

Forgive me if I'm being a bit slow about all this. Referential integrity is coming to mind (is that the one with update/null FKs on change??) but I don't think you can do this through LiteDB (i.e. a change in one does not cascade to related tables).

Any advice would be greatly appreciated.