Azure Table 스토리지에 유지되는 속성을 제외하려면 어떻게 해야 합니까?
다음과 같은 수업이 있는 경우:
public class Facet : TableServiceEntity
{
public Guid ParentId { get; set; }
public string Name { get; set; }
public string Uri{ get; set; }
public Facet Parent { get; set; }
}
부모는 ParentId GUID에서 파생되며 이 관계는 내 저장소에서 작성됩니다.그럼 어떻게 하면 애저에게 그 필드를 떠나라고 말할 수 있을까요?특정 유형의 Ignore 속성이 있습니까?아니면 대신 이러한 관계를 제공하는 상속된 클래스를 만들어야 합니까?
최신 Microsoft 사용.WindowsAzure.Storage SDK(v6.2.0 이상), 속성 이름이 다음과 같이 변경되었습니다.IgnorePropertyAttribute
:
public class MyEntity : TableEntity
{
public string MyProperty { get; set; }
[IgnoreProperty]
public string MyIgnoredProperty { get; set; }
}
WindowsAzure라는 속성이 있습니다.Table. 속성.제외할 속성에 IgnoreAttribute를 설정할 수 있습니다.사용방법:
[Ignore]
public string MyProperty { get; set; }
Windows Azure Storage Extensions 의 일부입니다.https://github.com/dtretyakov/WindowsAzure 에서 다운로드할 수 있습니다.
또는 패키지로 인스톨 합니다.https://www.nuget.org/packages/WindowsAzure.StorageExtensions/
라이브러리는 MIT 라이선스가 있습니다.
bwc에서 Andy Cross가 보낸 이 답장은 --- 다시 한 번 고마워요 Andy.이 질문은 녹색 포럼입니다.
안녕하세요.
WritingEntity 및 ReadingEntity 이벤트를 사용합니다.http://msdn.microsoft.com/en-us/library/system.data.services.client.dataservicecontext.writingentity.aspx 필요한 모든 제어가 가능합니다.
참고로 여기에도 링크되어 있는 블로그 투고가 있습니다.
앤디 고마워
TableEntity에서 WriteEntity 메서드를 덮어쓰고 사용자 지정 속성이 있는 속성을 삭제할 수 있습니다.
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; }
}
getter 및 setter를 비공개로 설정하여 테이블 스토리지 데이터베이스에 속성이 저장되는 것을 건너뛸 수도 있습니다.
참조: https://stackoverflow.com/a/21071796/5714633
이 답변들은 좀 구식일 수 있습니다.
Azure의 최신 버전을 사용하여 이 기능을 아직 필요로 하는 고객님은 다음 웹 사이트를 이용해 주십시오.[IgnoreDataMember]
언급URL : https://stackoverflow.com/questions/2277247/how-do-you-exclude-a-property-from-being-persisted-in-azure-table-storage
'programing' 카테고리의 다른 글
속성 문자열을 사용하여 텍스트를 굵게 표시 (0) | 2023.04.21 |
---|---|
Query Explorer를 통해 조건에 따라 CosmosDB에서 문서 삭제 (0) | 2023.04.21 |
SSIS Excel 데이터 원본 - 열 데이터 형식을 재정의할 수 있습니까? (0) | 2023.04.21 |
Excel 2013 VBA Clear All Filters 매크로 (0) | 2023.04.21 |
UIView 서브클래스를 위한 적절한 프랙티스 (0) | 2023.04.21 |