我有两个表Menu和GroupMenu。我需要在Odata中编写子查询。我可以在SQL中获得结果,例如
select * from [Menu] where id in (select MenuId from GroupMenu where GroupId = 2)
下面的的结果
以下是我班级的结构
[Serializable]
public class GroupMenu
{
[Key]
public int Id { get; set; }
public int GroupId { get; set; }
[ForeignKey("GroupId")]
public virtual Group Group { get; set; }
public int MenuId { get; set; }
[ForeignKey("MenuId")]
public virtual Menu Menu { get; set; }
public DateTime ModifiedDate { get; set; }
}
[Serializable]
public class Group
{
[Key]
public int Id { get; set; }
[MaxLength(80)]
[Required]
public string Name { get; set; }
public bool IsActive { get; set; }
public DateTime ModifiedOn { get; set; }
public Guid ModifiedBy { get; set; }
}
答案 0 :(得分:1)
你可以发布你的edmx($元数据)吗? "子查询"必须通过导航属性。 类似的东西:
test_1 test_2 hd_count
2013-12-20 10:40:30 2013-12-20 10:44:30 8
-it为您提供包含菜单的GroupMenu