Getting Started with .NET Document Databases Using Marten

Marten is a document database library for the easy storing, updating, and querying of .NET objects. It provides an easy way for you to persist data without the added complexities of object relational mapper tools.
Course info
Rating
(19)
Level
Intermediate
Updated
Nov 4, 2016
Duration
1h 43m
Table of contents
Description
Course info
Rating
(19)
Level
Intermediate
Updated
Nov 4, 2016
Duration
1h 43m
Description

Marten is an open source library for .NET that enables the use of an underlying PostgreSQL database as a document database. Marten can be used as a replacement or alternative to other document databases such as MongoDb or RavenDb and can also be an alternative to ORMs such as Entity Framework. In this course, Getting Started with .NET Document Databases Using Marten, you'll learn how the open-source Marten library allows you to use the PostgreSQL database as a document database in which to persist your .NET objects. First, you'll explore the fundamentals of how Marten works. Next, you'll discover how to store .NET entities as documents and how to update and delete documents. Finally, you'll learn the various ways to query the data from your .NET application. By the end of this course, you'll understand how to use Marten to store objects as documents and how to retrieve, modify, and delete them from C# code.

About the author
About the author

With over 15 years experience, Jason Roberts is a Microsoft .NET MVP, freelance developer, and author.

More from the author
Working with Files and Streams in C#
Intermediate
3h 13m
12 Oct 2018
Error Handling in C# with Exceptions
Intermediate
1h 37m
6 Aug 2018
More courses by Jason Roberts
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi everyone, my name's Jason Roberts. Welcome to my course, Getting Started With. NET Document Databases Using Marten. I am a Microsoft. NET MVP, freelance developer and author. In this course, we're going to learn how the open source Marten library allows us to use the PostGrass database as a document database in which to persist our. NET objects. Some of the major topics that we'll cover in this course include the fundamentals of how Marten works, how to store. NET entities as documents, how to update and delete documents, and the various ways to query the data from our. NET application. By the end of this course, you'll understand how to use Marten to store objects as documents and how to retrieve, modify, and delete them from C# code. Before beginning the course, you should be familiar writing basic C# code in Visual Studio. I hope you'll join me on this journey, with the Getting Started with. NET Document Databases Using Marten course, at Pluralsight.

Getting Started
Hi, I'm Jason Roberts from Pluralsight. Welcome to this course, Getting Started with. NET Document Databases Using Marten. In this first module, we're going to be getting acquainted with Marten and getting things set up in Visual Studio. In this module, we're going to start off by looking at some of the design goals that the Marten team had when creating the Marten library. So for example, we'll learn that one of the design goals was to improve developer productivity when storing and retrieving objects. We'll then get a brief overview of document databases and how they differ from regular relational databases. We'll get a high level overview of the Postgres database system and we'll learn that Marten uses the advanced JSON features of Postgres to store document data. We'll then get an architectural overview of how Marten works when we're storing entities. And then we'll jump into some demos where we'll start off by installing the Postgres database on my Windows machine. And we'll use the supplied pgAdmin tool to connect to the Postgres server and create a new database in which we're going to store our documents. We'll head over to Visual Studio and we'll install the Marten NuGet package into the application. This NuGet package will give us access to the Marten features, one of which is the IDocumentStore Interface. So we'll learn more about this interface and then we'll head back to Visual Studio and we'll actually create an instance of an IDocumentStore within our application. It's this document store instance that we're going to use to work with our data. So let's kick off this module by looking at some of the design goals the Marten team has.

Querying Data
Hi, welcome back. In the previous module we learned the basics of working with documents such as how to store and retrieve them, how to delete them, and how to set up foreign key constraints. In this module we're going to be focusing on how we can query existing data in the database. So we'll be learning the two main ways to query data using Marten and that's to use LINQ and also SQL queries. So in this module we're going to be learning about all of the major LINQ operators that Marten supports. So for example we'll start off by looking at the where operator and we'll learn how to use this to query data in the database. And we'll see that we can use equality, inequality, comparison, logical and, and logical or operators in conjunction with the where operator. We'll learn how to write queries where some of the data contains null values. And we'll learn some of the different ways we can query string values. So for example finding all names that contain a certain sub string. We'll learn that if we only expect one document to exist in the database matching certain criteria, we can expect only a single document to be returned, and we'll also see how if we need to we can return all documents of a given type. So for example returning all of the customers in the database. We'll learn about some of the other link operators such as the aggregation and sorting operators that Marten supports. And we'll learn how we can reduce database round trips and network traffic by including related documents in one database call. Finally we'll learn that if you hit an H case where the supported link operators aren't sufficient, we can also write PostgreSQL statements in our Marten code. So let's start off by getting a high level overview of querying with Marten.