Ejemplo n.º 1
0
        public async Task <IEnumerable <T> > QueryAsync()
        {
            var columns = FluentEntityAdoHelper.JoinEnumerable(
                _selectedColumns.SelectMany(keyValue =>
                                            keyValue.Value.Select(value =>
                                                                  GetColumnNameWithAs(keyValue.Key, value.Attribute.Name))),
                ", ");
            var sqlCommand = $"SELECT {columns} FROM {_tableName} {_joinCommandBuilder} {_whereHelper.CommandWhere} {_orderCommandBuilder}";
            var result     = await _daoHelper.SelectAsync <T>(sqlCommand, MapObject);

            if (_autoReset)
            {
                Reset();
            }

            return(result);
        }
Ejemplo n.º 2
0
        public async Task Test_Select_SingleMultiple()
        {
            await _fluentEntity
            .InsertInto(new List <GenreMock> {
                new GenreMock {
                    Id = 1, RowVersion = DateTime.Now, Name = "Drama"
                },
                new GenreMock {
                    Id = 2, RowVersion = DateTime.Now, Name = "Horror"
                }
            }).ExecuteAsync();

            var selectResult = await _daoHelper.SelectAsync("SELECT genre.id, genre.name FROM genre WHERE genre.id >= @id", (record =>
                                                                                                                             new GenreMock
            {
                Id = record.GetInt64(0),
                Name = record.GetString(1)
            }), new QueryParameter("@id", 1));

            selectResult.Should().HaveCount(2);
        }