c# - 如果您创建一个 DomainService,公开一个实体,您可以访问聚合实体吗?

标签 c# entity-framework-4 wcf-ria-services odata

假设您创建了一个 RIA DomainService 并在其中包含一个 Person(如下所示)实体,您可以访问该对象上的聚合实体吗?

例如,如果我有这样的实体(请记住,这是一种天真的表示,它们是通过 EF4 设计器建模的):

public class Person
{
    string FirstName { get; set; }
    PhoneNumber { get; set; }
}

public class PhoneNumber
{
    public string AreaCode { get; set; }
    public string Trunk { get; set; }
    public string Number { get; set; }
}

如果我在创建 PeopleDomainService 时包含 Person,客户端是否可以访问它上面的 PhoneNumber(并修改它)?

最佳答案

您可以使用 [Include] 属性修饰 Person 对象的 PhoneNumber 属性。还记得在获取 Person 对象时在 LINQ 查询中包含一个 include 语句。

关于c# - 如果您创建一个 DomainService,公开一个实体,您可以访问聚合实体吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4393104/

相关文章:

c# - 将 LINQ 与 NHibernate 结合使用

c# - ASP.NET 数据注释正则表达式 : Don't allow following characters in Name:\,/, :, *, ;,

mysql - 没有为具有复合键的表创建实体类型

c# - ReferentialConstraint 中的依赖属性映射到存储生成的列。列 : 'ID'

c#-3.0 - 检索单一实体+Ria服务

c# - Xamarin.iOS,将字典转换为 NSDictionary

c# - 从 c# 运行 powershell 脚本

c# - 具有包含和可为空值的 Linq 查询

silverlight - 获取 "An entity with the same identity already exists in this EntitySet"但 EntitySet 为空

.net - WCF RIA 服务和 Windows Azure => 实体没有定义 key