Programming Entity Framework
Building Data Centric Apps with the ADO.NET Entity Framework
- By
- Julia Lerman
http://apress.com/book/view/1430227036
http://apress.com/book/view/9781590599907
I’ve been using a lot of NoTracking queries to grab lists of data that I don’t need change tracked. One of the interesting behaviors of EF4’s Lazy Loading is that even if you have entities that you have queried with NoTracking on, they will still lazy load related entities.
http://learnentityframework.com/
SELECT VALUE BAModel.Contact(c.ContactID,c.FirstName,c.LastName,c.Title,c.AddDate,c.ModifiedDate)
FROM dbo.Contact as c
WHERE c.AddDate>=”1/1/2007″I was trying to emulate T-SQL here but I need a date, not a string. I thought that without a function I was hosed again, until I discovered Entity SQL’s Literals and rewrote the query successfully this way.
SELECT VALUE BAModel.Contact(c.ContactID,c.FirstName,c.LastName,c.Title,c.AddDate,c.ModifiedDate)
FROM dbo.Contact as c
WHERE c.AddDate>= DATETIME’2007-01-1 00:00′
I’ve had number of emails recently with people using Entity SQL and having problems similar to this, most commonly with decimals & doubles (e.g., 123.24). First I will point you to the MSDN documentation page on Literals for Entity SQL.
this ESQL expression will fail:
select p.amount from BAEntities.Payments as p where p.amount=125.25
The exception message is “The argument types ‘Edm.Decimal’ and ‘Edm.Double’ are incompatible for this operation. Near WHERE predicate, line 1, column 61.”
Entity Framework POCO Template for .NET 3.5
Funky Behavior NoTracking Query Entities
Entity Framework Profiler’s Beta period ends tomorrow when it goes RTM. But that means the 30% discount also ends. It will go from $220US to $315US tomorrow.
I spend a lot of time looking at what’s going on in my database when using EF and the views that EFProf provide are indispensible. It’s organized by context instance and provides links back to the .NET code that executed each command.
- Agile Entity Framework 4 Repository: Part 1- Model and POCO Classes
- Agile Entity Framework 4 Repository: Part 2- The Repository
- Agile EF4 Repository: Part 3 -Fine Tuning the Repository
- Agile EF4 Repository: Part 4: Compiled LINQ Queries
- Agile Entity Framework 4 Repository Part 5: IObjectSet and Include
- Agile Entity Framework 4 Repository: Part 6: Mocks & Unit Tests
Entity Framework Lazy Loading by Context or by Property?
Defining Constraints in an EF4 model that don’t exist in the database
Entity Framework ObjectContext and Reporting
1.
Chapter 1 Introducing the ADO.NET Entity Framework
1.
Programming Against a Model, Not Against the Database
2.
The Entity Data Model: A Client-Side Data Model
3.
The Entity in “Entity Framework”
4.
Choosing Your Backend
5.
Entity Framework Features
6.
The Entity Framework in Web Services
7.
What About ADO.NET DataSets and LINQ to SQL?
8.
Entity Framework Pain Points
9.
Programming the Entity Framework
2.
Chapter 2 Exploring the Entity Data Model
1.
Why Use an Entity Data Model?
2.
The EDM Within the Entity Framework
3.
Your First EDM
4.
The EDM in the Designer Window
5.
Entity Properties
6.
The Naked Model: Inspecting the Model’s XML
7.
A Less Daunting Model View
8.
The Three Parts of the Model
9.
CSDL: The Conceptual Schema
10.
SSDL: The Store Schema
11.
MSL: The Mappings
12.
Database Views in the EDM
13.
Code Generation from EDM to Classes
14.
Summary
3.
Chapter 3 Querying Entity Data Models
1.
Query the Model, Not the Database
2.
Your First EDM Query
3.
LINQ to Entities Queries
4.
Entity SQL Queries That Return Objects
5.
Method-Based Syntax Queries for LINQ and Entity SQL
6.
The Shortest Query
7.
EntityClient: The Lowest-Level Method for Returning Streamed Data Through EDM Queries
8.
Translation to Database Queries
9.
Avoid Inadvertent Query Execution
10.
Summary
4.
Chapter 4 Exploring EDM Queries in Greater Depth
1.
Same Model, Friendlier Name
2.
Projections in Queries
3.
Projections in Entity SQL
4.
Querying Across Associations
5.
Joins and Nested Queries
6.
Grouping
7.
Shaped Data Returned by Queries
8.
Deferred Loading and Eager Loading Queries
9.
Retrieving a Single Entity
10.
Retrieving a Single Entity with GetObjectByKey
11.
Entity SQL’s Wrapped and Unwrapped Results
12.
Summary
5.
Chapter 5 Modifying Entities and Saving Changes
1.
How ObjectContext Manages Entities
2.
The SaveChanges Method
3.
Adding New Entities
4.
Inserting New Parents and Children
5.
Deleting Entities
6.
Summary
6.
Chapter 6 Using Stored Procedures with the EDM
1.
Adding the Stored Procedures into the Model
2.
Working with Functions
3.
Implementing Functions
4.
The EDM Designer’s Model Browser
5.
Mapping the Last of the Four Functions: CustomersbyState
6.
More About the Update Model Wizard
7.
Summary
7.
Chapter 7 Tuning Up a Model
1.
The BreakAway Geek Adventures Business Model
2.
Creating a Class Library Project to Host an EDM
3.
Inspecting and Cleaning Up a New Model
4.
Cleaning Up Navigation Property Names
5.
Mapping a Few Stored Procedures
6.
Working with Many-to-Many Relationships
7.
Building the BreakAwayModel Project
8.
Summary
8.
Chapter 8 Data Binding with Windows Forms and WPF Applications
1.
Data Binding with Windows Forms Applications
2.
Data Binding with WPF Applications
3.
Summary
9.
Chapter 9 Working with Object Services
1.
Where Does Object Services Fit into the Framework?
2.
Query Processing
3.
Object Materialization
4.
The ObjectContext
5.
State Management and ObjectStateEntry
6.
Relationship Management
7.
Sending Changes Back to the Database
8.
Additional Features
9.
Summary
10.
Chapter 10 Customizing Entities
1.
Partial Classes
2.
Customizable Methods
3.
Customizable Event Handlers
4.
Other Opportunities for Customization
5.
Summary
11.
Chapter 11 Using the ASP.NET EntityDataSource Control
1.
Getting to First Base with the EntityDataSource Control and Flat Data
2.
Understanding How the EntityDataSource Is Able to Retrieve and Update Your Data
3.
Working with Related EntityReference Data
4.
Working with Hierarchical Data in a Master/Detail Form
5.
Browsing Through the EntityDataSource Events
6.
Summary
12.
Chapter 12 Customizing Entity Data Models
1.
Designer Support for Mappings
2.
Mapping Table per Type Inheritance for Tables That Describe Derived Types
3.
Using Entity Splitting to Map a Single Entity to More Than One Table
4.
Using Conditional Mapping to Filter Entity Mappings
5.
Implementing Table per Hierarchy Inheritance for Tables That Contain Multiple Types
6.
Implementing Customizations That Are Not Supported by the EDM Designer
7.
Mapping Table per Concrete (TPC) Type Inheritance for Tables with Overlapping Fields
8.
Creating Complex Types to Encapsulate Sets of Properties
9.
Using QueryView to Create Read-Only Entities and Other Specialized Mappings
10.
Additional Customization Options
11.
Summary
13.
Chapter 13 Working with Stored Procedures When Function Mapping Won’t Do
1.
Does the Procedure Line Up with an Entity?
2.
Overview of Procedures, UDFs, and TVFs in the EDM
3.
Composing Queries Against Functions
4.
Mapping and Executing Query Stored Procedures
5.
Adding Native Queries to the Model
6.
Adding Native Views to the Model
7.
Using Commands That Affect the Persisted Database
8.
Defining Insert, Update, and Delete Stored Procedures Directly in the Model
9.
Mapping Insert/Update/Delete to Types Within an Inheritance Structure
10.
Implementing and Querying with User-Defined Functions (UDFs)
11.
Summary
14.
Chapter 14 Using Entities with Web and WCF Services
1.
Building a Client That Is Ignorant of the Entity Framework
2.
Using the Entity Framework with ASMX Web Services
3.
Using the Entity Framework with WCF Services
4.
Summary
15.
Chapter 15 Working with Relationships and Associations
1.
Deconstructing Relationships in the Entity Data Model
2.
Deconstructing Relationships Between Instantiated EntityObjects
3.
Defining Relationships Between Entities
4.
Learning a Few Last Tricks to Make You a Relationship Pro
5.
Summary
16.
Chapter 16 Making It Real: Connections, Transactions, Performance, and More
1.
EntityConnection and Database Connections in the Entity Framework
2.
The Entity Framework and Transactions
3.
The Entity Framework and Security
4.
The Entity Framework and Performance
5.
Entities in Multithreaded Applications
6.
Summary
17.
Chapter 17 Controlling Objects with ObjectStateManager and MetadataWorkspace
1.
Managing ObjectStateEntry Objects with ObjectStateManager
2.
Getting an ObjectStateManager and Its Entries
3.
CurrentValues and OriginalValues
4.
Building the ObjectStateEntry Visualizer
5.
ObjectStateManager and SavingChanges
6.
The MetadataWorkspace API
7.
Creating EntityObjects Without Entity Classes
8.
Creating Entities and Graphs Dynamically
9.
Summary
18.
Chapter 18 Handling Entity Framework Exceptions
1.
Preparing for Exceptions in Entity Framework Code
2.
EntityConnectionString Exceptions
3.
Query Compilation Exceptions
4.
Creating a Common Wrapper to Handle Query Execution Exceptions
5.
SaveChanges Command Execution Exceptions
6.
ObjectStateEntries Returned by Object Services Exceptions
7.
InvalidOperationExceptions
8.
Exceptions When Multiple Parties Edit Data Concurrently
9.
Understanding Optimistic Concurrency Options in the Entity Framework
10.
Implementing Optimistic Concurrency with the Entity Framework
11.
Handling OptimisticConcurrencyExceptions
12.
Handling Concurrency Exceptions at a Lower Level
13.
Handling Exceptions When Transactions Are Your Own
14.
Summary
19.
Chapter 19 Using Your Own Custom Classes
1.
Mapping Classes to the Entity Data Model
2.
Implementing the IPOCO Interfaces
3.
Custom Class Assemblies and Entity Data Model Files
4.
Summary
20.
Chapter 20 Using the Entity Framework in n-Tier Client-Side Applications
1.
Thinking in Layers
2.
Finding Your Motivation: A Master/Detail Data Entry Form That Will Use the DataBridge Class
3.
Preventing Non-UI Logic from Leaking into the UI
4.
Implementing Logic That Fits Best in the Entity Partial Classes
5.
Building the CommandExecutor Class
6.
Building the DataBridge Class
7.
Using the DataBridge Class for Data Binding in a Master/Detail Form
8.
Allowing Users to Roll Back Their Edits
9.
Helping the User Who Forgets to Save Changes
10.
Summary
21.
Chapter 21 Using the Entity Framework in n-Tier ASP.NET Applications
1.
Understanding How an ObjectContext Fits into the Web Page Life Cycle
2.
Introducing ASP.NET’s ObjectDataSource Control
3.
Designing Object Provider Classes to Be Used with an ObjectDataSource
4.
Wiring Up the Provider Classes to ObjectDataSource Controls
5.
Understanding Why We Didn’t Use Object Graphs in This Business Layer
6.
Summary
22.
Chapter 22 Implementing a Smarter WCF Service for Working with Entities
1.
Will Your Client Agree to Your Data Contract?
2.
Shipping DTOs, Not EntityObjects
3.
Creating EntityState Properties That Do Not Rely on ObjectContext
4.
Designing the Service Interface
5.
Implementing the Service Operations
6.
Implementing the Client That Will Use the WCF Service
7.
Testing It All with a Simple Console Application
8.
Summary
23.
Chapter 23 The Entity Framework, Today and Tomorrow
1.
What About Building Reports with the Entity Framework?
2.
Extensions, Samples, and Solutions from Microsoft
3.
Entity Framework v.Next
4.
Blogs, Forums, and Other Resources
1.
Appendix Entity Framework Assemblies and Namespaces
1.
Unpacking the Entity Framework Files
2.
Exploring the Namespaces
- MSDN Data Access and Storage Developer Center
- MSDN Library: Entity Framework Documentation
- MS ADO.NET Team Blog
- MS Data Access Team Blog
- Entity Framework FAQ by Danny Simmons
- MSDN Entity Framework Forums
- Code Gallery Home Page for Entity Framework Team
(ADO.NET Entity Framework projects, samples, toolkits, extensions and Learning Tools created by Entity Framework Team) - CodePlex EFContrib
A project for contributing EF Source Code - Sample Databases from Microsoft
- “How Do I” Videos from E.F. Team
- 101 C# LINQ Samples (on MSDN)
- My Entity Framework Articles
Introducing ADO.NET Entity Framework CoDe Magazine Nov/Dec 2007
Data Access Options in Visual Studio 2008 CoDe Magazine Sept/Oct 2008
ADO.NET Entity Framework Overview SDN Magazine May 2009
8 Entity Framework Gotchas CoDe Magazine July/August 2009
Filed under: .NET, Blogs, Code, Database, Design, Products, Reference Tagged: .NET, ADO.NET, Books, DAO, Data, DTO, EF4, Entity, Entity Frameworks, Linq, ODBC, Oracle, SQL
Written by Visitor Blogs on May 20th, 2010 with no comments.
Read more articles on Entity and EF4 and ADO.NET and reference and Data and ODBC and Entity Frameworks and DTO and DAO and LINQ and books and .Net and Blogs and Code and SQL and Oracle and otherSoftware and Database and Design and Products.




