Subscribe For Free Updates!

We'll not spam mate! We promise.

Mar 20, 2011

Using LINQ to Entities to Work with Database Data

Views:

VIDEOS ARE BELOW IN SEQUENCE 




  • 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.


  • 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 Service’s ObjectQuery.ToTraceString() method to peek in and see the SQL that has been created from the LINQ query.


  • 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.


  • 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).


  • Up to this point we’ve 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, we’ll demonstrate the same code we wrote, but using a SQL Server Express Edition version of the database.


  • 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 gotcha’s 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.


  • This video demonstrates how to update an entity and delete an entity (as well as all related child entities) using 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.


  • 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.


  • 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.


  • 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.


  • 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.


  • 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.


  • For the Day 10 homework assignment you'll 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 you're stuck, you can use the solution in the next video to help you out. Good luck!


  • Get stuck on Day 10's homework assignment? Never fear! Bob demonstrates step-by-step how to work through and solve the final day's homework assignment.





  • Plese Feel Free to Socializer This Post
    SOCIALIZE IT →
    FOLLOW US →
    SHARE IT →

    2 comments:

    1. Looking for the Ultimate Dating Site? Create an account to find your perfect match.

      ReplyDelete
    2. If you need your ex-girlfriend or ex-boyfriend to come crawling back to you on their knees (even if they're dating somebody else now) you need to watch this video
      right away...

      (VIDEO) Get your ex back with TEXT messages?

      ReplyDelete

    Become a Fan

    visual studio learn