0

我的域类上有一个虚拟的 ICollection 属性。如果我离开该属性,则在查询后由微风生成的项目没有 entityaspect 属性。如果我删除虚拟,一切正常。

例子:

这是一个产品 Poco:

public class Product : BaseEntity  
{


    [Required]
    public string Name { get; set; }       

    public decimal Price { get; set; }

    public string Description { get; set; }

      //  if i leave the property like this, everything works fine.

    public  ICollection<Category> Categories { get; set; }

     //if i do something like this, the entities are loaded by breeze, 
       but they  got  no  entity aspect property 

    public virtual  ICollection<Category> Categories { get; set; }



}
4

1 回答 1

0

确保您在DbContext. 您可以执行以下操作:

   this.Configuration.LazyLoadingEnabled = false;
   this.Configuration.ProxyCreationEnabled = false;

或者您可以使用EFContextProvider以下方式访问DbContext

 var contextProvider = new EFContextProvider<MyDbContext>();

 contextProvider.Context //this is the DbContext
于 2014-02-25T00:25:35.133 回答