public bool IsValidName(string column) { if (_repository.DataBaseTypes == DataBaseTypes.PostgreSql) { if (NotValidkeywords == null) { NotValidkeywords = _repository.GetLightDataTable(_repository.GetSqlCommand("select * from pg_get_keywords() where catdesc = String[reserved]"), "word"); } return(!NotValidkeywords.FindByPrimaryKey <bool>(column.ToLower())); } return(true); }
public ILightDataTable ObjectColumns(Type type) { var key = type.FullName + _repository.DataBaseTypes.ToString(); try { if (CachedObjectColumn.ContainsKey(key)) { return(CachedObjectColumn[key]); } var table = type.TableName(); var cmd = _repository.GetSqlCommand(_repository.DataBaseTypes == DataBaseTypes.Mssql || _repository.DataBaseTypes == DataBaseTypes.PostgreSql ? $"SELECT COLUMN_NAME as column_name, data_type FROM INFORMATION_SCHEMA.COLUMNS WHERE LOWER(TABLE_NAME) = LOWER(String[{table}])" : $"SELECT name as column_name, type as data_type FROM pragma_table_info(String[{table}]);"); var data = _repository.GetLightDataTable(cmd, "column_name"); if (data.Rows.Any()) { return(CachedObjectColumn.GetOrAdd(key, data)); } else { return(data); } } catch (NpgsqlException) { _repository.Renew(); return(ObjectColumns(type)); } }