【问题标题】:Using AttachTo with a Contained EntitySet将 AttachTo 与包含的 EntitySet 一起使用
【发布时间】:2016-11-07 20:40:04
【问题描述】:

我有一些类定义如下:

public class Table
{

    [Key]
    public string Name { get; set; }

    [Contained]
    public IList<TableEntity> Entities { get; set; }
}

public class TableEntity
{
    [Key]
    public string Partition { get; set; }
}

我想使用 AttachTo 将对象添加到 DataServiceContext 而无需先查询它。我怎样才能做到这一点?

【问题讨论】:

    标签: c# odata wcf-data-services asp.net-web-api-odata wcf-data-services-client


    【解决方案1】:

    我能够做到这一点

    context.AttachTo("Tables(\'TableName\')/Entities", tableEntityInstance);
    

    不是很优雅,但很有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-13
      • 2014-04-19
      • 1970-01-01
      • 2016-02-22
      • 2012-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多