If you are planning to choose Linq to Entities data model for you projects, please read-on.
Linq-Entities (LE) still doesn't have many of the features that are present in LINQ-Sql (LS). The following are the major things which came across during m development.
This article assumes that you are familiar with both.
- LE doesn’t have proper support for Stored Procedures (SP):
LS can import a PS to DBML file or using SqlMetal and can invoke it directly from the context and during import a type is automatically defined for the return data from the SP.
With EF, you cannot invoke the SP on the data context as used to be with LINQ.
You can do it using an extension provided EFExtensions:
http://blogs.msdn.com/meek/archive/2008/03/26/ado-entity-framework-stored-procedure-customization.aspx
But MS doesn’t guarantee that it will be supported in future.
If you import SP using EDMGen.exe, you will be surprised to see that EDMGen has no switch that imports a Stored Procedure mapping to CSDL and MSL. That means you have to manually do the importing to CSDL and MSL files..!
- LS supports Outer Joins, but LE has crippled support for outer joins.
http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/a3f2b146-750b-435c-b48c-2ea301bf130f/
- LS can join with List<T> where are LE can’t do the same.
- LE doesn’t practically support the SQL IN clause:
http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/095745fe-dcf0-4142-b684-b7e4a1ab59f0/
The work arounds are very messy.
5. You can't use the extension methods like Any() in LE, but they work well in LS
Also see this blog:
http://www.kindblad.com/2009/01/11/why-you-should-not-use-the-adonet-entity-framework/
LE is a crippled solution in the sense that LE promotes using the Lambda expression for querying the database entities, but these Lambda expressions doesn’t support many basic SQL operations.
And there is no proper support for Stored Procedures.
LE is projected as a superior solution that LS, but LE doesn’t support many features of LS.
I have no words to express my frustrations..!
Update [06/08/2009]
Found a better solution to do left outer join with EF
http://oddiandeveloper.blogspot.com/2008/12/testable-left-outer-join-in-linq-to.html
You can flatten a left-outer-join as follows:
var v = from en in context.Entity.Include("PostalAddress").Include("PostalAddressType")
let leftouter = (from pa in en.PostalAddress
select new {
PA = pa,
PAT = pa.PostalAddressType
}).FirstOrDefault()
select new {
EntityID = en.EntityID,
PostalAddressID = (Guid?)leftouter.PA.PostalAddressID,
PostalTypeID = (Guid?)leftouter.PAT.PostalAddressTypeID
};