How to Do Custom Mapping Using Entity SQL Views

This post was intended to be a reply to this question on the Entity Framework forum, but its size exceeds the forum server limit. Besides, it’s useful in general. So I decided to post it here. In this post you’ll find an entire repro of the subject scenario from the forum.   Create the…


LINQ to Entities: Compiled Queries

Last Friday I blogged about making local variables behave consistently in LINQ to Entities queries. And the solution I recommended was compiled queries. But just today I realized that I haven’t blogged about compiled queries in general yet.     The main purpose of compiled queries to improve performance. While regular LINQ to Entities queries…


Behavior of Variables in LINQ to Entities Queries

LINQ is very nice about referencing local variables without any additional declaration. When I ran my first such LINQ to Entities query, I was ecstatic. The next moment I was puzzled – are the values of those variables picked at compile-time and later used as constants, or are they picked at each execution, so they…


How to Parse an EntityDataReader

2007.12.18: Please accept my apologies – today I discovered (and fixed) two bugs in the parsing code. One is a silly error. The other is that collections should be treated as primitive types and refs with regard to the number of fields. The code bellow includes the changes.   2007.12.04: Last week I discovered that…


XSL Transformation of CSDL into HTML

The attached XSL script neatly renders an Entity Framework CSDL file into HTML.   Below is the NorthwindEF model that we’ve been using for our samples, rendered using that XSL script:   Northwind Entity SetsEntity TypesComplex TypesAssociations Entity Sets Northwind Employees Northwind.Employee Territories Northwind.Territory Regions Northwind.Region Suppliers Northwind.Supplier Products Northwind.Product Categories Northwind.Category Customers Northwind.Customer Orders Northwind.Order OrderDetails Northwind.OrderDetail…


Entity SQL Tip #1

A well defined query against a well defined entity data model does not need JOIN.   Navigation properties in combination with nesting sub-queries should be used instead. These latter constructs represent task requirements much more closely than JOIN does. That makes it easier to build and maintain correct Entity SQL queries.