Wednesday 29 September 2010

Getting Started with LINQ to Entities

Introducing the object context, basics queries, eager loading, lazy loading and projection.
In this video, Julie Lerman will show you how to query your database with LINQ to Entities queries against an Entity Data Model. This video uses Entity Framework 4.0 and Visual Studio 2010.


Presented by Julie Lerman.




Context object
var context = new myModel.MyEntities

Basic query
var query = from c in context.Customers select c;
var customers = query.ToList();

Basic filter query
var query = from c in context.Customers where c.customerID==5 select c;
var customer = query.FirstOrDefault();

Eager loading
var query = from c in context.Customers.Include("SalesOrdersHeaders") where c.customerID==5 select c;
var customer = query.FirstOrDefault();

Lazy loading (.NET 4 only)
var query = from c in context.Customers where c.customerID==5 select c;
var customer = query.FirstOrDefault();
lblTest.Text = customer.SalesOrdersHeader.Count

Projection
var query = from c in context.Customers where c.customerID==5
select new { c.CustomerID, c.Firstname, c.Lastname };
Read rest of entry

Tuesday 21 September 2010

Creating an Entity Data Model from a Database

The entity framework is an object-relational mapping (ORM) framework for the .NET Framework. The entity framework separates the conceptual and logical data models, allowing developers to program against the conceptual model rather than the logical model.

This video walks you through the basics of creating an entity data model from an existing database using Entity Framework 4.0 and Visual Studio 2010. You’ll learn to run the Entity Data Model wizard, connect to a database, and select database objects for your model. Once the model has been created, you’ll then learn about the basic features of the model such as the entities, associations and properties.


Presented by Julie Lerman.




Read rest of entry
 

Popular Posts

developer-express Copyright © 2009 Black Nero Blogspot Templatesis Designed by Ipietoon Sponsored by Online Business Journal