Skip to main content

Posts

Showing posts with the label RavenDB

NDepend–Find out where a library is used–Part 2

A few weeks ago I was contacted by Patrick Smacchia , the creator of NDepend , if I would check out the latest edition of their code quality tool. As I had an upcoming software audit assignment planned, I thought it would be a great occasion to see what NDepend brings to the table and how it can help me to improve my understanding of an unfamiliar codebase. Yesterday I shared how I was able to generate the CQLinq query I needed through the class browser. While writing that post I noticed that NDepend also suggested me to use another feature to get there. When creating a new query, the editor suggests you to have a look at the code search feature: So let’s do that today. I opened Search (View –> Search View). Let’s see if we can find all Repository objects. I change the ‘Element’ value to ‘Type’ and enter ‘Repository’ in the search field. NDepend picks this up and generates a CQLinq query for me.

SQL or NoSQL, that’s the question…

Are you still using your ‘old school’ relational database or do you want to work with one of the hip and funky NoSQL(Not Only SQL) solutions?  Either way your applications will probably have to store some data. To help you find the best solution for your problem domain, the Microsoft Patterns & Practices team released a new guide about Building Highly-Scalable Solutions for Storing and Retrieving Data (Using SQL and NoSQL Databases)   From the guide: This guide focusses on the most common types of NoSQL database currently available, describes the situations for which they are most suited, and shows examples of how you might incorporate them into a business application. To illustrate good practice, the guide summarizes the experiences of a fictitious organization named Adventure Works, who implemented a solution based initially on a relational database. Some inefficiencies in the resultant system caused them to modify their system to take advantage of different NoSQL da...

RavenDb: Delete al documents from a specific type

Last week I was looking for a way to delete all documents of a specific type from the database. For example you want to remove all your Orders from the database. I started implementing this by loading all documents and delete them one by one. But this was a rather inefficient solution, so I started to look at some alternatives. After some attempts, I ended up with the following code: var documentName="Orders"; session.Advanced.DatabaseCommands.DeleteByIndex("Raven/DocumentsByEntityName", new IndexQuery { Query = "Tag:" + documentName }, allowStale: true ); Clean, simple AND efficient!

RavenDB: Change the primary key convention

Every document in RavenDB should have a unique identifier. By default it searches for properties named Id. If it couldn’t find such a property an unique identifier is created for you behind the scenes(but is not available through a property on your object). But what if you don’t like this convention? For example what if you want to call your identifier properties ‘key’ instead of ‘id’. Changing this convention is easy in RavenDB: var documentStore = new EmbeddableDocumentStore { DataDirectory = "App_Data", UseEmbeddedHttpServer = true }; var store= documentStore.Initialize(); store.Conventions.FindIdentityProperty = prop => { return prop.Name .Equals("key",StringComparison.InvariantCultureIgnoreCase); };

RavenDB: accessing a specific database using the HTTP API

RavenDB offers the following options to access it: .NET Client API: The Client API allows easy access to it from any .NET language. The .NET Client API exposes all aspects of the RavenDB server to your application in a seamless manner. HTTP API: RavenDB provides an HTTP API for accessing and manipulating data on the server. This API sits next to the C# Client API, providing most of the same functionality, but with a platform agnostic, web friendly interface. Using the HTTP API, it's possible to write a fully functioning RavenDB application using just Javascript and HTML. For a demo application I’m building I wanted to use the HTTP API but I only had one problem, what’s the correct URL to access data in a specific RavenDB database? To access data(e.g. docs) in the default database, you can use: curl -X GET http://localhost:8080/docs/locations/1 But I created a specific database instance, what’s the impact on the URL? After some trial and error I discovered that the synta...