Start with 7 free days of training.

Gain instant access to our entire IT training library, free for your first week.
Train anytime on your desktop, tablet, or mobile devices.

Training in current data accessing technologies.

This Microsoft video training with Garth Schulte covers data access programming, including working with ADO.NET, XML technologies, and more....
This Microsoft video training with Garth Schulte covers data access programming, including working with ADO.NET, XML technologies, and more.

Related area of expertise:
  • Programming level 2

Recommended skills:
  • Experience using Microsoft Visual Studio
  • Experience using ADO.NET 4
  • 2 to 3 years of developing application concepts
  • Familiarity with relational database concepts
  • 1 to 2 years of using a relational database management system
  • Familiarity with ADO.NET 4 coding techniques and framework components, ADO.NET Data Services LINQ, LINQ to SQL, Entity Framework technologies, Structured Query Language (SQL), stored procedures, and Database Structures/Schemas (Objects) XML

Recommended equipment:
  • Microsoft Visual Studio 2010

Related certifications:
  • MCTS: .NET Framework 4, Data Access
  • MCPD: Windows Developer 4
  • MCPD: Web Developer 4

Related job functions:
  • Software developers
  • IT professionals

Data access programming skills are a must for software developers these days and this course shows you how to use all of the current data access technologies while preparing you for the 70-516 exam.

Trainer Garth Schulte shows you how to work with technologies such as ADO.NET, LINQ to SQL, WCF, and the Entity Framework - just to name a few. This CBT Nuggets course will provide you with the skills and knowledge you need to create data access solutions and turn that blank canvas into a mosaic of interactive data!
 show less
1. Introduction to Accessing Data with .NET 4 (24 min)
2. Overview of ADO.NET (46 min)
3. Working with ADO.NET - Disconnected Data (29 min)
4. Working with ADO.NET - Connected Data (39 min)
5. Introduction to LINQ (32 min)
6. Writing LINQ Queries (32 min)
7. LINQ to SQL Introduction (31 min)
8. Working with LINQ to SQL (33 min)
9. LINQ to XML Introduction (24 min)
10. Working with LINQ to XML (26 min)
11. Introduction to the ADO.NET Entity Framework (38 min)
12. Working with the ADO.NET Entity Framework (46 min)
13. Introduction to WCF Data Services (23 min)
14. Consuming WCF Data Services (23 min)
15. Developing Reliable Applications - Troubleshooting Data (25 min)
16. Developing Reliable Applications - Protecting Data (42 min)
17. Developing Reliable Applications - Synchronizing Data (26 min)
18. Deploying Applications & Components (25 min)

Introduction to Accessing Data with .NET 4


Introduction to Accessing Data with .NET 4. Hello and welcome, everybody. We're going to kick the series off here with just a preview of all the things we're going to cover in the series and all things that we're going to be required to cover for the 70-516 exam.


All right, so let's jump right into it here. I want to start off with a brief look at our outline. The first thing we're going to do is talk about data access in general. So we'll just kind of get a briefing of what data access is. We'll step back and take a look at the entire picture of where data access sits within an application architecture.


So that's where we'll start off here, a little bit of a data access overview. We'll then move into the exam overview. And I just want to cover all the different areas that the exam requires and the areas you feel comfortable with before attempting to take the exam.


So we'll look at what Microsoft expects of us. At the end here, we'll take a look at the Nuggets overview, look at all the Nuggets contained within this series and just a general overview of how they're separated and how they're grouped together. So it will make it easier if you ever need to find a spot that you're-- maybe you have a weak point in that you want to practice up on.


You have a reference point here in this Nugget. All right, so let's jump right into a data access overview here and just talk about all the technology we're going to be learning about and all the technologies we should understand as .NET 4 developers for developing our data access strategy.


All right, so here are all the technologies. We're going to talk about each one of these and how they fit into the big picture. And what I have in the middle here is sort of your standard three tier architecture. So I just want to give you a brief, again, kind, of a bird's eye view here of an applications architecture, so we can see where the data access layers fit and these technologies that we're going to be using fit.


All right, let's start at the top here with the presentation layer. This layer is just simple user interface. So we can use technologies, such as if building a web application, we're going to have a collection of web forms. If you're building a Windows application, you're going to have a collection of WinForms.


