如何排除属性在Azure表存储中保留?

Jef*_*f D 22 azure azure-storage azure-table-storage

如果我有这样的课程:

    public class Facet : TableServiceEntity
{
    public Guid ParentId { get; set; }      
    public string Name { get; set; }
    public string Uri{ get; set; }
    public Facet Parent { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

Parent来自ParentId Guid,该关系旨在由我的存储库填充.那么我如何告诉Azure单独留下该字段?是否存在某种类型的Ignore属性,或者我是否必须创建一个提供这些关系的继承类?

Tho*_*mas 25

使用最新的Microsoft.WindowsAzure.Storage SDK(v6.2.0及更高版本),属性名称已更改为IgnorePropertyAttribute:

public class MyEntity : TableEntity
{
     public string MyProperty { get; set; }

     [IgnoreProperty]
     public string MyIgnoredProperty { get; set; }
}
Run Code Online (Sandbox Code Playgroud)


Man*_*een 8

有一个名为WindowsAzure.Table.Attributes.IgnoreAttribute的属性可以在要排除的属性上设置.只需使用:

[Ignore]
public string MyProperty { get; set; }
Run Code Online (Sandbox Code Playgroud)

它是Windows Azure存储扩展的一部分,您可以从以下网址下载:https: //github.com/dtretyakov/WindowsAzure

或安装为一个软件包:https: //www.nuget.org/packages/WindowsAzure.StorageExtensions/

该库是MIT许可的.

  • 这已被"IgnorePropertyAttribute"取代,请参阅[IgnorePropertyAttribute类](https://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storage.table.ignorepropertyattribute.aspx). (4认同)

Jef*_*f D 4

来自生物武器公约安迪·克罗斯的回复 --- 再次感谢安迪。 这个问题是天蓝色的论坛

你好,

使用 WriteEntity 和 ReadingEntity 事件。http://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicecontext.writingentity.aspx这为您提供了所需的所有控制。

作为参考,这里也链接了一篇博客文章:http://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/d9144bb5-d8bb-4e42-a478-58addebfc3c8

谢谢安迪

  • 遗憾的是,论坛的链接不再有效:​​-( MSDN 真的搞砸了它的链接! (2认同)