<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>In an application I'm working on, I'm trying to write an IronPython script that queries Azure Tables, returning a result into a class defined in Python.  I keep running into the following error when I do this:<div><br></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>Unhandled Exception: System.InvalidOperationException: The type 'IronPython.NewTypes.IPAzureTest.BaseModelClass_1$1' is not supported by the client library.</div></div><div><div>   at System.Data.Services.Client.ClientType.Create(Type type, Boolean expectModelType)</div></div><div><div>   at System.Data.Services.Client.AtomMaterializer.ResolveByCreating(AtomEntry entry, Type expectedEntryType)</div></div><div><div>   at System.Data.Services.Client.AtomMaterializer.ResolveOrCreateInstance(AtomEntry entry, Type expectedEntryType)</div></div><div><div>   at System.Data.Services.Client.AtomMaterializerInvoker.DirectMaterializePlan(Object materializer, Object entry, Type expectedEntryType)</div></div><div><div>   at System.Data.Services.Client.ProjectionPlan.Run(AtomMaterializer materializer, AtomEntry entry, Type expectedType)</div></div><div><div>   at System.Data.Services.Client.AtomMaterializer.Read()</div></div><div><div>   at System.Data.Services.Client.MaterializeAtom.MoveNextInternal()</div></div><div><div>   at System.Data.Services.Client.MaterializeAtom.MoveNext()</div></div><div><div>   at System.Linq.Enumerable.<CastIterator>d__b1`1.MoveNext()</div></div><div><div>   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)</div></div><div><div>   at System.Data.Services.Client.DataServiceQueryProvider.ReturnSingleton[TElement](Expression expression)</div></div><div><div>   at System.Data.Services.Client.DataServiceQueryProvider.Execute[TResult](Expression expression)</div></div><div><div>   at System.Linq.Queryable.Single[TSource](IQueryable`1 source)</div></div><div><div>   at Microsoft.Scripting.Interpreter.FuncCallInstruction`2.Run(InterpretedFrame frame)</div></div><div><div>   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)</div></div><div><div>   at Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0 arg0, T1 arg1, T2 arg2)</div></div><div><div>   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)</div></div><div><div>   at Microsoft.Scripting.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)</div></div><div><div>   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)</div></div><div><div>   at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)</div></div><div><div>   at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)</div></div><div><div>   at IronPython.Compiler.PythonScriptCode.Run(Scope scope)</div></div><div><div>   at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)</div></div><div><div>   at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope)</div></div><div><div>   at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink)</div></div><div><div>   at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)</div></div><div><div>   at IPAzureTest.IPScriptHost.RunEdit() in d:\Development\Utilities\IPAzureTest\IPAzureTest\IPScriptHost.cs:line <span style="font-size: 12pt;">31</span></div></div><div><div>   at IPAzureTest.Program.Main(String[] args) in d:\Development\Utilities\IPAzureTest\IPAzureTest\Program.cs:line <span style="font-size: 12pt;">12</span></div></div></blockquote><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">If I define the model class in C#, I do not run into this issue.  The data I'm working with changes often.  Being able to define the model in Python will make it so new builds are not necessary when additional tables are added.  </span></div><div><span style="font-size: 12pt;"><br></span></div><div>Here is what my python script looks like:</div><div><br></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>import clr</div></div><div><div>import System</div></div><div><div>clr.AddReference("System.Core")</div></div><div><div>clr.ImportExtensions(System.Linq)</div></div><div><div><br></div></div><div><div>class MyTable(AzureTableService.BaseModelClass):</div></div><div><div><span class="Apple-tab-span" style="white-space:pre">   </span>def __new__(self, partitionKey, rowKey):</div></div><div><div><span class="Apple-tab-span" style="white-space:pre">              </span>self.PartitionKey = partitionKey</div></div><div><div><span class="Apple-tab-span" style="white-space:pre">              </span>self.RowKey = rowKey</div></div><div><div><span class="Apple-tab-span" style="white-space:pre">          </span>return super.__new__(self)</div></div><div><div><span class="Apple-tab-span" style="white-space:pre">            </span></div></div><div><div><span class="Apple-tab-span" style="white-space:pre">      </span>MyTableDetails = "";</div></div><div><div><br></div></div><div><span style="font-size: 12pt;">y = AzureTableService.GetAzureTableQuery[MyTable]("MyTable")</span></div><div><div>z = y.Where(lambda c: c.PartitionKey == "10" and c.RowKey == "10040").Single()</div></div><div><div><br></div></div><div><div>print(z.MyTableDetails)</div></div><div><br></div></blockquote>And my C# Code:<div><br></div><div><pre style="font-family: Consolas; font-size: 13px; background-position: initial initial; background-repeat: initial initial;">    <span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">AzureTableService</span> {
        <span style="color:blue;">private</span> <span style="color:#2b91af;">CloudStorageAccount</span> mStorageAccount;
        <span style="color:blue;">public</span> AzureTableService() {
            <span style="color:#2b91af;">CloudStorageAccount</span>.SetConfigurationSettingPublisher((configName, configSetter) => {
                <span style="color:blue;">var</span> connectionString = <span style="color:#2b91af;">ConfigurationManager</span>.AppSettings[configName];
                configSetter(connectionString);
            });
            mStorageAccount = <span style="color:#2b91af;">CloudStorageAccount</span>.FromConfigurationSetting(<span style="color:#a31515;">"DataConnectionString"</span>);        
        }
                
        <span style="color:blue;">private</span> <span style="color:#2b91af;">TableServiceContext</span> AzureTableServiceContext {
            <span style="color:blue;">get</span> {
                <span style="color:blue;">var</span> context = mStorageAccount.CreateCloudTableClient().GetDataServiceContext();
                context.IgnoreResourceNotFoundException = <span style="color:blue;">true</span>;
                <span style="color:blue;">return</span> context;
            }
        }
        <span style="color:blue;">public</span> <span style="color:#2b91af;">IQueryable</span><T> GetAzureTableQuery<T>(<span style="color:blue;">string</span> TableName) {
            <span style="color:blue;">return</span> AzureTableServiceContext.CreateQuery<T>(TableName);
        }
 
        <span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">BaseModelClass</span> : <span style="color:#2b91af;">TableServiceEntity</span> {
            <span style="color:blue;">public</span> BaseModelClass(<span style="color:blue;">string</span> partitionKey, <span style="color:blue;">string</span> rowKey) : <span style="color:blue;">base</span>(partitionKey, rowKey) { }
            <span style="color:blue;">public</span> BaseModelClass() : <span style="color:blue;">base</span>(<span style="color:#298ca9;">Guid</span>.NewGuid().ToString(), <span style="color:#2b91af;">String</span>.Empty) { }
        }
 
        <span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">MyTable</span> : <span style="color:#2b91af;">TableServiceEntity</span> {
            <span style="color:blue;">public</span> MyTable(<span style="color:blue;">string</span> partitionKey, <span style="color:blue;">string</span> rowKey) : <span style="color:blue;">base</span>(partitionKey, rowKey) { }
            <span style="color:blue;">public</span> MyTable() : <span style="color:blue;">base</span>(<span style="color:#298ca9;">Guid</span>.NewGuid().ToString(), <span style="color:#2b91af;">String</span>.Empty) { }
            <span style="color:blue;">public</span> <span style="color:blue;">string</span> FeeScheduleDetails { <span style="color:blue;">get</span>; <span style="color:blue;">set</span>; }
        }
    }</pre><div><br></div></div><div>If I use MyTable define in C#, it works fine.  By using the one defined in Python throws the exception.  Can anyone point me in the right direction?</div><div><br></div>                                          </div></body>
</html>