You can also use the latest and greatest WPF technology, Windows Presentation Foundation, which can do both. You can have a WPF Windows app or a WPF web application, just the latest technology, a little easier to do things like data binding and laying out and things of that nature.


So that's the presentation layer. It's just simply our user interface. Presentation layer communicates with the conceptual error, otherwise known as the business layer. And this just contains all of our domain models, which is really just a digital form of our business models and our business practices in the real world.


So that's all that is. It's just going to be a bunch of interrelated classes that we're going to compile into one or many DLLs that are going to contain all of our business models. So the conceptual layer communicates with the data layer, which is where we're going to be spending most of our time here in between the conceptual and data layer.


The data layer's job is to take data from the conceptual layer or pass data to a conceptual layer, from which it gets from the database. So there's a lot of plumbing work in here and a lot of grunt work. And that's where the new data access strategies come into play.


So we're going to try to hide a lot of that grunt work from us by really abstracting it us from rates. We'll talk about that shortly. So that's really our layered architecture. And of course, communication goes back this way as well. And that's it. There's your three tier architecture.


Now one more thing on architecture here. The whole point of creating this layered architecture, it's for usability and for code separation. It'll make it easier to program again, so on and so forth. But really, the goal is-- and you can see Microsoft really heading this direction-- is to loosely couple our layers together.


So none of these layers truly depend on each other. Of course, the presentation layer will have to tap into the conceptual, which has to tap into the data layer, which has to, of course, get things from the physical database layer. But the whole point is if they are loosely coupled, we can strip one of these layers out and reuse it in another application, tap into it.


So really how it works is the bottom layer should not be aware of the top layer. Anything underneath should be able to be used by anything above. So that's the whole goal of these layered architectures, whether it's three tier or n tier. That's a good design goal and what everybody really strives for.


And you can see especially, as I mentioned here, Microsoft is striving for that with the latest data access technologies, because you're going to see that in action here when we get and talk about the Entity Framework and LINQ to SQL. All right, let's get familiar with some of these technologies here.


Now all these data access technologies again are in .NET 4. We'll start with the one that's been around forever, since the beginning of .NET is ADO.NET. Again, been around since the .NET framework has been around. And it's really the standard way to write data access applications these days and write your data access layer.


If you're in .NET and you're doing data access, then you're probably using ADO.NET, because the reason it's so popular is because it's easy to use. It's extensible. It's flexible. It's all those fancy buzzwords and then some. And really all ADO.NET is is a collection of classes that contain things like a connection class for connecting to a database, command classes for sending commands to databases, dataset class which contains data tables and data relations.


So really it's just the physical database brought over in memory so we can work with it locally within the application. And ADO.NET sits right down here inside of a data layer, of course. And this is where, again, it's grunt work doing all this plumbing, but it's necessary grunt work if, of course, we're going to communicate and create a database application.


One question I get asked quite a bit these days is, is ADO.NET becoming obsolete with these new technologies, LINQ to SQL and the Entity Framework coming out? And the short answer is, no, definitely not. The long answer is that it ADO.NET is extensively used within these technologies.


It's just we may not be using it as much directly because it's becoming abstracted from us. And it's going to all happen under the hood. But you can see the Entity Framework is actually called the ADO.NET Entity Framework. So it's built right on top of ADO.NET.


So it's still crucial to understand everything that ADO.NET has to offer. It'll help us in the long run and help us understand these new technologies a little better as well. Now moving on to LINQ to SQL here, first, let's just focus on this whole LINQ thing.


What is LINQ? Well, LINQ stands for Language Integrated Query. And what it is it's Microsoft's attempt at creating a standardized language to query data. And the key here is not just data that relies on a database, but data as in collections of our variables within our applications, data that sits on our hard drive, data that sits inside of a database, data that is essentially anywhere, that is what Microsoft's attempt at LINQ is trying to do is give us a simple, fast, and safe method for accessing all this data.


Even though I physical database here via the conceptual model, that's what LINQ to SQL is. But LINQ by itself is really what we mean by safe here is that it's type safe, meaning IntelliSense. Any time you hit object dot and that list comes up of all your properties and methods, that's IntelliSense.


And that's type safety because we were not referencing our objects via strings. And I'll give you great examples of this coming up, because we're going to take a look at how to do things the old way, or the non-safe way as we call it, and then the type safe way.


