4

谁能告诉我如何使用实体框架(代码优先/仅代码)自定义 Ado.Net 数据服务的 OData 提要?

没有 EDMX 文件(因为它只是代码)。

我尝试添加属性:

[EntityPropertyMapping( "Id" , SyndicationItemProperty.Title , SyndicationTextContentKind.Plaintext , true )]

对于我的 POCO 实体类,但提要标题标签中没有显示任何内容?

更新:

如果我使用的是 EDMX 文件,我可以通过应用如下属性来自定义提要:

<EntityType Name="Customer">
  <Property Name="myAddress" Type="MyModelNamespace.Address"
        me:EpmSourcePath="Street"
        m2:FC_Atom="true"
        m2:FC_TargetPath="EpmSyndicationTitle"
        m2:FC_ContentKind="EpmPlaintext"
        m2:FC_KeepContent="true"/>
</EntityType>

但我没有使用 EDMX 文件 - 我使用的是仅代码。我的问题是关于在仅使用代码(无 XML 文件)时实现同样的事情。

谢谢!

4

1 回答 1

0

您是否为实体集设置了访问规则?

作为测试的全部内容,您应该具有以下内容:

public class NorthwindService : DataService<NorthwindEntities>
{
   public static void InitializeService(IDataServiceConfiguration config)
   {
      config.SetEntitySetAccessRule("*", EntitySetRights.All);
    }
}
于 2010-07-02T14:12:13.557 回答