public async Task <Row> GetTableRow(int tableId, int rowId) { var tableMeta = await _dbContext.TableInfos.Where(x => x.Id == tableId) .Include(x => x.FieldInfos).FirstAsync(); if (tableMeta == null) { throw new TableNotFoundException(tableId); } var table = _mapper.Map <Table>(tableMeta); var selectSpecificRowQuery = _commandDirector.BuildSelectSpecificRow(table, rowId, tableMeta.ViewQuery); var unhandledRow = _dbContext.CollectFromExecuteSql(selectSpecificRowQuery).First(); var row = new Row { TableId = table.Id }; foreach (var field in table.Fields) { unhandledRow.TryGetValue(field.Name, out object obj); if (obj != null) { row.Data[field] = obj; } } return(row); }
public void TestCreateSelectCommandWithCondition() { var sqlQuery = _crudCommandDirector.BuildSelectSpecificRow(_table, 0); Assert.Equal("SELECT * FROM data.Car WHERE gid = '0'", sqlQuery); }