So LINQ by itself it just gives us a standardized way of accessing data, whether that data is stored locally in our application inside of a collection, or if it's stored in a database, or if it's stored in an XML file. And that's where these "to" come.


You're going to see LINQ to SQL, LINQ to objects, LINQ to XML. And those are all just dialects of LINQ that allow us to hit that specific technology. So LINQ to SQL is what we're really going to be focusing on here since we're in the data access layer.


And really want LINQ to SQL is it's considered an ORM, an Object Relational Mapper. And that's also what the Entity Framework is. These are both ORM tools. And what that basically means is we're mapping our conceptual layer to our data layer. And so what we do there is we'll just simply-- instead of writing all this code in the data layer, we're going to call and query our objects, which will then automatically go to the data layer, which will go to the database.


So you can see this is where the whole abstraction is coming in. These technologies are really going to help us get out of the data layer. We'll get out of building and writing all this code in the data layer. We'll set it up. We'll be done with it. And then we'll tap into our conceptual error, which will do all the heavy lifting for us to grabbing the data.


Now the ADO.NET Entity Framework is also an ORM, as I mentioned, Object Relational Mapper. And again all an ORM allows us to do is take our physical database schema, our structure, and map it to our conceptual layer. So the output from our LINQ to SQL designers and our Entity Framework designer are going to be essentially mapping files, mapping files that explain how the source, our data sources, match up to our conceptual layer.


And all that's going to be handled for us really. Once we set those up, we're just going to really work with our conceptual layer, our data models here, to handle all the saving and sending data back and forth to our application. So the Entity Framework handles all that stuff.


LINQ to SQL handles all that stuff. And one of the big questions I see when people are learning these technologies is, well, if they're both ORMs, isn't that kind of redundant? Why do I need one of the other? And you know, the quick answer to that is absolutely they are semi-redundant because they both accomplish the same thing.


But the difference-- the devil's in the details as they say-- in LINQ to SQL is really the rapid application version of the Entity Framework that allows us to do things very quick. I mean you'd be really surprised how fast you can get a LINQ to SQL data layer set up and working through your conceptual layer.


In fact, I'll show you when we get to there and we start working with LINQ to SQL. It's quick. It's easy. And I can see why it's all the rage these days, because it's really wonderful to work with. But some of the things that it lacks here is it lacks the robustness of Entity Framework.


You can only do one-to-one mappings between your conceptual and your data layer. And what that means is one class to one table. Now, of course, we can get around that by mapping to stored procedures and things of that nature. But generally speaking, one-to-one mappings.


And also, LINQ to SQL only supports, at least in the initial release here in Visual Studio, SQL Server databases. Now there are third party vendors out there extending it. So it can support things such as MySQL, PostgreSQL, Oracle, things nature. So don't shy away if you don't have a SQL Server.


Look on the internet, because things are coming out daily these days. LINQ is definitely a very popular. It's not going anywhere. And the Entity Framework supports pretty much anything that any OLE DB provider supports now. So any time you create a connection now, if you can create connection to pretty much anything out there, the Entity Framework can handle it as well.


And it supports complex data structures. So really your decision to use LINQ to SQL over the Entity Framework is going to be how complex your data structure is, because I've seen people build massive enterprise-wide applications based on LINQ to SQL.


They chose LINQ to SQL because it's fast. It's easy to use and easy to support. The Entity Framework is easy to use. But it's beastly. And there's a lot of big things to learn about it. But that's because it does support all of the complex features. So really, it's going to, again, come down to your physical database, how complex it is, and what your application requires.


So these two technologies really sit in the middle. They sit in our data layer and are conceptual layer because they essentially write our data layer for us and then they fill up our conceptual layer for us. So a little overlap there and one could argue that they kind of sit in the middle between the data and the conceptual layer.


Now let's move on to WCF Data Services. And this used to be called ADO.NET Data Services. And they changed it to WCF Data Services, Windows Communication Foundation, because it really supports a lot more now. Anytime we need to access data remotely, it's not just web services anymore, we can access our file system remotely now if we wanted to.


We could pull that data out of the file system and get reports on our file system or anything on the local computer that we can hook into. So not only can we build web services, we can expose our conceptual layer. We can expose any data really. And that's what this the goal of the Windows Communication Foundation, WCF, is to allow us to take data that's in one area and expose it over the internet.


