2
我新的实体框架4.1,和我有非常相同的问题,因为这个家伙: Adding A Custom Property To Entity Framework?访问自定义属性
然而,当我添加自定义一个只读属性,我的实体使用部分类,我无法访问它作为一个属性。
//Auto-generated Entity Class EntityModel.cs
public partial class Model
{
public string foo {get; set;}
public string bar {get; set;}
}
//Custom class EntityModelCustom.cs
public partial class Model
{
public string baz
{
get
{
return string.Format("{0}+{1}", this.foo, this.bar);
}
}
}
在我的代码,当我尝试去获得财产
Model m = new Model();
m.foo和m.bar都可以访问。但我不能访问m.baz这是我想:-(
我在做什么错?
它们都在相同的命名空间 –
它们也必须在同一个程序集中。 –