私は2つのアプリケーションのインスタンスを実行しています。 1つのインスタンスでは、私は自分のエンティティの1つを保存します。 RavenDB(http:// localhost:8080/raven)をチェックすると、私はその変更を見ることができます。次に、私の他のクライアントでは、これを行います(下記)が、他のアプリケーションからの変更は表示されません。 DBで最新のデータを取得するためには何が必要ですか?RavenDB - 1人のクライアントは別のクライアントからの変更を見ることができません
public IEnumerable<CustomVariableGroup> GetAll()
{
return Session
.Query<CustomVariableGroup>()
.Customize(x => x.WaitForNonStaleResults());
}
編集:変更を加えて並行性の例外を取得しようとすると、上記のコードが機能します。その後、リフレッシュ(上記のコードを呼び出す)を呼び出すと、動作します。私ができるだけで、より詳細な情報といくつかのコードを欠く
public abstract class DataAccessLayerBase
{
/// <summary>
/// Gets the database.
/// </summary>
protected static DocumentStore Database { get; private set; }
/// <summary>
/// Gets the session.
/// </summary>
protected static IDocumentSession Session { get; private set; }
static DataAccessLayerBase()
{
if (Database != null) { return; }
Database = GetDatabase();
Session = GetSession();
}
private static DocumentStore GetDatabase()
{
string databaseUrl = ConfigurationManager.AppSettings["databaseUrl"];
DocumentStore documentStore = new DocumentStore();
try
{
//documentStore.ConnectionStringName = "RavenDb"; // See app.config for why this is commented.
documentStore.Url = databaseUrl;
documentStore.Initialize();
}
catch
{
documentStore.Dispose();
throw;
}
return documentStore;
}
private static IDocumentSession GetSession()
{
IDocumentSession session = Database.OpenSession();
session.Advanced.UseOptimisticConcurrency = true;
return session;
}
}
上記のコードをSave()に追加しました。それは役に立ちますか? –
インデックスを追加していないことにも注意してください。 RavenDBが自動的にインデックスを追加したようです。手動で追加するのが古いかどうか、それともまだ適切かどうかはわかりません。 –
Bob、手動でインデックスを追加する必要はありません。 RavenDBはクエリを評価し、あなたの質問(クエリ)に対する回答を提供する動的なインデックスを作成します。これらが頻繁に使用されると、RavenDBは自動的に最適化され、インデックスを永続化してディスクに保存します。非常に複雑なインデックスを手動で追加するだけで済みます。オリジナルの質問に答えるために上記の私の編集を見てください。 –