internal static void AddObjectsToDictionaryFromXml(XElement xmlRoot, UtilityRow entity, bool shouldIncludeNull) { Dictionary <string, object> strs = new Dictionary <string, object>(); XmlUtility.AddObjectsToDictionaryFromXml(xmlRoot, entity.ColumnValues, shouldIncludeNull); }
private void ProcessChange(ChangeDescription changeDescription) { TableRow sqlEntity = null; PointQueryTracker pointQuery = null; DbTableDataContext failedCommandIndex = this; failedCommandIndex.FailedCommandIndex = failedCommandIndex.FailedCommandIndex + 1; switch (changeDescription.UpdateType) { case UpdateKind.Insert: { this.CheckPermissions(null, changeDescription); this.CheckPartitionAndRowKeys(((UtilityRow)changeDescription.Row).PartitionKey, ((UtilityRow)changeDescription.Row).RowKey, changeDescription.UpdateType); DateTime?nullable = null; sqlEntity = this.GetSqlEntity(((UtilityRow)changeDescription.Row).PartitionKey, ((UtilityRow)changeDescription.Row).RowKey, nullable); if (sqlEntity != null) { throw new TableServiceGeneralException(TableServiceError.EntityAlreadyExists, null); } UtilityRow row = (UtilityRow)changeDescription.Row; this.AddChangeToMap(DevelopmentStorageDbDataContext.EncodeKeyString(row.PartitionKey), DevelopmentStorageDbDataContext.EncodeKeyString(row.RowKey), changeDescription); this.m_dbContext.TableRows.InsertOnSubmit(this.CreateAndPopulateSqlEntity(row)); return; } case UpdateKind.Delete: { if (changeDescription.IfMatchHeaderMissing) { throw new XStoreArgumentException("If-Match header is mandatory when deleting an entity."); } sqlEntity = this.CheckAndGetEntity(changeDescription, true); this.AddChangeToMap(sqlEntity.PartitionKey, sqlEntity.RowKey, changeDescription); this.m_dbContext.TableRows.DeleteOnSubmit(sqlEntity); return; } case UpdateKind.Replace: { sqlEntity = this.CheckAndGetEntity(changeDescription, true); this.AddChangeToMap(sqlEntity.PartitionKey, sqlEntity.RowKey, changeDescription); sqlEntity.Data = XmlUtility.GetXmlFromUtilityRow(changeDescription.Row as UtilityRow); return; } case UpdateKind.Merge: { sqlEntity = this.CheckAndGetEntity(changeDescription, true); this.AddChangeToMap(sqlEntity.PartitionKey, sqlEntity.RowKey, changeDescription); sqlEntity.Data = XmlUtility.MergeXmlProperties(changeDescription.Row as UtilityRow, sqlEntity.Data); return; } case UpdateKind.InsertOrMerge: { this.ExecuteQuery <UtilityRow>(changeDescription); pointQuery = ((DbTableRowQueryProvider <UtilityRow>)changeDescription.QueryableRow.Provider).PointQuery; if (pointQuery == null) { throw new DataServiceException(400, "PK and RK not present in the required format"); } (changeDescription.Row as UtilityRow).PartitionKey = pointQuery.PartitionKey; (changeDescription.Row as UtilityRow).RowKey = pointQuery.RowKey; sqlEntity = this.CheckAndGetEntity(changeDescription, false); this.AddChangeToMap(DevelopmentStorageDbDataContext.EncodeKeyString(pointQuery.PartitionKey), DevelopmentStorageDbDataContext.EncodeKeyString(pointQuery.RowKey), changeDescription); if (sqlEntity != null) { sqlEntity.Data = XmlUtility.MergeXmlProperties(changeDescription.Row as UtilityRow, sqlEntity.Data); return; } this.m_dbContext.TableRows.InsertOnSubmit(this.CreateAndPopulateSqlEntity(changeDescription.Row as UtilityRow)); return; } case UpdateKind.InsertOrReplace: { this.ExecuteQuery <UtilityRow>(changeDescription); pointQuery = ((DbTableRowQueryProvider <UtilityRow>)changeDescription.QueryableRow.Provider).PointQuery; if (pointQuery == null) { throw new DataServiceException(400, "PK and RK not present in the required format"); } (changeDescription.Row as UtilityRow).PartitionKey = pointQuery.PartitionKey; (changeDescription.Row as UtilityRow).RowKey = pointQuery.RowKey; sqlEntity = this.CheckAndGetEntity(changeDescription, false); this.AddChangeToMap(DevelopmentStorageDbDataContext.EncodeKeyString(pointQuery.PartitionKey), DevelopmentStorageDbDataContext.EncodeKeyString(pointQuery.RowKey), changeDescription); if (sqlEntity != null) { sqlEntity.Data = XmlUtility.GetXmlFromUtilityRow(changeDescription.Row as UtilityRow); return; } this.m_dbContext.TableRows.InsertOnSubmit(this.CreateAndPopulateSqlEntity(changeDescription.Row as UtilityRow)); return; } default: { return; } } }