So our applications that aren't housed within the network, or any third party applications or vendor applications that would like to tap into our data, we can give them access remotely over a web server and through HTTP. So really WCF Data Services could take this three tier architecture and turn it into an n tier architecture because we could add another layer in here that other applications could tap into our applications that our remote customers could tap into and so forth.


So if we add another layer in here in, WCF Data Services would go right here, through a cloud, and right in, and we can hook it right into our conceptual layer as well here. So that's WCF Data Services. We'll take a good look at that. And finally, here we have Microsoft Sync Services.


And Microsoft Sync Services is way to hook up offline applications. You know, let's say you have remote sales users out there that they don't have internet access 24/7, or maybe they only have it a very short period of time. Sync Services allows them to work on their laptop or whatever mobile device they have all day long in their database applications, as if they were online.


So it would queue up other changes, manage all their changes. And then when they connected to the internet, Microsoft Sync Services would take over and sync the source and the destination all up for us. So this would look like this. We'd have here. We'd have a little disconnection, lightning bolt here.


And then this would connect into our data source. So this could be yet another part of our application, another tier in our application if you will. And this could even hook into our conceptual layer up here if we wanted to do validation on this data to make sure that, you know, everything the salesperson was typing was accurate and conforms to our standards that our conceptual layer was built to validate against.


So these are all the technologies we're going to need to be proficient with in order to become good data access programmers and .NET 4, and also, of course, if we want to pass exams. So speaking of the exam, let me take you in. I want to show you what Microsoft is going to expect from us as far as a 7--516 exam goes.


So let's fire up Internet Explorer. Head over to Google. And type in 70-516 and hit Enter. Here we go. The first result that comes up is Microsoft's page here on the exam. And here it is, Accessing Data with Microsoft .NET Framework 4. Here's a quick overview on it, all the technologies that we're going to get familiar with.


Skills Measured is what we want to talk about because this is all the things on the exam, the makeup of the exam based on a percentage here. 20% of the exam is going to be modeling data. And this is kind of what we're talking about with our ORM tools, LINQ to SQL and the Entity framework, because the very first two objectives on here-- check it out-- map entities and relationships by using the Entity Data Model.


This is the Entity Framework's resulting output, as I mentioned, which is an EDMX file. So we'll talk about creating those mapping files. We'll also then move into LINQ to SQL and talk about their mapping files, DBML mapping files. Create and customize Entity objects, we'll talk about how to do that.


And we'll also talk about how to connect to POCO model to the Entity Framework. What's a POCO model. POCO stands for Plain Old CLR Objects. And what this means is say you've had an application. You created your conceptual model years ago. You use it in many applications within your organization.


Why change it? We don't need to create a new one, right? We just want to hook up our old one using the Entity Framework to the database so we can essentially redo our data access layer to make it a lot easier. And that's POCO is all about. And we're going to take a look at how to do that.


Create a database from an Entity Framework model. And this is kind of neat in the fact that we can auto create a database based on our conceptual layer. So We'll take a look at how to do that. And also, vice versa, we can create a conceptual layer based on a database layer in Entity Framework that's hooked up to a database.


We'll take a good look at that. We'll look at model defined functions. So that's 20% of it is modeling data, pretty much using the Entity Framework or LINQ to SQL. Moving on here, 18% of the exam is going to be covering connections and contexts. In connections here, we're going to start with how to configure a connection string and hook up to the data provider of our choice.


We'll take a look at how to manage that connection, how to actually use that connection by opening it, and closing it, managing the lifecycle of it, so on and so forth. We'll look at securing a connection. So if we need to secure everything from the actual data that we're communicating with all the way to the actual connection string stored in the configuration file, we'll take a look at how to secure it.


We'll look at managing the data context and object context. A couple more points here, these are LINQ to SQL and Entity Frameworks ways-- you can think of it really as the connection. So where in ADO.NET we have a physical connection object, well, with LINQ to SQL and Entity Framework, depending which one we're using, we'll have a data context or an object context.


So think of these as our connections. So we'll take a good look at how to work with and use the data context and the object context when we're working with the Entity Framework or LINQ to SQL. We'll look at loading mechanisms from eager loading to lazy loading to explicit loading.


