Raven.Client.Document.DocumentStore.Initialize C# (CSharp) Method

Initialize() public method

public Initialize ( ) : IDocumentStore
return IDocumentStore
		public IDocumentStore Initialize()
		{
			try
			{
#if !CLIENT
				if (configuration != null)
				{
					DocumentDatabase = new Raven.Database.DocumentDatabase(configuration);
					DocumentDatabase.SpinBackgroundWorkers();
					databaseCommandsGenerator = () => new EmbededDatabaseCommands(DocumentDatabase, Conventions);
				}
				else
#endif
				{
					databaseCommandsGenerator = ()=>new ServerClient(Url, Conventions, credentials);
					asyncDatabaseCommandsGenerator = ()=>new AsyncServerClient(Url, Conventions, credentials);
				}
                if(Conventions.DocumentKeyGenerator == null)// don't overwrite what the user is doing
                {
                    var generator = new MultiTypeHiLoKeyGenerator(DatabaseCommands, 1024);
                    Conventions.DocumentKeyGenerator = entity => generator.GenerateDocumentKey(Conventions, entity);
                }
			}
			catch (Exception)
			{
				Dispose();
				throw;
			}

            return this;
		}

Usage Example

Esempio n. 1
0
 public static IDocumentSession GetRavenDBConnection()
 {
     DocumentStore documentStore = new DocumentStore();
     documentStore.ConnectionStringName="RavenDB";
     documentStore.Initialize();
     return documentStore.OpenSession();
 }
All Usage Examples Of Raven.Client.Document.DocumentStore::Initialize