|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Raven.Client.Document;
using Raven.Client;
using System.IO;
namespace DocumentDB.Raven
{
class Program
{
public static string documentStoreLocation = @"http://localhost:8080";
[STAThread]
static void Main(string[] args)
{
Run();
}
public static void Run()
{
try
{
if (RavenServer.Instance.Start())
{
using (var documentStore = new DocumentStore { Url = documentStoreLocation, DefaultDatabase = "ravenTest" })
{
documentStore.Initialize();
RavenDemo ravenDemo = new RavenDemo(documentStore);
//Do general CRUD stuff
#region Simple CRUD stuff
ravenDemo.InsertTestData();
ravenDemo.ShowListOfBlogs();
ravenDemo.ShowListOfRecentPosts();
//Do simple insert then delete
ravenDemo.InsertFollowedByDelete();
#endregion
//Do transactions stuff
#region Transactions
//Do insert inside Transaction, that is RolledBack
ravenDemo.InsertInsideTransaction(true);
//Do insert inside Transaction, that is Committed
ravenDemo.InsertInsideTransaction(false);
#endregion
}
//FullTextSearch stuff
#region FullTextSearch stuff
//Do FullTextSearch stuff, but since ravenDB has no convient way (ok you could delete the files on disk) to create empty DB
//we will cheat and use its Multi-tenanting facilities
using (var documentStore = new DocumentStore { Url = documentStoreLocation, DefaultDatabase = "ravenTest-" + DateTime.Now.Ticks })
{
documentStore.Initialize();
RavenFullTextSearchDemo ravenFullTextSearchDemo = new RavenFullTextSearchDemo(documentStore);
ravenFullTextSearchDemo.Run();
}
#endregion
//Bulk DELETE stuff
#region BulkDelete stuff
//Do BulkDelete stuff, but since ravenDB has no convient way (ok you could delete the files on disk) to create empty DB
//we will cheat and use its Multi-tenanting facilities
using (var documentStore = new DocumentStore { Url = documentStoreLocation, DefaultDatabase = "ravenBulkDeleteTest-" + DateTime.Now.Ticks })
{
documentStore.Initialize();
RavenBulkDeleteDemo ravenBulkDeleteDemo = new RavenBulkDeleteDemo(documentStore);
ravenBulkDeleteDemo.Run();
}
#endregion
//Bulk UPDATE stuff
#region BulkUpdate stuff
//Do BulkUpdate stuff, but since ravenDB has no convient way (ok you could delete the files on disk) to create empty DB
//we will cheat and use its Multi-tenanting facilities
using (var documentStore = new DocumentStore { Url = documentStoreLocation, DefaultDatabase = "ravenBulkUpdateTest-" + DateTime.Now.Ticks })
{
documentStore.Initialize();
RavenBulkUpdateDemo ravenBulkUpdateDemo = new RavenBulkUpdateDemo(documentStore);
ravenBulkUpdateDemo.Run();
}
#endregion
}
}
catch (Exception ex)
{
Console.WriteLine("============= OH NO : ERROR ============");
}
Console.ReadLine();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)
- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence
Both of these at Sussex University UK.
Award(s)
I am lucky enough to have won a few awards for Zany Crazy code articles over the years
- Microsoft C# MVP 2016
- Codeproject MVP 2016
- Microsoft C# MVP 2015
- Codeproject MVP 2015
- Microsoft C# MVP 2014
- Codeproject MVP 2014
- Microsoft C# MVP 2013
- Codeproject MVP 2013
- Microsoft C# MVP 2012
- Codeproject MVP 2012
- Microsoft C# MVP 2011
- Codeproject MVP 2011
- Microsoft C# MVP 2010
- Codeproject MVP 2010
- Microsoft C# MVP 2009
- Codeproject MVP 2009
- Microsoft C# MVP 2008
- Codeproject MVP 2008
- And numerous codeproject awards which you can see over at my blog