首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >getProperty的1.14.12堆栈(EF6)“未定义不是一个函数”

getProperty的1.14.12堆栈(EF6)“未定义不是一个函数”
EN

Stack Overflow用户
提问于 2014-05-26 01:14:44
回答 1查看 360关注 0票数 0

我收到以下错误:“未定义不是updateRelatedEntityInCollection updateRelatedEntityInCollection中的一个函数

当使用微风叠加1.14.12与EF 6.1 / WebApi2。

我有以下实体/地图定义的服务器端:

代码语言:javascript
复制
public partial class Agency
{
    public Agency()
    {
        this.Programs = new HashSet<AgencyProgram>();
        this.Locations = new HashSet<Location>();
        this.Participants = new HashSet<Participant>();
        this.StaffMembers = new HashSet<Staff>();
    }

    public int Id { get; set; }
    public string Name { get; set; }

    public virtual ICollection<AgencyProgram> Programs { get; set; }
    public virtual ICollection<Location> Locations { get; set; }
    public virtual ICollection<Participant> Participants { get; set; }
    public virtual ICollection<Staff> StaffMembers { get; set; }
}

public partial class Staff
{
    public Staff()
    {
        this.CareerClubs = new HashSet<CareerClub>();
        this.ClassFacilitation = new HashSet<ClassFacilitator>();
    }

    public int AgencyId { get; set; }
    public int Id { get; set; }
    public string Name { get; set; }

    public virtual Agency Agency { get; set; }
    public virtual ICollection<CareerClub> CareerClubs { get; set; }
    public virtual ICollection<ClassFacilitator> ClassFacilitation { get; set; }
}

public class StaffMap : EntityTypeConfiguration<Staff>
{
    public StaffMap()
    {
        // Primary Key
        this.HasKey(t => t.Id);

        // Properties
        this.Property(t => t.Name)
            .IsRequired()
            .HasMaxLength(50);

        // Table & Column Mappings
        this.ToTable("Staff");
        this.Property(t => t.AgencyId).HasColumnName("AgencyId");
        this.Property(t => t.Id).HasColumnName("Id");
        this.Property(t => t.Name).HasColumnName("Name");
    }
}

public class AgencyMap : EntityTypeConfiguration<Agency>
{
    public AgencyMap()
    {
        // Primary Key
        this.HasKey(t => t.Id);

        // Properties
        this.Property(t => t.Name)
            .IsRequired()
            .HasMaxLength(50);

        // Table & Column Mappings
        this.ToTable("Agency");
        this.Property(t => t.Id).HasColumnName("Id");
        this.Property(t => t.Name).HasColumnName("Name");
}

当我查询控制器是否有代理时(没有过滤器,只需要

代码语言:javascript
复制
return context.Agencies

我要拿回下面的Json

代码语言:javascript
复制
[{"$id":"1","$type":"System.Data.Entity.DynamicProxies.Agency_09777AD4C70881ED42DD78FB209FCD42C4995B1603097BBFD98C061405E71961, EntityFrameworkDynamicProxies-Model.Persistence","Locations":[],"Participants":[],"Programs":[],"StaffMembers":[{"$id":"2","$type":"System.Data.Entity.DynamicProxies.Staff_B3294F308AC9ED853C9E99FE2B1D765F9433E16FF56372757A43E397DECA38C7, EntityFrameworkDynamicProxies-Model.Persistence","Agency":{"$ref":"1"},"CareerClubs":[],"ClassFacilitation":[],"AgencyId":4,"Id":5,"Name":"Samuel Gonzalez"}],"Id":4,"Name":"Test Agency\r\n"}]

任何时候,Breeze‘type’结果(无论是用toType还是如果我设置元数据映射),都会引发此错误。relatedEntity for updateRelatedEntityInCollection是一个填充的Staff对象,没有简单的道具(没有EntityAspect),inverseProperty associationName是Staff_Agency。

我想无论出于什么原因,Staff对象在从服务器返回后不会得到“轻松化”。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-05-26 23:34:46

动态代理是问题所在。您需要关闭它们,或者使用Breeze的EFContextProvider,它可以正确地配置事物。

微风通过"$type“属性识别实体,当使用代理时,该属性将变得不可识别。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23861496

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档