假设我有以下域:
public class Movie
{
public string Id { get; set; }
public string Name { get; set; }
public List<ActorReference> Actors { get; set; }
}
public class Actor
{
public string Id { get; set; }
public string Name { get; set; }
public string Biography { get; set; }
public string AnotherDetailProperty { get; set; }
}
public class ActorReference
{
public string Id { get; set; }
public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
现在,如果演员的名字发生变化,我想确保所有引用的电影也会更新。因此,我首先创建一个索引,让我查询涉及特定演员的所有电影: …
这是例外,现在完全让我的生活很痛苦。不知道发生了什么变化,但数据库位于 MVC3 站点的 App_Data 文件夹中。该网站托管在 IIS 7.5 中,作为默认网站。
任何解决问题的建议都将受到欢迎。
编辑..问题可能或多或少与我的控制器代码在抛出异常后没有清理有关,因此没有在文档会话上调用 dispose
Line 30: instance = new EmbeddableDocumentStore { ConnectionStringName = "RavenDB" };
Line 31: instance.Conventions.IdentityPartsSeparator = "-";
Line 32: instance.Initialize();
[EsentFileAccessDeniedException: Cannot access file, the file is locked or in use]
Microsoft.Isam.Esent.Interop.Api.Check(Int32 err) in C:\Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Api.cs:2739
Microsoft.Isam.Esent.Interop.Api.JetInit(JET_INSTANCE& instance) in C:\Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Api.cs:131
Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator) in c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:207
[InvalidOperationException: Could not open transactional storage: C:\code\BE\Com.BuyEfficient\Com.BuyEfficient.Web\App_Data\ravendata\Data]
Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator) in c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:220
Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration configuration) in c:\Builds\RavenDB-Stable\Raven.Database\DocumentDatabase.cs:156
Raven.Client.Embedded.EmbeddableDocumentStore.InitializeInternal() in c:\Builds\RavenDB-Stable\Raven.Client.Embedded\EmbeddableDocumentStore.cs:143
Raven.Client.Document.DocumentStore.Initialize() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\DocumentStore.cs:483
Com.BuyEfficient.Web.Infrastructure.DataDocumentStore.Initialize() in C:\code\BE\Com.BuyEfficient\Com.BuyEfficient.Web\Infrastructure\DataDocumentStore.cs:32
Com.BuyEfficient.Web.App_Start.Services.PreStart() in C:\code\BE\Com.BuyEfficient\Com.BuyEfficient.Web\App_Start\Services.cs:25 …Run Code Online (Sandbox Code Playgroud) 我正在运行 RavenDB.Client 2.0.2173-不稳定。我正在创建一个多租户系统,作为注册过程的一部分,我想创建一个新的 Raven 数据库。
我有三行简单的代码..
string newDBName = "1234";
IDocumentStore documentStore = new DocumentStore { Url = "http://myserver:8080", DefaultDatabase = newDbName};
documentStore.Initialize();
documentStore.DatabaseCommands.EnsureDatabaseExists(newDBName);
Run Code Online (Sandbox Code Playgroud)
根据建议,我也尝试过这个:
string newDBName = "1234";
IDocumentStore documentStore = new DocumentStore { Url = "http://myserver:8080"};
documentStore.Initialize();
documentStore.DatabaseCommands.EnsureDatabaseExists(newDBName);
Run Code Online (Sandbox Code Playgroud)
我在最后一行收到 InvalidOperationException,Raven 告诉我它不知道该怎么做。
<h1>Could not figure out what to do</h1>
<p>Your request didn't match anything that Raven knows to do, sorry...</p>
Run Code Online (Sandbox Code Playgroud)
我知道我的连接/服务器可以正常工作,因为我可以从默认数据库读取/写入。
是权限问题吗?
我正在尝试使用符合我所看到的各种 Greg Young 启发示例的实践和原则来实现一个事件溯源系统。
我了解版本检查逻辑是如何工作的,并且在保存聚合时,如果当前版本与预期版本不匹配,则意味着另一个会话/客户端应用程序在您之前更新了聚合。
我也知道您可以制定一种在保存并发事件时追溯解决冲突的方法,这个问题与这样做无关。
我想了解的是,在使用 nosql 数据库(例如 ravendb)作为事件存储的特定实现中,我将如何确保写入的事件不会因竞争条件而与版本号重叠。
以下代码来自一个示例项目来说明:
在Repository<TAggregate>存储库类中有一个保存方法
public void Save(AggregateRoot aggregate, int expectedVersion)
{
if (aggregate.GetUncommittedChanges().Any())
{
lock (_lockStorage)
{
var item = new T();
if (expectedVersion != -1)
{
//issue if two processes get to this line of code below together
//and both have the same 'version to be expected' then start writing together
item = GetById(aggregate.Id);
if (item.Version != expectedVersion)
{
throw new ConcurrencyException(string.Format("Aggregate {0} has been previously modified",
item.Id));
} …Run Code Online (Sandbox Code Playgroud) 我在部署到 Azure 应用服务的 Web 应用程序上收到 TCP/IP 端口耗尽错误。该问题与占用端口的 RavenDB 连接会话有关。我想我有一个修复程序并且应该很好,但我觉得自己被超越了,因为我真的无法在部署的环境中做很多调试。
在调试问题时,我尝试访问 netstat,但收到访问被拒绝消息,似乎无法绕过它。有什么想法吗?
切线:Azure webapp 中的端口是如何分配的?提出的选项(如https://msdn.microsoft.com/en-us/library/aa560610(v=bts.20).aspx 中所述)有减少套接字连接超时值或动态增加端口上限分配给客户端 TCP/IP 套接字连接。但是,我认为这在 Azure Web 应用程序中是不可能的。
我正在尝试在分页列表中显示文档修订。这仅在我知道总结果数时才有效,以便我可以计算页数。
对于常见的文档查询,这可以通过session.Query(...).Statistics(out var stats).
我目前的解决方案如下:
// get paged revisions
List<T> items = await session.Advanced.Revisions.GetForAsync<T>(id, (pageNumber - 1) * pageSize, pageSize);
double totalResults = items.Count;
// get total results in case items count equals page size
if (pageSize <= items.Count || pageNumber > 1)
{
GetRevisionsCommand command = new GetRevisionsCommand(id, 0, 1, true);
session.Advanced.RequestExecutor.Execute(command, session.Advanced.Context);
command.Result.Results.Parent.TryGet("TotalResults", out totalResults);
}
Run Code Online (Sandbox Code Playgroud)
这种方法的问题是我需要一个额外的请求来获取第一个请求TotalResults确实已经返回的属性。我只是不知道如何访问它。
我在 C 驱动器上有一个数据库,我需要从中查询以获取所有餐馆的名称。我是 RavenDB 的新手,似乎找不到任何关于如何从位于计算机 C 驱动器上的文件夹进行查询的文档。有没有人知道如何做到这一点?
我们正在从 MongoDb 迁移到 RavenDb,但遇到了一个问题。
我们有一个简单的模型(C# DotNet)
using System.Globalization;
public class Location
{
#region Properties
public double Latitude { get; set; }
public double Longitude { get; set; }
#endregion Properties
#region Methods
public override string ToString()
{
var numberFormatInfo = new NumberFormatInfo { NumberDecimalSeparator = "." };
return $"{Longitude.ToString(numberFormatInfo)} {Latitude.ToString(numberFormatInfo)}";
}
#endregion Methods
}
public class Place
{
public Location[] Area {get;set;} // Please note the array
}
Run Code Online (Sandbox Code Playgroud)
客户可以选择一个地点作为一对,或者他们可以在交互式地图上绘制一个多边形,代表该地点,该多边形将存储在上面的 Area 属性中。
在 MongoDb 中,这再简单不过了
var locationQuery = new FilterDefinitionBuilder<Place>()
.GeoWithinBox( …Run Code Online (Sandbox Code Playgroud) 我需要在一段时间后将文档标记为过期,因此我尝试使用 @refresh 功能重新运行订阅并计算我的“过期”标志。我知道有“文档过期”功能,但这个功能会删除我不想要的数据。
我在设置中打开了刷新功能,并在所需文档的元数据中添加了 @refresh UTC 日期时间。例如我手动添加了这个文件:
{
"Name": "My data",
"@metadata": {
"@collection": "Testing",
"@refresh": "2021-04-30T07:41:35.4845961Z"
}
}
Run Code Online (Sandbox Code Playgroud)
看起来我正面临非确定性行为 - 有时会处理刷新有时不会。我尝试了不同的时间组合,并通过代码或 Raven Studio 进行设置。
我在用
在错误跟踪器中没有找到相关问题 https://issues.hibernaterhinos.com/issues/RavenDB?q=document%20refresh
任何想法要检查什么或可能是什么情况?
编辑:打开登录控制台后,我发现了一些错误日志。看起来像
RavendbProject, Raven.Server.Documents.Expiration.ExpiredDocumentsCleaner, Failed to refresh documents on RavendbProject which are older than 05/17/2021 09:48:47, EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object.
RavendbProject | at Sparrow.Server.ByteStringContext`1.From(String value, ByteStringType …Run Code Online (Sandbox Code Playgroud) 我正在使用 pyravendb 中的 document_store 来使用 session 将实体加载为数据框。我想知道是否可以加载集合并将其作为数据框获取?
from pyravendb.store import document_store
document_store = document_store.DocumentStore("http://live-test.ravendb.net", "DemoUser-08fef053-7143-4fc7-9860-bc415838799d")
document_store.initialize()
with document_store.open_session() as session:
employee = session.load(["employees/8-A"])
display(employee)
Run Code Online (Sandbox Code Playgroud)