public class CustomTableEntity : TableEntity
    {
        public override IDictionary<string, EntityProperty> WriteEntity(Microsoft.WindowsAzure.Storage.OperationContext operationContext)
        {
            var entityProperties = base.WriteEntity(operationContext);
            var objectProperties = GetType().GetProperties();

            foreach (var property in from property in objectProperties
                                     let nonSerializedAttributes = property.GetCustomAttributes(typeof(NonSerializedOnAzureAttribute), false)
                                     where nonSerializedAttributes.Length > 0
                                     select property)
            {
                entityProperties.Remove(property.Name);
            }

            return entityProperties;
        }
    }

    [AttributeUsage(AttributeTargets.Property)]
    public class NonSerializedOnAzureAttribute : Attribute
    {
    }
    public class MyEntity : CustomTableEntity
    {
        public string MyProperty { get; set; }

        //[NonSerializedOnAzure]
        public string MyIgnoredProperty { get; set; }
    }

 There is an attribute called WindowsAzure.Table.Attributes.IgnoreAttribute can be set on the property you want to exclude.

 

posted on 2014-10-17 14:22  aking96  阅读(279)  评论(0编辑  收藏  举报