BMills
BMills

Reputation: 901

Get Id of just created Raven Document

Say I'm storing a new document without specifying an id so it uses the raven automatic one, how would I then retrieve that id for immediate use?

League league = new League(){Name = "League1"};
RaventSession.Store(league);

Division division = new Division(){ Name = "Division1",
                                    LeagueId = //need league id for this property

Upvotes: 0

Views: 73

Answers (1)

Embri
Embri

Reputation: 622

When you store an entity, the id is assigned to the entity (if you don't set it) then check league.Id after RaventSession.Store(league);

note that you can also use RaventSession.Advanced.GetDocumentId(league); to retrieve the stringId of the entity

Upvotes: 2

Related Questions