Ejemplo n.º 1
0
        public static object GetProjectedWrapperEnumerator(IEnumerator <TableRow> enumerator, int propertyCount, string propertyListName, string resourceTypeName, string[] projectedProperties)
        {
            switch (Math.Min(9, propertyCount))
            {
            case 0:
            {
                return(DbUtilityResourceBuilder.GetProjectedWrapperTypedEnumerator <ProjectedWrapper0>(enumerator, propertyCount, propertyListName, resourceTypeName, projectedProperties));
            }

            case 1:
            {
                return(DbUtilityResourceBuilder.GetProjectedWrapperTypedEnumerator <ProjectedWrapper1>(enumerator, propertyCount, propertyListName, resourceTypeName, projectedProperties));
            }

            case 2:
            {
                return(DbUtilityResourceBuilder.GetProjectedWrapperTypedEnumerator <ProjectedWrapper2>(enumerator, propertyCount, propertyListName, resourceTypeName, projectedProperties));
            }

            case 3:
            {
                return(DbUtilityResourceBuilder.GetProjectedWrapperTypedEnumerator <ProjectedWrapper3>(enumerator, propertyCount, propertyListName, resourceTypeName, projectedProperties));
            }

            case 4:
            {
                return(DbUtilityResourceBuilder.GetProjectedWrapperTypedEnumerator <ProjectedWrapper4>(enumerator, propertyCount, propertyListName, resourceTypeName, projectedProperties));
            }

            case 5:
            {
                return(DbUtilityResourceBuilder.GetProjectedWrapperTypedEnumerator <ProjectedWrapper5>(enumerator, propertyCount, propertyListName, resourceTypeName, projectedProperties));
            }

            case 6:
            {
                return(DbUtilityResourceBuilder.GetProjectedWrapperTypedEnumerator <ProjectedWrapper6>(enumerator, propertyCount, propertyListName, resourceTypeName, projectedProperties));
            }

            case 7:
            {
                return(DbUtilityResourceBuilder.GetProjectedWrapperTypedEnumerator <ProjectedWrapper7>(enumerator, propertyCount, propertyListName, resourceTypeName, projectedProperties));
            }

            case 8:
            {
                return(DbUtilityResourceBuilder.GetProjectedWrapperTypedEnumerator <ProjectedWrapper8>(enumerator, propertyCount, propertyListName, resourceTypeName, projectedProperties));
            }

            case 9:
            {
                return(DbUtilityResourceBuilder.GetProjectedWrapperTypedEnumerator <ProjectedWrapperMany>(enumerator, propertyCount, propertyListName, resourceTypeName, projectedProperties));
            }
            }
            return(null);
        }
Ejemplo n.º 2
0
        public TResult Execute <TResult>(Expression expression)
        {
            PointQueryTracker pointQuery;

            if (this.CheckForReadPermission && this._context != null)
            {
                bool flag = TableResourceContainer.IsUtilityTables(this._userResourceName);
                this._context.CheckPermission(this._userResourceName, flag, true, UpdateKind.None);
            }
            if (TableResourceContainer.IsUtilityTables(this._userResourceName))
            {
                string str = null;
                if (this._context.ContinuationToken != null)
                {
                    this._context.ContinuationToken.TryGetValue("TableName", out str);
                }
                DevStoreTableQueryVisitor devStoreTableQueryVisitor = new DevStoreTableQueryVisitor(this._accountName, expression, str, TableDataContextHelper.MaxRowCount);
                devStoreTableQueryVisitor.TranslateQuery();
                if (this._context.IsBatchRequest && (!devStoreTableQueryVisitor.IsPointQuery.HasValue || !devStoreTableQueryVisitor.IsPointQuery.HasValue || !devStoreTableQueryVisitor.IsPointQuery.Value))
                {
                    throw new NotImplementedException();
                }
                string   str1              = devStoreTableQueryVisitor.SqlQuery.ToString();
                object[] array             = devStoreTableQueryVisitor.Parameters.ToArray();
                List <TableContainer> list = this._context.m_dbContext.ExecuteQuery <TableContainer>(str1, array).ToList <TableContainer>();
                if (devStoreTableQueryVisitor.TakeCount >= 0 && devStoreTableQueryVisitor.TakeCount < list.Count)
                {
                    TableContainer item = list[list.Count - 1];
                    this._context.ContinuationToken = new Dictionary <string, string>()
                    {
                        { "NextTableName", item.CasePreservedTableName }
                    };
                    this._context.ContinuationTokenAvailableCallback(this._context.ContinuationToken);
                    list.RemoveAt(list.Count - 1);
                }
                return((TResult)DbUtilityResourceBuilder.GetUtilityTableEnumerator(list.GetEnumerator()));
            }
            LinqToXmlTranslator linqToXmlTranslator = new LinqToXmlTranslator(this._accountName, this._userResourceName, expression, this._context.ContinuationToken, TableDataContextHelper.MaxRowCount, this._context.IsBatchRequest, this.SASKeyBounds);

            linqToXmlTranslator.TranslateQuery();
            if (linqToXmlTranslator.PointQuery.IsPointQuery)
            {
                pointQuery = linqToXmlTranslator.PointQuery;
            }
            else
            {
                pointQuery = null;
            }
            this.PointQuery = pointQuery;
            if (this._context.IsBatchRequest && this.PointQuery == null)
            {
                throw new NotSupportedException("We support retrieving only a single resource via a batch.");
            }
            string str2 = linqToXmlTranslator.XmlQuery.ToString();

            object[] objArray = (
                from ParameterRecord  in linqToXmlTranslator.Parameters
                select r.Value).ToArray <object>();
            List <TableRow> tableRows = this._context.m_dbContext.ExecuteQuery <TableRow>(str2, objArray).ToList <TableRow>();

            if (linqToXmlTranslator.TakeCount >= 0 && linqToXmlTranslator.TakeCount < tableRows.Count)
            {
                TableRow tableRow = tableRows[tableRows.Count - 1];
                this._context.ContinuationToken = new Dictionary <string, string>();
                this._context.ContinuationToken["NextPartitionKey"] = DevelopmentStorageDbDataContext.DecodeKeyString(tableRow.PartitionKey);
                this._context.ContinuationToken["NextRowKey"]       = DevelopmentStorageDbDataContext.DecodeKeyString(tableRow.RowKey);
                this._context.ContinuationTokenAvailableCallback(this._context.ContinuationToken);
                tableRows.RemoveAt(tableRows.Count - 1);
            }
            if (linqToXmlTranslator.ProjectedPropertyCount < 0)
            {
                return((TResult)DbUtilityResourceBuilder.GetUtilityRowEnumerator(tableRows.GetEnumerator()));
            }
            return((TResult)DbUtilityResourceBuilder.GetProjectedWrapperEnumerator(tableRows.GetEnumerator(), linqToXmlTranslator.ProjectedPropertyCount, linqToXmlTranslator.PropertyListName, this._userResourceName, linqToXmlTranslator.ProjectedProperties));
        }