And all this, again, has to do with the Entity Framework and LINQ to SQL. We'll look at how to cache data. We'll look at how to configure-- and this should say WCF.NET Data Services. Microsoft forgot to update their own terminology here. But we'll look at how to configure WCF.NET Data Services.


And then we'll look you're here at 22% of the exam is querying data. We'll take a good look at sending queries over through the wire to pull back the data we want, send our updates over. We'll look at everything from executing a SQL query through ADO.NET here.


And we'll also take a look at creating a LINQ query. We'll look at creating an Entity SQL query. So all the different query mechanisms to go everything from our Entity Framework to ADO.NET to LINQ to SQL, all the different ways of accessing data within each of those technologies.


We'll look at how to handle special data types and complex data. We'll look at how to query XML using LINQ to XML. And we'll also use other technologies too, like the XmlReader, XmlDocuments. We'll take a look at XPath, things of that nature. We used to pull data out of XML files and XML data.


And then we'll take a look at how to query data using-- and here they have a right-- WCF.NET Data Services. And then we'll also look at manipulating data, creating, updating, or delete our standard CRUD statements here-- create, read, update, delete-- by using SQL statements.


We'll do the same thing by using the data context, by using the object context. So again, just each technology's own version, so to speak, of manipulating data from querying data, we'll look at them all. We'll take a look at transactions, how to manage transactions to keep all of our units working together and all of our processes.


And then we'll take a look how to work with disconnected objects. And then, finally here, we'll look at developing and deploying reliable applications. So we'll look at everything from monitoring and collecting performance data within our applications, to handling exceptions, to protecting encrypting data, to synchronizing data-- we use those Microsoft Sync Services we talked about-- and finally, how to deploy our application and our components.


So this is what Microsoft expects of us. And it's really not that bad. I mean, most of it's going to revolve around setting up and modeling our data, managing our connections, and querying our data. Those are going to be the big ones. And also manipulating data.


So it really all has to do with these three technologies that we're actually-- technically, four big technologies-- that' we're going to look. And it's going to be ADO.NET, LINQ to SQL, the Entity Framework, and then WCF Data Services. But again, the majority of this is really going to be going LINQ to SQL and the Entity Framework and ADO.Net, which all have a lot of overlap.


So once you kind of understand the concepts, really it's just learning those specific versions of those concepts. So whether you're working with an ADO.NET connection, whether we're working with the Entity Framework's data context or the LINQ to SQL object context, they're really all the same thing, just different flavors of them.


So that should make it a little less daunting for you. All right, let's jump right in to the last thing I want to show you here, which is the overview of our Nuggets and how they tie into the exam pack that Microsoft expects us to learn. So where we're at right now is an Introduction to Accessing Data with .NET 4.


This one's kind of all by itself here. We'll call this a foundational video, because really what we're doing is just taking a brief overview of everything this series is going to cover and then just a brief overview of data access in general as well is what we did earlier here.


Then we'll take a look at ADO.NET, three videos here on ADO.NET. We'll first get familiar with ADO.NET by looking at the conceptual model that is ADO.NET. We'll look at all the different classes that we need to understand and get familiar with. And then we'll jump right into the disconnected world and do things like work with ADO.NET locally and save the data in a local file, maybe an XML file or a binary .NET, .DAT file.


So we'll look at everything without a connection that we can do with ADO.NET. Then we'll look at everything we can do while connected to a database. So we'll work with a physical database here, create some demos, and talk about how to work with databases using ADO.NET.


So we'll get familiar with all the grunt work I was talking about earlier. Next here, we're going to have a huge look at LINQ. So we'll take a big look at everything LINQ here. We'll start with an introduction to LINQ. I'll get you familiar with what LINQ is.


We'll look at some syntax and just a general overview of all the different flavors of LINQ as well. We'll then look at writing LINQ queries, get you familiar with some syntax. We'll work with LINQ to objects here and learn how to query collections within an application and just really get familiar with how to write these LINQ queries, because then we're going to move to LINQ to SQL.


We'll get this flavor of LINQ and how to work with SQL Server databases. We'll first take an introduction to it. Then we'll learn how to actually do it by building a LINQ to SQL application. Then we'll do the same thing with XML. LINQ to XML, another flavor, we'll look at how to work with XML data using LINQ and other XML technologies.


