我有一个类,所有属性都设置为私有:
public class MyClass
{
public int Id {get;private set;}
public int IdChild {get;private set;}
public string SomeProperty {get;private set;}
public virtual Child Child {get;private set;}
}
因此,要修改它们的属性,我必须:(通过示例)
1)调用方法来修改属性:
myclass.SetChild(child);
那么,我如何使用动态代理创建一个实体(我使用EF Code First)?
var myClass = myContext.MyClass.Create();
myClass.Id = 1 // Cannot do that, because this property is "Private Set"
PS:我已经启用了ProxyCreation和LazyLoad!