2013-07-15 3 views
2

IronPython을 다양한 작업을 수행하는 스크립팅 엔진으로 사용하는 프로젝트가 있습니다. 이러한 작업 중 하나는 Azure 테이블 저장소에서 테이블 조회를 수행해야하지만 테이블 레이아웃은 다르고 자주 변경되므로 모델 클래스를 Python으로 정의해야합니다.IronPython의 Azure 테이블 저장소 쿼리

여기에 내가 겪고있는 문제는 쿼리를 실행할 때마다 내 프로젝트의 기본 클래스가 클라이언트 라이브러리에서 지원되지 않는다는 것입니다.

Unhandled Exception: System.InvalidOperationException: The type 'IronPython.NewTypes.IPTest.BaseModelClass_1$1' is not supported by the client library. 

파이썬 코드 :

import clr 
import System 
clr.AddReference("System.Core") 
clr.ImportExtensions(System.Linq) 


class MyTable(AzureTableService.BaseModelClass): 
    def __new__(self, partitionKey, rowKey): 
     self.PartitionKey = partitionKey 
     self.RowKey = rowKey 
     return super.__new__(self) 

    MyTableDetails = ""; 

#I can manually create an entity, and it recognizes the base class, but not when I try to return from a query 
#working = MyTable("10", "10040") 
#print working.PartitionKey 

y = AzureTableService.GetAzureTableQuery[MyTable]("MyTable") 
z = y.Where(lambda c: c.PartitionKey == "10" and c.RowKey == "10040") 

print(z.Single()) 

C# 코드 : 내가 부족 분명 아무것도

public class AzureTableService { 
    private CloudStorageAccount mStorageAccount; 
    public AzureTableService() { 
     CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) => { 
      var connectionString = ConfigurationManager.AppSettings[configName]; 
      configSetter(connectionString); 
     }); 
     mStorageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");   
    } 

    private TableServiceContext AzureTableServiceContext { 
     get { 
      var context = mStorageAccount.CreateCloudTableClient().GetDataServiceContext(); 
      context.IgnoreResourceNotFoundException = true; 
      return context; 
     } 
    } 
    public IQueryable<T> GetAzureTableQuery<T>(string TableName) { 
     return AzureTableServiceContext.CreateQuery<T>(TableName); 
    } 

    public class BaseModelClass : TableServiceEntity { 
     public BaseModelClass(string partitionKey, string rowKey) : base(partitionKey, rowKey) { } 
     public BaseModelClass() : base(Guid.NewGuid().ToString(), String.Empty) { } 
    } 
} 

있습니까? 내 주석이 달린 코드에서는 수동으로 만들 때 기본 클래스 속성을 인식하는 것으로 보이지만 쿼리에서 반환 할 때는 기본 클래스 속성을 인식하지 못합니다.

답변

0

문제는 Microsoft.WindowsAzure.StorageClient이 (가) 사용하는 System.Data.Services.Client과 관련되어 있습니다.

데이터 서비스 클라이언트에서 사용할 수있는 유형을 제한합니다. 이것은 IDynamicMetaObjectProvider (기본적으로 모든 동적 개체 및 따라서 IronPython 클래스의 모든 개체)의 구현이 쿼리 결과의 deserialization 중에 사용되는 것을 방지하는 것으로 보입니다.

결과를 확인하는 Azure Storage 1.7.0.0, 2.0.6.0 및 2.1.0.0-rc를 사용하여 시나리오를 테스트했습니다.

언제든지 the source을보고 AtomPub의 다른 디시리얼라이저를 사용할 수 있습니다.

관련 문제