Introducing the LearningLine

Recently we have been working on something new at DevelopMentor for online teaching. I still really like teaching in the classroom and I think that this is a great environment to learn new material. But it is also a very expensive and not very scalable way of learning. It typically means being away from the office for a week at a time and that can be hard on the business and on your colleagues.   And while the classroom is a great place to learn that will do you little good if you can’t go there. So we are starting … Continue reading Introducing the LearningLine

Using optimistic concurrency with RavenDB

Whatever database your are using, relational or document, there is one thing you can be certain of as soon as you get a second user of the system and that is concurrency conflicts. It may not happen often but eventually it will happen that two users load the same document, make some changes to it and save it back to the database. There are several ways of dealing with these kind of concurrency problems: Just ignoring it and letting the second users changes overwrite the first ones While this isn’t advisable if the data is very important there are lots … Continue reading Using optimistic concurrency with RavenDB

Paging through data in RavenDB

RavenDB has a very nice feature in it being safe by default and returns just 128 documents. Now you can override these safe defaults but it is very unwise to do so. And even if you decide to do so are you really going to show a million customers to your user at the same time? I would guess not as the user would not be really happy with the response or the speed of it. In most cases using paging is a much better solution.   Paging through a RavenDB result set It turns out that paging through a … Continue reading Paging through data in RavenDB

Storing and retrieving records using RavenDB

After installing RavenDB 2 the next step is to start saving data and load it again. Unlike SQL server we don’t need to go into the RavenDB Management Studio and create a database and tables with a schema. The database, optional but highly recommended, will be created when we first access it. And when it comes down to tables and schema RavenDB is much simpler, all it does is store documents. A document doesn’t have a schema enforced so we don’t need to define one up front. Instead we just save some data and load it again. The document to … Continue reading Storing and retrieving records using RavenDB

Installing RavenDB 2

Before we get started with RavenDB we need to install the required parts. There are several ways we can do this and one of the easiest is using the NuGet Package manager from within Visual Studio 2012 with the available RavenDB NuGet packages.   Which package to install? As should be obvious from the screenshot above there are quite a few NuGet packages to choose from. It turns out we need to use two packages to get started, the client and server part. Adding them is easy, just open the NuGet Package Manager Console window from the Visual Studio Tools … Continue reading Installing RavenDB 2

Querying RavenDB databases

As we have seen in previous blog posts getting data from a RavenDB database is easy. Either use the IDocumentSession.Query<T>() function to load a series of documents or the IDocumentSession..Load<T>() function to load a document using its identity. However sometimes we want more control over what we want to load. It turns out this is rather easy as the IDocumentSession.Query<T>() function returns an IQueryable<T>, actually it returns a IRavenQueryable<T> to be exact but more about that another time. Querying the database As IDocumentSession.Query<T>() return an IQueryable<T> we can just start composing queries just as we can with EntityFramework or another … Continue reading Querying RavenDB databases

Using RavenDB with Azure websites

In a previous post I explored various options of hosting RavenDB. While using RavenDB as a Windows Service or hosted in IIS is probably the best way to go in most cases there are a number of cases where the embedded option is great. And one of the places where I really like the embedded option of hosting RavenDB is when doing simple standalone websites. And with the new Azure website option that is a great way to host them.   The code is real straightforward and just like before. I am using a DataDirectory option when creating the EmbeddableDocumentStore … Continue reading Using RavenDB with Azure websites

Different options for hosting RavenDB

In the previous blog posts about RavenDB I used the Raven.Server.exe to create a database server. Just running raven.Server.exe and connecting to it is fine for development but certainly not our only option.   Running RavenDB as a Windows Service Once you have the RavenDB.Server NuGet package you can install it as a Windows Service. This means it is always available and running whenever you need it. Certainly a nice and simple way of using RavenDB if you do so more often.   Installing is easy, just run Raven.Server.exe /install and it installs.   Running as an IIS application Another … Continue reading Different options for hosting RavenDB

RavenDB and multiple databases

In my previous two posts about RavenDB I used a Book class as the example. The first example was an ASP.NET MVC 3 application and the second was an ASP.NET MVC 4 application and I just copies the Books class from the first to the second example. As I just used the default namespace in both projects .NET would consider this two different classes, after all the namespace and assemblies are different.   How does RavenDB handle CLR types It turns out RavenDB doesn’t really care about these differences with namespaces and assemblies. The extra information is stored as metadata … Continue reading RavenDB and multiple databases

Using RavenDB with ASP.NET MVC 4

Some people might have wondered why I used ASP.NET MVC 3 in my previous blog post. The reason is that the RavenDB.Client package uses Newtonsoft.Json and ASP.NET MVC 4 also has a dependency on Newtonsoft.Json. In itself this isn’t a problem except that RavenDB requires Newtonsoft.Json version 4.0.8 and ASP.NET MVC 4 ships with a much newer version of Newtonsoft.Json, to be exact version 4.5.6. The result is that trying to Install-Package RavenDB.Client produces the following error: Install-Package : Updating ‘Newtonsoft.Json 4.5.6’ to ‘Newtonsoft.Json 4.0.8’ failed. Unable to find a version of ‘Microsoft.AspNet. WebApi.Client’ that is compatible with ‘Newtonsoft.Json 4.0.8’. … Continue reading Using RavenDB with ASP.NET MVC 4