/// <summary> /// Defines the local table on the store. /// </summary> /// <param name="tableName">Name of the local table.</param> /// <param name="item">An object that represents the structure of the table.</param> public override void DefineTable(string tableName, JObject item) { if (tableName == null) { throw new ArgumentNullException("tableName"); } if (item == null) { throw new ArgumentNullException("item"); } if (this.Initialized) { throw new InvalidOperationException("Cannot define a table after the store has been initialized."); } // add id if it is not defined JToken ignored; if (!item.TryGetValue(MobileServiceSystemColumns.Id, StringComparison.OrdinalIgnoreCase, out ignored)) { item[MobileServiceSystemColumns.Id] = String.Empty; } var tableDefinition = (from property in item.Properties() let storeType = SqlHelpers.GetStoreType(property.Value.Type, allowNull: false) select new ColumnDefinition(property.Name, property.Value.Type, storeType)) .ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase); var sysProperties = GetSystemProperties(item); this.tableMap.Add(tableName, new TableDefinition(tableDefinition, sysProperties)); }
public static object SerializeValue(JValue value, bool allowNull) { string storeType = SqlHelpers.GetStoreType(value.Type, allowNull); return(SerializeValue(value, storeType, value.Type)); }