Expected version: 0, Current version: -1

Where can I find any info in documentation that new steam should have version = -1 otherwise there is error:

WrongExpectedVersionException

Hello, Aleksander,

You can find it documented here:

https://eventstore.org/docs/dotnet-api/optimistic-concurrency-and-idempotence/index.html

https://eventstore.org/docs/http-api/optional-http-headers/expected-version/index.html?tabs=tabid-1%2Ctabid-3%2Ctabid-5

Wow you beat me to it! :slight_smile: I was just answering this…,

as esu skolingas(?!) alaus

Sorry my Lithuanian is rusty :stuck_out_tongue:

For the value here 0-int.maxvalue are actual position you expect. There are then some special ones which are negative.

  • 0, the stream should exist but be empty when writing.
  • -1, the stream should not exist when writing.
  • -2, the write should not conflict with anything and should always succeed.
  • -4, the stream or a metadata stream should exist when writing.

Greg


Virus-free. www.avast.com

Thx very much :slight_smile: I have also one request :slight_smile: Could You add to the documentation how to register EventStore in ASP.NET Core in Startup.cs?

Below code from ducumentation is maybe good for console application but not for ASP.NET Core application:

var connection =
    EventStoreConnection.Create(new IPEndPoint(IPAddress.Loopback, 1113));

// Don't forget to tell the connection to connect!
connection.ConnectAsync().Wait();

W dniu niedziela, 23 czerwca 2019 10:28:47 UTC+2 użytkownik Aleksander Wercis napisał:

can you drop a ticket in docs with what you are looking for there (maybe a bit more specific?)

I have sent the below email to You:

Could You add to the doc how to register EventStore in ASP.NET Core application? Because now I have improvise.

I have added to Startup.cs to method ConfigureServices:

services.AddSingleton(); // singleton or maybe scoped or maybe transient?

The class ‘EventStoreContext’:

public class EventStoreContext
{
public IEventStoreConnection Connection { get; }

    public EventStoreContext()
    {
        Connection = EventStoreConnection.Create("ConnectTo=tcp://admin:changeit@localhost:1113;");
        Connection.ConnectAsync().Wait();
    }
}

W dniu niedziela, 23 czerwca 2019 13:31:19 UTC+2 użytkownik Greg Young napisał: