/// <summary> /// Loads the primary keys. /// </summary> /// <param name="tableConfig">The table configuration.</param> /// <param name="tableInfo">The table information.</param> /// <param name="parentInfo">The parent class table information.</param> protected virtual void LoadPrimaryKeys(TableConfig tableConfig, TableInfo tableInfo, TableInfo parentInfo) { if (tableConfig.PrimaryKeys.Count > 0) { foreach (var item in tableConfig.PrimaryKeys.Distinct().Where(x => !IsIgnored(x, tableConfig))) { tableInfo.PrimaryKeys.Add(item); } } else if (parentInfo != null && parentInfo.PrimaryKeys.Count > 0) { foreach (var item in parentInfo.PrimaryKeys.Where(x => !IsIgnored(x, tableConfig))) { tableInfo.PrimaryKeys.Add(item); } } else { string primaryKey = ConfigData.PrimaryKeyDefault(tableConfig.Type); if (!string.IsNullOrEmpty(primaryKey) && !IsIgnored(primaryKey, tableConfig)) { if (ExpressionProcessor.GetProperty(tableConfig.Type, primaryKey) == null) { throw new InvalidConfigurationException($"The type \"{tableConfig.Type}\" does not have " + $"property \"{primaryKey}\"."); } tableInfo.PrimaryKeys.Add(primaryKey); } } }
/// <summary> /// Checks if a property exists and return it. /// </summary> /// <param name="propertyName">The property name.</param> /// <returns>The property name.</returns> protected string GetProperty(string propertyName) { if (ExpressionProcessor.GetProperty(Config.Type, propertyName) == null) { throw new ArgumentException($"The type \"{Config.Type}\" does not have property \"{propertyName}\".", nameof(propertyName)); } return(propertyName); }