public void RegisterIndex(Models.DataType type, IndexDefinition indexDefinition) { if (type == DataType.Boolean) { _booleanIndexes.Add(indexDefinition.FieldId, Indexing.Creation.IndexFactory.CreateIndex <bool>(indexDefinition.IndexType)); } else if (type == DataType.Int16) { _int16Indexes.Add(indexDefinition.FieldId, Indexing.Creation.IndexFactory.CreateIndex <Int16>(indexDefinition.IndexType)); } else if (type == DataType.Int32) { _int32Indexes.Add(indexDefinition.FieldId, Indexing.Creation.IndexFactory.CreateIndex <Int32>(indexDefinition.IndexType)); } else if (type == DataType.Int64) { _int64Indexes.Add(indexDefinition.FieldId, Indexing.Creation.IndexFactory.CreateIndex <Int64>(indexDefinition.IndexType)); } else if (type == DataType.Decimal) { _decimalIndexes.Add(indexDefinition.FieldId, Indexing.Creation.IndexFactory.CreateIndex <decimal>(indexDefinition.IndexType)); } else if (type == DataType.BigString || type == DataType.LittleString) { _stringIndexes.Add(indexDefinition.FieldId, Indexing.Creation.IndexFactory.CreateIndex <string>(indexDefinition.IndexType)); } else if (type == DataType.DateTime) { _dateTimeIndexes.Add(indexDefinition.FieldId, Indexing.Creation.IndexFactory.CreateIndex <DateTime>(indexDefinition.IndexType)); } }
public List <Models.DataType> GetAllDataTypes() { List <Models.DataType> DataTypeList = null; try { //SQL Statement var sqlString = "SELECT * FROM data_types"; using (var connection = new NpgsqlConnection(connectionString)) { connection.Open(); using (var command = new NpgsqlCommand(sqlString, connection)) { command.Prepare(); using (var reader = command.ExecuteReader()) { if (reader != null && reader.HasRows) { //Initialize a Data Type Models.DataType dataType = null; //Create a List to hold multiple Data Types DataTypeList = new List <Models.DataType>(); while (reader.Read()) { //Create and hydrate a new Object dataType = new Models.DataType(); dataType.Id = Convert.ToInt64(reader["id"]); dataType.Name = Convert.ToString(reader["name"]).Trim(); //Add to List DataTypeList.Add(dataType); } } } } } return(DataTypeList); } catch (Exception ex) { //Log Exception //_logger.LogError(ex, "error retrieving data types"); return(DataTypeList); } }
public IHttpActionResult GetDataType(int id) { DataType dataType = db.DataType.Find(id); if (dataType == null) { return(NotFound()); } var item = new Models.DataType { Id = dataType.Id, Name = dataType.Name, Properties = dataType.Properties }; return(Ok(item)); }
public Models.DataType GetDataType(long id) { Models.DataType dataType = null; try { //SQL Statement var sqlString = "SELECT * FROM data_types WHERE id = @id"; using (var connection = new NpgsqlConnection(connectionString)) { connection.Open(); using (var command = new NpgsqlCommand(sqlString, connection)) { command.Parameters.AddWithValue("@id", NpgsqlTypes.NpgsqlDbType.Bigint, id); command.Prepare(); using (var reader = command.ExecuteReader()) { if (reader != null && reader.HasRows) { while (reader.Read()) { //Create and hydrate a new Object dataType = new Models.DataType(); dataType.Id = Convert.ToInt64(reader["id"]); dataType.Name = Convert.ToString(reader["name"]).Trim(); } } } } } return(dataType); } catch (Exception ex) { //Log Exception //_logger.LogError(ex, "error retrieving data type"); return(dataType); } }