加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – Azure存储客户端v4.1 – 期望非基本类型的值

发布时间:2020-12-15 22:05:31 所属栏目:百科 来源:网络整理
导读:我最近将我的ASP.NET项目(MVC5)升级为使用Storage Library 4.1定位Azure SDK 2.3,当我尝试将任何内容保存到Table Storage时遇到一个奇怪的错误. 错误: An unhandled exception of type ‘Microsoft.WindowsAzure.Storage.StorageException’ occurred in Mi
我最近将我的ASP.NET项目(MVC5)升级为使用Storage Library 4.1定位Azure SDK 2.3,当我尝试将任何内容保存到Table Storage时遇到一个奇怪的错误.

错误:

An unhandled exception of type ‘Microsoft.WindowsAzure.Storage.StorageException’ occurred in Microsoft.WindowsAzure.Storage.dll

Additional information: A primitive value was specified; however,a value of the non-primitive type ” was expected.

我的模型通过使用TableServiceContext添加,更新,删除,保存的存储库进入表存储.

我按照这种模式为我的模型:

[System.Data.Services.Common.DataServiceKey(new string[] { "PartitionKey","RowKey" })]
public class PersistedAlert : Alert,ITableEntity
{
    public string PartitionKey
    {
        get { return this.StudentId; }
        set { this.StudentId = value; }
    }

    public string RowKey
    {
        get { return this.Id; }
        set { this.Id = value; }
    }

    public DateTime Timestamp { get; set; }

    public new int Type { get; set; } //hides Enum type in Alert base class
}

在升级过程中,我需要将所有引用换成

System.Data.Services.*

对于

Microsoft.Data.Services.*

…除OData库外.

内部有什么变化使我的模式不再有效吗?

解决方法

由于网上没有任何关于此错误的内容,而且这几乎是它所讨论的唯一地方,即使我的上下文与您的上下文不同,我也会添加一个解决方案.错误是完全一样的,所以我猜它起源于同一个地方.

对我来说,这是一个导致问题的继承主键.序列化实体的主键必须是自然的而不是重写.如果Class具有ID属性,则DerivedClass还必须将ID属性声明为“new”,或者必须将ID属性从Class移动到DerivedClass.

这里有更多细节:http://jerther.blogspot.ca/2014/12/aspnet-odata-v4-primitive-value-was.html

我确实认为这是一个错误而不是限制,因为继承的密钥与Entity Framework和Fluent API非常兼容.

我希望这有助于节省一些头发.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读