MikaelEliasson/EntityFramework.Utilities — pull request #9 by MikaelEliasson (2014-01-10 11:44:56+00:00)
Title: 0.4.0 Release

## What's new:

### db.Database.ForceDelete()
Drops the mssql database even if it has connections open. Solves the problem when you are recreating the database in your tests and Management Studio has an open connection that earlier prevented dropping the database.

### IncludeEFU

Relating to my post http://mikee.se/Archive.aspx/Details/entity_framework_pitfalls,_include_20140101 this tries to solve the problem with original Include performance in a developer friendly way.

It will load every Included collection as a separate query instead and then manually fix the relations. The goal is also to provide child collection filtering, sorting and if possible paging.

The goal is to make the API look like this:

```
var result = db.Contacts
.IncludeEFU(c => c.PhoneNumbers)
.IncludeEFU(c => c.Emails)
.Where(c => !c.FirstName.Contains("3"))
.OrderByDescending(c => c.FirstName)
.ToList();
```
It should not matter if you place the Where() and OrderBy() on the root entity before or after the includes.

To filter and sort child collection the goal is to get something like

```
var result = db.Contacts
.IncludeEFU(c => c.PhoneNumbers.Where(p => !p.IsPrivate).OrderBy(p => p.Number))
.ToList();
```

#### Notes
This will be implented by wrapping the QueryProvider. This is done by EFUQueryable and EFUQueryProvider if anyone is interested in the implementation or even better is interested in giving feedback on how to build it better. How this works with other wrappers is a question for another day.

It will run all queries AsNoTracking(), even the root query. Remember this is about performance when loading many entities for ReadOnly scenarios.

It will not work with composite keys in the first iteration unless someone help me add that support.

### Current status

ForceDelete is implemented. Possibly I'm looking at adding a ForceRecreate which drops the DB if it exists and then Creates a new one.

IncludeEFU is implemented in a first version which does not allow child collection filtering and also doesn't include filtering of the loaded child collections based on the filtering of the parent collection. I'm debating if I should load children using an IN clause or rewrite the expression for the root and apply it to the child collections.

I also need to find a way to get the DBContext from the orginal query. Right now the API looks like this

```
var result = db.Contacts
.IncludeEFU(db, c => c.PhoneNumbers)
.ToList();
```
Instead of what I want which is
```
var result = db.Contacts
.IncludeEFU(c => c.PhoneNumbers)
.ToList();
```