开发者

Nerd Dinner - how is the return type of the EF queries determined?

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