首页 > 代码库 > 存入azure table是忽略某个属性
存入azure table是忽略某个属性
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.
存入azure table是忽略某个属性
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。