And then we'll learn how to write a LINQ to XML application. Then we'll move in, and we'll take a look at it couple of Nuggets here on the Entity Framework. So these Nuggets are going to consist of first taking an introduction to the Entity Framework.


We'll just look at all the different features that it supports, all the things that we can do with it. And then we'll jump right into a big demo here. And we'll learn how to create a database from a conceptual model. We'll learn how to create a conceptual model from a database.


And we'll also talk about hooking up our POCO objects to an Entity Framework. So all the things that we can possibly do and then some there. Then we'll take a look at a couple of Nuggets here on WCF, Windows Communication Foundation, again. , First we'll take an introduction, see all the different data points that we can expose through these services, all the things we can do with it.


And then we'll take another good look here, a good demo, on how to work with and consume these data services and pull that data remotely into a local application. So you can see, I like doing things through demos here. Demos are the best way to learn in my opinion.


So that's why I like to kind of do an intro, follow it up with a demo. And that'll give us the best of both worlds. Finally here, we got four Nuggets. The last four Nuggets are going to all work with how to develop a reliable application. So really just general application development theory here.


First, troubleshooting data. And, of course, troubleshooting data access applications are a little more complicated than just troubleshooting a standard application, because it's deep down there in our layers. We've got layers all over the place when we're dealing with data access apps.


So we're going to dig down deep into layer and find good ways to troubleshoot, because, of course, debugging is never fun and sometimes can be frustrating. So we'll take some good points here on how to troubleshoot and make sure we trap our exceptions to give us the most out of those errors.


Then we'll look at protecting data. We'll look at how to encrypt our data, took a good look at that, a whole video dedicated to protecting there our information there. We'll take a look at how to synchronize data for those offline applications. We'll look at Microsoft's Sync Services there.


And then finally here, we'll take a look at how to deploy our apps in our components. So in this CBT Nugget, we took a look at an introduction to accessing data with .NET 4. We started off here with a data access overview. I just wanted to get your feet wet here with some terminology and just give you a brief overview here of all the different technologies that we're going to need to understand in order to not only become good, proficient data access programmers, but also, of course, what Microsoft's going to expect from us as far as the exam goes.


And that's what we took a look at next. We took a look at what Microsoft is going to expect from us as far as the exam goes, the 70-516 exam. And we saw that most of it is going to revolve around modeling, querying, and managing our data. Then again here, I just took you through all the different Nuggets inside of this series and just briefly talked about how they're separated out.


And we saw we're pretty much going to talk about ADO.NET, the Entity Framework, LINQ to SQL, and then developing reliable applications. I hope this has been informative for you. And I'd like to thank you for viewing.

Overview of ADO.NET

Working with ADO.NET - Disconnected Data

Working with ADO.NET - Connected Data

Introduction to LINQ

Writing LINQ Queries

LINQ to SQL Introduction

Working with LINQ to SQL

LINQ to XML Introduction

Working with LINQ to XML

Introduction to the ADO.NET Entity Framework

Working with the ADO.NET Entity Framework

Introduction to WCF Data Services

Consuming WCF Data Services

Developing Reliable Applications - Troubleshooting Data

Developing Reliable Applications - Protecting Data

Developing Reliable Applications - Synchronizing Data

Deploying Applications & Components

Please help us improve by sharing your feedback on training courses and videos. For customer service questions, please contact our support team. The views expressed in comments reflect those of the author and not of CBT Nuggets. We reserve the right to remove comments that do not adhere to our community standards.

comments powered by Disqus
Intermediate 10 hrs 18 videos


Training Features

Practice Exams
These practice tests help you review your knowledge and prepare you for exams.

Virtual Lab
Use a virtual environment to reinforce what you are learning and get hands-on experience.

Offline Training
Our iOS and Android mobile apps offer the ability to download videos and train anytime, anywhere offline.

Accountability Coaching
Develop and maintain a study plan with one-to-one assistance from coaches.

Supplemental Files
Files/materials that supplement the video training.

Speed Control
Play videos at a faster or slower pace.

Included in this course
Pick up where you left off watching a video.

Included in this course
Jot down information to refer back to at a later time.

Closed Captions
Follow what the trainers are saying with ease.
Garth Schulte
Nugget trainer since 2002