コード例 #1
0
ファイル: UserFullWrite.cs プロジェクト: thiagottt/etl
        public override IEnumerable <Row> Execute(IEnumerable <Row> rows)
        {
            FluentFile engine = FluentFile.For <UserFullRecord>();

            engine.HeaderText = "Id\tName\tAddress";
            using (FileEngine file = engine.To(filePath))
            {
                foreach (Row row in rows)
                {
                    file.Write(row.ToObject <UserFullRecord>());

                    //pass through rows if needed for another later operation
                    yield return(row);
                }
            }
        }
コード例 #2
0
ファイル: WriteUsersToFile.cs プロジェクト: xliang/rhino-etl
        /// <summary>
        /// Executes this operation
        /// </summary>
        /// <param name="rows">The rows.</param>
        /// <returns></returns>
        public override IEnumerable <Row> Execute(IEnumerable <Row> rows)
        {
            FluentFile engine = FluentFile.For <UserRecord>();

            engine.HeaderText = "Id\tName\tEmail";
            using (FileEngine file = engine.To("users.txt"))
            {
                foreach (Row row in rows)
                {
                    UserRecord record = new UserRecord();

                    record.Id    = (int)row["id"];
                    record.Name  = (string)row["name"];
                    record.Email = (string)row["email"];

                    file.Write(record);
                }
            }
            yield break;
        }
コード例 #3
0
        protected override async Task ExecuteYield(IAsyncEnumerable <Row> rows, AsyncEnumerator <Row> .Yield yield,
                                                   CancellationToken cancellationToken = default)
        {
            FluentFile engine = FluentFile.For <UserRecord>();

            engine.HeaderText = "Id\tName\tEmail";
            using (FileEngine file = engine.To("users.txt"))
            {
                await rows.ForEachAsync(row =>
                {
                    UserRecord record = new UserRecord();

                    record.Id    = (int)row["id"];
                    record.Name  = (string)row["name"];
                    record.Email = (string)row["email"];

                    file.Write(record);
                }, cancellationToken);
            }
            @yield.Break();
        }