I've been investigating using Microsoft's entity framework for a project at work. I created a simple little data layer solution which has an IDataService interface so I could write a standard ADO.Net implementation and an Entity Framework version using Linq-to-Entity.
I've created two tests which request exactly the same data, but use the different implementations. The queries are simple, they retrieve data from a table, and using hierarchical information generate a DTO with the data in a hierarchy.
The data in the database is along the lines of
------------------------
ID | Description
----|-------------------
1 | Item 1
2 | Item 2
3 | Item 3
4 | Item 4
5 | Item 5
----------------
Parent | Child
-------|--------
1 | 2
1 | 3
3 | 4
1 | 5
Desired Output
--------------
Item 1
|-Item 2
|-Item 3
| |-Item 4
|-Item 5
And so the queries currently take the form of:
from a in tableA
join b in tableB on b.Parent equals a.ID
where b.Parent == root.ID
select new DTO.Entry {
Id = a.ID
...
}
The method containing this query is run recursively until there are no more child elements left to process.
Using Linq-to-entity the test takes about 320ms to complete, using ADO.Net the tests takes about 8ms!
Is this just something I have to live with/consider or should the performance be about on par? Also, as the underlying data structure has no referential integrity (I know!), so I am compensating for this in my ADO.Net stuff, but I can't with Entities, is this likely to have an impact?
At the moment it seems that if you want performance then you should stick with ADO.Net