- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我需要执行一个查询来检查一个集合是否在给定集合中,就像常规操作一样,但对于集合。
class Post
{
public string[] Tags {get;set;}
}
session.Queury<Post>.Where(x=>x.Tags.in(new[]{".net","c#","RavenDB"})).ToList();
所以如果我在我的数据库中有:
new Post{Tags= new[]{"C#",".net"}};
它会被退回
但如果我有:
new Post{Tags= new[]{"C#",".net","SQLServer"}};
不会退还。
更新:
我想做的是:
session.Query<Post>()
.Where(x => x.Tags.All(y => y.In(new[] { "C#", ".net", "RavenDB" })))
.ToList();
但我遇到了 System.NotSupportedException。
最佳答案
我设法找到解决方案:
static void Main(string[] args)
{
var sessionStore = new EmbeddableDocumentStore
{
RunInMemory = true,
UseEmbeddedHttpServer = true,
Conventions =
{
DefaultQueryingConsistency = ConsistencyOptions.AlwaysWaitForNonStaleResultsAsOfLastWrite
}
};
sessionStore.Initialize();
using (var session = sessionStore.OpenSession())
{
var allTags = new[] {"C#", ".net", "RavenDB", "Linux", "Mac"};
var tagsCollection = new[] {"C#", ".net", "RavenDB"};
var complementTagsCollection = allTags.Except(tagsCollection).ToList();
session.Store(new Post
{
Tags = new List<string>{"C#",".net"}
});
session.SaveChanges();
// Posts where all their tags are in tagsCollection
var result = session.Query<Post>().Where(x => !x.Tags.In(complementTagsCollection)).ToList();
}
}
关于c# - RavenDB Collection "in"集合查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25535363/
我正在玩Raven DB几天,我想将其用作Web聊天应用程序的存储。我有包含一些用户数据和聊天记录的文档-这是大集合的聊天消息。 每次加载用户文档时,聊天记录也会加载,即使我只需要几个字段,例如:用户
我的实体是: class Resource { string Name; string EmployeeId; } 如何查询多名员工的资源?我尝试了这个: Resource[] Fin
我知道这篇文章的标题会让一些人感到畏缩。我自 2011 年 12 月以来一直在使用 RavenDB,并且逐渐意识到我以不适合使用文档数据库的方式对数据进行建模。首先,我完全明白这一点。其次,考虑到我目
考虑 2 个查询: var test1 = store.OpenSession().Query().Where(x => x.Id == 1).ToList(); var test2 =
我正在运行 RavenDB.Client 2.0.2173-Unstable。我正在创建一个 Multi-Tenancy 系统,作为我注册过程的一部分,我想创建一个新的 Raven 数据库。 我有三行
我正在使用在 Visual Studio 2010 中通过 NuGet 安装的嵌入式 RavenDB => RavenDB-Embedded.1.0.499 包。它正在我阅读完这篇优秀文章后开始的当前
我们在 AWS 上有一个带有集群 RavenDB 服务器 (5.23) 的 DotNet Core API (C#)。创建文档时,Id 具有不同的格式,具体取决于客户端。如果使用 Swagger/Po
我想知道取回搜索记录总数的最佳方法是什么,同时取回第 N 个 128 记录块数据段,这似乎是 RavenDb 运行时强加的上限。 例如给定这个查询,我还需要知道记录的总数。 var bookmarks
我使用的是 RavenDB 2.0.3.0 版。连接调试器后,涉及 RavenDB 的所有内容都运行得非常缓慢。每个查询需要几秒钟才能完成。 如果我在调试器坐在那里时按下暂停键,我总是看到它挂断了以下
我使用以下代码从 RavenDB 中删除文档。在 Raven UI 的底部,我可以看到文档数量从 3,000,000 减少到 2,000,000。但是“数据”文件的大小不会缩小。它总是大约100G。
我想在我的 Raven DB 中轮询新文档。推荐的方法是什么?我可以使用 IndexTimestamp 还是可以依赖文档的顺序? 我想我想分两步完成: 1.检查是否有新的东西,如果有: 1.1。获取最
我已经更改了我的数据模型,并且需要将所有对象的属性更改为 null,因为在我的模型更改后反序列化它们会引发异常。 我猜我可以为每个文档发布一个补丁,但我找不到任何方法来做到这一点,修补某种类型的每个文
有没有办法在进行空间搜索时从 RavenDB 获取距离计算值。我尝试转换建议的 _ = SpatialIndex.Generate(r.Latitude, r.Longitude) 至 距离 = Sp
是否有一种明智的方法来 stub /模拟调用 IDocumentSession.Query() 的结果? ? 我有一个命令,我想验证在对象上调用了方法(即正在测试的“单元”是命令,而不是命令编排的对象
我想在存储在 RavenDB 文档数据库中的两个实体之间有一个引用。由于这不是关系数据库,我知道我应该使用 RavenDBs 文档中描述的非规范化引用技术。虽然起初这看起来不错,但一旦我开始创建一个真
是否可以使用返回单个文档但不是关键的属性从数据存储加载(而不是查询)文档? 在我的场景中,我有用户和品牌。品牌是用户,但用户不一定是品牌。每个品牌都有一个 UserId 属性及其 Id。有没有办法通过
通过官方 RavenDB 阅读一个简单的问题 documentation ,我知道您可以使用客户端 API 函数执行这些操作,但不能使用 RQL,或者无论如何都可以使用 RQL 执行。 最佳答案 您正
我正尝试在 RavenDB 中检索我按 int 列表排序的文档。 Queryable = Queryable.OrderBy(dto => SearchIds.IndexOf(dto.Property
我刚刚让 RavenDB 开始工作。 我意识到我必须启动 RavenDB\packages\RavenDB.1.0.573\server.exe 才能通过以下方式在我的应用程序中访问它: Do
RavenDB 是否有众所周知的做法来检查 RavenDb 的可用性或检查它在任何给定时间的过载程度?我研究了一些 ravendb API 服务。好像没找到关于健康监测的。有没有像官方的 ravend
我是一名优秀的程序员,十分优秀!