Esempio n. 1
0
        public static IEnumerator <T> GetProjectedWrapperTypedEnumerator <T>(IEnumerator <TableRow> enumerator, int propertyCount, string propertyListName, string resourceTypeName, string[] projectedProperties)
            where T : ProjectedWrapper
        {
            List <T> ts = new List <T>();

            while (enumerator.MoveNext())
            {
                TableRow current = enumerator.Current;
                Dictionary <string, object> strs = new Dictionary <string, object>();
                strs["PartitionKey"] = DevelopmentStorageDbDataContext.DecodeKeyString(current.PartitionKey);
                strs["RowKey"]       = DevelopmentStorageDbDataContext.DecodeKeyString(current.RowKey);
                strs["Timestamp"]    = current.Timestamp;
                XmlUtility.AddObjectsToDictionaryFromXml(current.Data, strs, true);
                object[] objArray = new object[propertyCount];
                for (int i = 0; i < propertyCount; i++)
                {
                    if (!strs.TryGetValue(projectedProperties[i], out objArray[i]))
                    {
                        objArray[i] = null;
                    }
                }
                ProjectedWrapperCreator projectedWrapperCreator = ProjectedWrapperCreator.GetProjectedWrapperCreator(propertyCount);
                ts.Add((T)projectedWrapperCreator.CreateProjectedWrapper(objArray, propertyListName, resourceTypeName));
            }
            return(ts.GetEnumerator());
        }
Esempio n. 2
0
        public static object GetUtilityRowEnumerator(IEnumerator <TableRow> enumerator)
        {
            List <UtilityRow> utilityRows = new List <UtilityRow>();

            while (enumerator.MoveNext())
            {
                TableRow   current    = enumerator.Current;
                UtilityRow utilityRow = new UtilityRow()
                {
                    PartitionKey = DevelopmentStorageDbDataContext.DecodeKeyString(current.PartitionKey),
                    RowKey       = DevelopmentStorageDbDataContext.DecodeKeyString(current.RowKey),
                    Timestamp    = current.Timestamp
                };
                XmlUtility.AddObjectsToDictionaryFromXml(current.Data, utilityRow, false);
                utilityRows.Add(utilityRow);
            }
            return(utilityRows.GetEnumerator());
        }
Esempio n. 3
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));
        }