Note that there are some explanatory texts on larger screens.

plurals
  1. POApplying Dynamic LINQ on Azure table storage is thowing exception Value cannot be null
    primarykey
    data
    text
    <p>Im trying to query the azure table storage's Table using Dynamic LINQ Queries to get only subset of columns along dynamic constructed predicate. I was able to successfully generate predicate, but to implement Select i.e. Projection Operation to get only required properties/ columns from entities of Azure table I'm facing difficulties. To get sub set of columns I'm trying to use Dynamic LINQ Library. Here the Columns are not predefined, columns can be anything, user may select. These columns are nothing but Properties of Customer class..</p> <pre><code>Months.AsParallel().ForAll(x =&gt; RowKeys.AsParallel().WithDegreeOfParallelism(5).ForAll(y =&gt; { string StartRowKey = y.GetRowKeyStartFilter(); string EndRowKey = y.GetRowKeyEndFilter(); DataContextExciseCustVen rptContextParallel = new DataContextExciseCustVen(); var strPredicate = GetPredicate(x.ToString(), StartRowKey, EndRowKey); IQueryable&lt;dynamic&gt; query = (rptContextParallel.CreateQuery&lt;DomainData.Entities.Excise.Invoice&gt;(DomainData.Entities.Excise.Invoice.TABLE_NAME) .Where(strPredicate) .Select("new (PartitionKey ,RowKey ,Timestamp ,CompanyCode,ProgramCode)")) as IQueryable&lt;dynamic&gt;; CloudTableQuery&lt;dynamic&gt; dyn = query.AsTableServiceQuery(); foreach (var z in dyn.Execute()) { threadSafeData.Add(z); } } )); </code></pre> <p>When I Execute above Code, I'm getting exception at query.AsTableServiceQuery();, Value cannot be null . Select("new (Col1,Col2)") is returns IQueryable type , but not IQueryable. Because I'm returning sub set of columns from Azure table, I Will not know destination type of object. It will anonymous every time. IQueryable doesn't contain AsTableServiceQuery() extension method. but IQueryable has this extension method from Azure Client SDK. </p> <pre><code>IQueryable&lt;dynamic&gt; query = (rptContextParallel.CreateQuery&lt;Customer&gt;(DomainData.Entities.Customer.TABLE_NAME) .Where(strPredicate) .Select("new (CompanyCode,ProgramCode,CustomerName,...)")) as IQueryable&lt;dynamic&gt;; </code></pre> <p>The above statement, Select Clause returns IQueryable type and it is type casted to IQueryable because IQueryable doesn't contains AsTableServiceQuery extension method. So I typed cased to IQueryable . CloudTableQuery dyn = query.AsTableServiceQuery(); .. Here it throws an exception has value cannot be null. Looks like type casting is failed. because of which linq expression cannot be evaluated. Any work around to have IQueryable with ASTableServiceQuery extension method.</p> <p>I tried other way around , I commented out this statement // CloudTableQuery dyn = query.AsTableServiceQuery(); and changed for loop like below, This worked like charm. <code>foreach (var z in query) {} </code> But the question, I was not using any AsTableServiceQuery() and execute method of Storage Client. Will there any side effects for not calling AsTableServiceQuery. will I be able to receive all the data with ContinuationTokens, or Keys etc. result which returns from azure table will be around 1 million or more. So above query can be able to retrieve all the records along with other keys .</p> <p>Please help me on this...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload