views:

25

answers:

1

In Nerd Dinner's Entity Framework repository, the queries' return type corresponds to the model and not to the EF conceptual entity.

public IQueryable<Dinner> FindAllDinners()
{
  return db.Dinners;
}

...

public ObjectSet<Dinner> Dinners // NerdDinner.Designer.cs, line 76

The type of Dinner is NerdDinner.Models.Dinner.

I noticed the namespace for NerdDinner.Designer.cs is the same as the namespace for the model (NerdDinner.Models). I am assuming it pulled this namespace because it's sitting in the Models folder.

Question:

Can someone confirm that the return type of the EF queries is driven by the namespace of the EF config and that the namespace of the EF config is decided by the physical location of the EF files?

What options are available to make this technique work if the namespaces/locations are different and Code First CTP is not an option? Is this specific namespace configurable?

+2  A: 

They are the same type. You may not have noticed that the classes in the Models directory are partial classes, which are composed with the EF classes. Partial classes must be in the same namespace.

Donald
Thank you Donald - that helped me understand what was going on. Nerd Dinner leverages the fact that the generated partial class and the coded partial class are treated as the same type. Since partial classes cannot span multiple assemblies (per http://stackoverflow.com/questions/2263712/c-partial-classes), I'm left to approach this through a different technique.
Mayo