Jam*_*der 8 azure azure-storage wcf-data-services azure-table-storage
我最近将Microsoft.WindowsAzure.Storage的nuget包更新为3.0包,其中还包括对WCF数据服务客户端及其依赖项的更新.由于更新,我在查询解决时收到错误:
"客户端和服务之间存在类型不匹配.类型'ShiftDigital.Flow.Data.RouteDiagnostic'不是实体类型,但响应有效负载中的类型表示实体类型.请确保客户端上定义的类型匹配服务的数据模型,或更新客户端上的服务引用."
我什么也没做,只是更新了软件包,我的应用程序和我在LinqPad中设置的测试脚本生成了这个异常.
这是我在更新之前返回的实体的定义
public class RouteDiagnostic : TableEntity
{
public long? LeadRecipientRouteId { get; set; }
public bool Successful { get; set; }
public int Duration { get; set; }
public string Request { get; set; }
public string Response { get; set; }
public RouteDiagnostic()
: base()
{
this.Timestamp = DateTimeOffset.Now;
this.PartitionKey = GetPartitionKey(this.Timestamp.Date);
this.RowKey = Guid.NewGuid().ToString();
}
public static string GetPartitionKey(DateTime? keyDateTime = null)
{
return string.Format("{0:yyyyyMM}", keyDateTime ?? DateTime.Now);
}
}
Run Code Online (Sandbox Code Playgroud)
这是执行查询的代码
var storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse("...");
var tableClient = storageAccount.CreateCloudTableClient();
var tableContext = new Microsoft.WindowsAzure.Storage.Table.DataServices.TableServiceContext(tableClient);
var diagnostics =
tableContext.CreateQuery<RouteDiagnostic>("RouteDiagnostic")
.Where(rd => rd.PartitionKey == "0201401")
.ToList();
Run Code Online (Sandbox Code Playgroud)
在使用数据服务查询时,最新更新或构造实体的其他方式有什么变化吗?
Jam*_*der 12
结果是对WCF Data Services 5.6的更新我需要在我的类型中添加以下属性:
[DataServiceKey("PartitionKey", "RowKey")]
Run Code Online (Sandbox Code Playgroud)
一旦我添加了DataServiceKey属性,一切都很好.
| 归档时间: |
|
| 查看次数: |
912 次 |
| 最近记录: |