Vous êtes sur la page 1sur 9

Day 8 VCS2010_08_01 Introduction to SQL Server Stored Procedures In this video we continue our work in SQL Server 2008

8 Express Edition. We start with a brief conversation about the internals of query execution and query plans and how you can use SQL Server Stored Procedures to view and tweak query performance. Stored Procedures are also a mechanism used by DBAs to control access to the underlying table data for certain groups of users. We talk about how some organizations choose to use Stored Procedures to encapsulate business rules that must be implemented across the entire organization (as opposed to using shared C# assemblies for this purpose) since stored procedures sit closest to the data. The fourth benefit is that it will relegate the job of data selection and other CRUD opertaions to the tool originally created for that purposes (SQL). We discuss how Microsoft provides many technologies to architect applications around an organizations preferences as well as their business and technical needs and how there is no one right way to arch. VCS2010_08_02 Basics of Creating, Calling and Managing Stored Procedures As the title suggests we spend twenty minutes on the basics of creating stored procedures including basic syntax, using the built-in templates (in case you cant remember all that syntax off the top of your head). We briefly discuss the BEGIN and END keywords in SQL as what defines code blocks in T-SQL. Next, I demonstrate executing Stored Procedures in a new query window using an ad hoc query. I discuss how to create scripts that ALTER and DROP stored procedures. I spend a few moments talking about scripting your database objects and changes and why that is an important skill namely, to allow the migration of your database from a development to a production environment, tweakability, and source / version control. Finally I discuss naming conventions for Stored Procedures. VCS2010_08_03 Stored Procedure Input Parameters, Output Parameters and Return Values This video expands on the previous video demonstrating the use of input parameters, both creating and executing stored procedures that implement them. Similarly we give the same treatment to output parameters and return values and discuss the proper usage for each. VCS2010_08_04 Understanding the Differences Between SQL Server Express and Compact Editions The Visual Studio Express Editions allow you to create and manage two types of databases a Local and a Service database to add to your project. This video discusses the differences between those two options, which ultimately are using SQL Server 2008 Compact Edition and SQL Server 2008 Express Edition, respectively. Well examine scenarios where each one fits nicely and look at some crossover situations

which are really a judgment call on the part of the developer. We compare storage, access, security, programmability and more and end with some guidelines when to use each type of database in your applications. VCS2010_08_05 Understanding How to Retrieve Data from your Database into your .Net Application Most business-related .NET applications will involve data access in some regard. This video explains at a high level those steps that your .NET application must complete to locate, handshake, request and ultimately retrieve data from a data store regardless of the vendor or product. We also lay out the game plan for the next several videos over the next two days that well take to demonstrate the myriad ways available from Microsoft to access data from a database. VCS2010_08_06 Retrieving Data with ADONET 2 in a Connected Scenario (SQL Server Compact Edition) In an effort to see a progression from ADO.NET 2.0 to 4.0 and the new style of accessing databases and problems it solves, we begin looking at an example of database access using ADO.NET 2.0 in a Connected scenario, using a Data Reader against a SQL Server Compact Edition database. While you are welcome to use the code here within your own applications, be forewarned that the real purpose of this is not to encourage the use of the older API, but rather to highlight the style and show the evolution (which will be demonstrated a few videos after this one). VCS2010_08_07 Retrieving Data with ADONET 2 in a Connected Scenario (featuring SQL Server Express Edition) This video is similar to the previous one, however in this case we use ADO.NET 2.0 in a connected scenario using a DataReader to work against a SQL Server Express Edition database. As a result, we are forced to use a different connection string and command type (actually, well demonstrate two other command types Text and StoredProcedure). Again, the purpose of this video is not to commend this as the one right way to access a database in 2010, but rather to show a progression of thought in data access strategies enabled by Microsoft in ADO.NET 4.0, Entity Framework and LINQ to Entities (all topics that will be covered soon in subsequent videos.) VCS2010_08_08 Managing Data with ADONET 2 in a Disconnected Scenario (featuring SQL Server 2008 Express Edition) In this video we write A LOT of code to demonstrate how to use ADO.NET 2.0 s DataSet and DataAdapters to work in disconnected mode with a SQL Server Express Edition database. We define INSERT, UPDATE, DELETE and SELECT commands for our DataAdapters so that it can work with changes we made to our data while disconnected from the database. We talk about DataSets as in-memory representations of the tables and data in a database. Your application can both work with the data (as if it were

connected directly to it) however also conserve resources with a shared database (including database connections and table locks on the data). Were working our way towards discussing how the latest incarnation of ADO.NET uses techniques like these (an in-memory representation of data, working disconnected, etc.) to present data as strongly typed objects rather than as relational data. VCS2010_08_09 Creating and DataBinding to a Strongly Typed DataSet Finishing up our look at ADO.NET 2.0, in this video we look at creating a strongly typed DataSet using a wizard in Visual C# 2010 Express Edition. We then use that strongly typed version to duplicate the example from the previous video with emphasis on how much less is required AND how much more readable, safe and usable (thanks to Intellisense) it is compared to a not-so-strongly typed DataSet. Then we focus on using a strongly typed DataSet as the basis for a databinding example, using a Windows Form DataGrid to bind to the DataSet. We do write one like of code to save our changes back into the underlying database. VCS2010_08_10 Accessing Data with LINQ to Entities Having demonstrated basic ADO.NET 2.0 scenarios, we now look at two basic ADO.NET 4.0 Entity Framework scenarios (featuring LINQ to Entities) to access data. Much is NOT explained in this video but provides a high level overview of the need that was addressed in EF and contrast it with the ADO.NET 2.0 connected and disconnected approaches. The video demonstrates using LINQ to Entities against a single table, related tables, using LINQ query syntax and method syntax, using the var keyword and more. Also, shows how to create relationships between tables in a Compact Edition database in Visual Studios IDE. VCS2010_08_Homework Day 8 Homework Assignment At the conclusion of Day 8 we have a challenge that involves the creation of parameterized stored procedures, using ADO.NET 2.0 in connected mode to execute those stored procedures, retrieve and display the results to a Console window with a complex menu-ing system. Good luck! (Solution in the next video, as always.) VCS2010_08_Solution Day 8 Homework Solution Get stuck on Day 8 s homework assignment? This video details how to create the stored procedures, the console applications menuing system and finally how to connect to the Express Edition database, create the parameters collection, execute the stored procedure and display the results of that interaction in the console window.

Day 9 VCS2010_09_01 Object and Collection Initializers

In this video we look at a object and collection initializers. They work similarly to an initialized array, where were able to set the properties of a newly created object or multiple instances of new objects in a new collection in essentially one line of code. Well begin by demonstrating object initializers and then show how to use collection initializers In some ways its similar to a constructor that populates the properties of a newly instance of an object. However, unlike a constructor, you can pick and choose which properties to populate in any combination. Well also demonstrate some advanced scenarios like nested initializers and more. VCS2010_09_02 Local Type Inference (var Keyword) This video continues to explain the building blocks of LINQ by introducing the var keyword, also known as Local Type Inference (or rather, implicitly typed local variables). Local Type Inference is an easy way to declare a variable without having to know the type upfront. When we work with LINQ, many times it may not be very clear what a given LINQ query is returning, and in some cases when you start projecting anonymous types there IS no pre-existing type to use! (Ill explain what an anonymous type is later in Day 9). And so the var keyword allows us to say we dont really care what it is, let C# figure it out. Now, Microsoft suggests that you use the var keyword to make development easier. Some authors Ive read insist that you should use it as a temporary measure until you can figure out the exact return type one technique would be to set a break point and use the debugging tools to figure out what the actual type is. VCS2010_09_03 Anonymous Types In this video well look at another language enhancement in C# 3.0 and that is Anonymous Types. Anonymous types are are on the fly classes un-named classes and the key to this is that the compiler infers or figures out what the type definition looks like based on the object initializer. You might wonder why you would need such a thing, but they are used extensively when working with LINQ (i.e.,, when projecting results back from a LINQ query), so we want to get our heads around them before we start looking at LINQ examples. VCS2010_09_04 Extensions Methods In this video well talk about extension methods which are simply methods usually helper methods that can be bolted on to the side of existing types / classes even if that type is sealed, meaning that it cannot be inherited from. Extension Methods also help promote a more fluent style of programming (which well demonstrate and explain in the video.) In the past you may have had some helper methods that are intended for operation on certain types like a formatting method for example. This is similar in concept, but the implementation is cleaner and more elegant. The reason why Extension Methods are important is because this is how LINQs methods, like Select, Where, Sum, Count, are bolted on to the side of types that implement the IEnumerable interface, as well as others. So, Extension Methods are what makes LINQs method

syntax work. VCS2010_09_05 Understanding Delegates Typically, we speak of delegates in the context of events. However, since LINQ theres been a need to understand Delegates in a new context. In the first of a three-part mini series about Lambda Expressions, we use Delegates to explain the first chapter of the Lamda Expression story. Several length, well explained examples highlight how delegates work, what is their purpose, and most importantly, will help us to better understand Anonymous Methods and ultimately Lambda Expressions and their use within LINQ. VCS2010_09_06 Understanding Anonymous Methods In this second in a three-part mini-series about Lambda Expressions we demonstrate how Anonymous Methods can be used to satisfy a delegate input parameter to a method without having to declare a named method that matches the delegates method signature an Anonymous Method is a block of code without a name and can be declared in line and passed into a method as an input parameter. How does this help us? The real payoff for this idea is in the next video when we learn about Lambda Expressions, but Anonymous Methods are another step towards that important language element that is used extensively by the LINQ Method Syntax. VCS2010_09_07 Understanding Lambda Expressions This video is the thrilling conclusion to a three part mini-series that culminates in deciphering what a Lambda Expression is, how it is used in LINQ, and also the Func delegate declaration used by Microsoft in LINQs Method syntax (that you can use, too!) VCS2010_09_08 Introduction to LINQ to Objects In this lecture, Bob explains the benefits and two major styles of LINQ; the Method Syntax and the Query Syntax. Also discussed is the how LINQ is implemented in C#, and how LINQ is used to describe intent allowing the implementation of the given LINQ Provider to take on the responsibility of determining (and executing) the most efficient means of achieving the developers intent. VCS2010_09_09 Examples of LINQ to Objects This video demonstrates a dozen short examples to showcase both the Method Syntax and the Query Syntax to perform simple operations against a small sequence of data in an array of strings. Through this example we get a taste for both syntax and will use this a basis for further exploration throughout the remainder of Day 9. VCS2010_09_10 LINQ Projection

Projection in LINQ is the act of selecting data items from a sequence and shaping them into a new instance of a named type (a .NET Framework type or custom class) OR into an anonymous type. This video demonstrates many different techniques for using the LINQ C# keyword SELECT as a means of projecting your results into new lists of a given type. Even some more advanced projections are demonstrated such as taking an object graph and projecting it into a new XML document in one line of code! We demonstrate both method and query syntax for all examples. VCS2010_09_11 LINQ Where Clause In this video we demonstrate the use of LINQs WHERE clause to filter the data items in a sequence. In addition, we show how to chain WHERE clauses together using the && and || (AND and OR) operators in C#, how to accomplish this using the method syntax and lambda expressions and extension methods, and more. VCS2010_09_12 LINQ From and Join In this video well look at the FROM and JOIN statements in LINQ. Well look at how to retrieve both flattened and hierarchical results, and how to create what we might basically consider both inner and outer joins if this were T-SQL. Well over the following C# keywords: join on equals and into and well cover the following extension methods: SelectMany(), Join() and GroupJoin(). VCS2010_09_13 LINQ Quantifiers In this video weve included pretty much every other linq extension method featuring methods that can help you determine whether there are any items in the sequence at all, or at least, any items that meet a certain criteria, other methods that perform basic operations on the seuqnce that is the sum, the min, the max, the average and so on, methods that find the first or last occurance of an item in the sequence that meets a certain criteria and so on. Well cover: Any(), All(), Contains(), Count(), Sum(), Min(), Max(), Average(), First(), FirstOrDefault(), Last(), LastOrDefault(), Single(), SingleOrDefault() and Aggregate(). VCS2010_09_Exercise Day 9 Exercise This video caps off our jaunt into the land of LINQ. Here you are presented with 9 LINQ challenges and are required to complete each one using the Query Syntax and the Method Syntax. Good luck you will need it! (If you get stuck, theres always the solution videos for each part of this exercise!) VCS2010_09_Solution_MethodSyntax Day 9 Exercise Solution (Featuring LINQ Method Syntax) This video demonstrates the thought process and the solution for each of the nine LINQ challenges for Day 9 using the Method Syntax.

VCS2010_09_Solution_QuerySyntax Day 9 Exercise Solution (Featuring LINQ Query Syntax) This video demonstrates the thought process and the solution for each of the nine LINQ challenges for Day 9 using the Query Syntax.

Day 10 VCS2010_10_01 Using LINQ to Entities to Work with Database Data Kicking off Day 10, Bob discusses the Entity Framework in more depth, looking at the Entity Data Model itself and three three XML sections that comprise it, the Storage (or Physical) Model, the Conceptual Model and the Mapping section. We discussed why this extra layer of abstraction between the database and class model that represents it and discovered how it is this feature that gives the Entity Framework its high degree of flexibility. We discuss the Entity Container and how it derives from ObjectContext to give us access to the Entity Classes it contains, we looked at Lazy Loading and talked about best practices for optimizing LINQ queries, especially those involving related data. VCS2010_10_02 Selecting Data Using LINQ to Entities Part 1 In this video we look at the basics of selecting data using both the LINQ query and method syntax including projecting entire entities, a single property of an entity, and multiple properties of the entity into a new anonymous type. We also look at the Object Services ObjectQuery.ToTraceString() method to peek in and see the SQL that has been created from the LINQ query. VCS2010_10_03 Selecting Data Using LINQ to Entities Part 2 Continuing on the theme of using LINQ to Entities to select entities from the entity model, in this video we demonstrate how to select data from two related entities, how to select into a shaped hierarchy as well as how to flatten the properties of the entities, and how to alias properties and entities in the LINQ syntax. VCS2010_10_04 Selecting Data with LINQ to Entities Part 3 In the third of our LINQ to Entities select mini-series I talk about selecting a single item from a sequence of our entity objects using First and FirstOrDefault extension methods, demonstrating the difference and how to utilize the Default if LINQ query returns an empty sequence. We also briefly look at the order by and where clauses, and look at some shortcuts when working with the FirstOrDefault extension methods, employing an overloaded version that allows us to specify a predicate (where clause). VCS2010_10_05 Inserting Entities Part 1 Basic Syntax and Problems With SQL

Server Compact Edition and Identity Columns Up to this point weve been demonstrating the Entity Framework using a simple SQL Server Compact Edition database with a Customers and Orders table, primary keys that are identity columns, etc. We begin this video with a simple demonstration and explanation of creating a new instance of an entity, populating its properties, calling AddTo__ and then calling SaveChanges. However, we discuss why the code refuses to work with the Compact Edition and some possible remedies. In the next video, well demonstrate the same code we wrote, but using a SQL Server Express Edition version of the database. VCS2010_10_06 Inserting Entities Part 2 Working With SQL Server Express Edition and Inserting Related Entities In this video we pick up where we left off in the previous topic to demonstrate the same entity insertion code, this time with a SQL Server Express Edition database. Bob reminds the student of the gotchas of working with the Express edition and how to see the database changes initiated by our insertion code. He also discusses how the AddTo__ method is deprecated in favor of an ObjectSet syntax in Entity Framework 4.0. Finally, we discuss how to insert related entities and how the Entity Framework is intelligent enough to insert two (or more) records while recording the foreign key value in the related entities. VCS2010_10_07 Updating and Deleting Entities with the Entity Framework This video demonstrates how to update an entity and delete an entity (as well as all related child entities) using the Entity Framework. VCS2010_10_08 Working With Stored Procedures in the Entity Framework Wrapping up our basic Entity Framework and LINQ to Entities coverage, in this video Bob demonstrates how to utilize Stored Procedures in EF4, both simple stored procs as well as stored procs that accept input parameters and output a subset of all possible fields from a table. He also demonstrates how to retrieve data into a collection of existing Entities as well as into a new custom complex type. VCS2010_10_09 String Manipulation: Escape Sequences and String.Format This video begins another three-part mini series on working with String data. In this video Bob demonstrates how to use the forward-slash character to enable escape sequences for otherwise difficult to represent instructions for literal string formatting. He also shows how to format numeric data into highly formatted strings using different string formatting instructions. VCS2010_10_10 String Manipulation: StringBuilder

Bob explains what happens in memory when you concatenate string values and how this could lead to inefficient programming. To solve this potential performance issue, Bob demonstrates the use of the StringBuilder class to append values in a memory efficient manner. VCS2010_10_11 String Manipulation: Built-In String Functions In this third of three parts, Bob demonstrates built-in string functions to manipulate and parse through strings. Topics include Replace, ToUpper, ToLower, Length, Trim and more. VCS2010_10_12 Working with DateTime and TimeSpan In this video, Bob shows how to work with the DateTime class to format a date or time into a properly formatted string, how to create new instances of DateTime for a given date and discusses potential issues when using Parse to create a new DateTime (and prescribes the TryParse method as a safer alternative), how to perform date math, how to use the TimeSpan class to represent the span of time between two dates, and more. VCS2010_10_13 Packaging Code and Referencing Assemblies In this final video for the Core 1 Visual C# 2010 Express Edition video series, Bob explains the thought process behind extracting common code into its own Class Library project and how to reference that new project (the output of which is a .NET Assembly) across two or more projects. As he notes, this is an important building block for future discussions about application architecture, service orientation and more. VCS2010_10_Homework Day 10 Homework For the Day 10 homework assignment youll create a project to enter the date and amount for a given purchase. Your program will then calculate the tax, save the data to a database, retrieve the data and display the results to a Console window. Of course if youre stuck, you can use the solution in the next video to help you out. Good luck! VCS2010_10_Solution Day 10 Homework Solution Get stuck on Day 10 s homework assignment? Never fear! Bob demonstrates step-bystep how to work through and solve the final days homework assignment.

Vous aimerez peut-être aussi