Devexpress GridControl Master-detail with Entity Framework:如何设置

时间:2017-03-09 06:39:35

标签: mvvm entity-framework-6 master-detail gridcontrol devexpress-wpf

我试图在Devexpress masted-detail网格控件中显示来自两个相关实体的数据

stringifyJSON(resarray.push('"' + key + '"' + ':' + stringifyJSON(obj[key])),resarray);

使用Fluen API描述关系:

public class ParentTable
    {
      public int ParentID { get; set; }
      public string ParentData1 { get; set; }
      public string ParentData2 { get; set; }
      public virtual ICollection<ChildTable> ChildDataCollection { get; set; }

    }

public class ChildTable
    {
      public int ChildID { get; set; }
      public int ParentID { get; set; }
      public string ChildData1 { get; set; }
      public string ChildData2 { get; set; }
    }

ParentList是来自ParentTable的数据,ChildList来自ChildDataCollection

Xaml:

   modelBuilder.Entity<ParentTable>()
                .HasKey(e=> e.ParentID)
                .HasMany(e => e.ChildDataCollection)
                .WithRequired()
                .HasForeignKey(e => e.ParentID });

如果我设置DataControlDetailDescriptor Item Source是ChildDataCollection一切正常,但是如果我需要修改这个集合该怎么办(我根据这些数据创建一个列表并希望将它绑定到DataControlDetailDescriptor ItemSource)

我需要ChildList将是详细的ItemSource,我不幸运... emty行:( 我需要这个新的ChildDataList

0 个答案:

没有答案