Beispiel #1
0
        public void Execute(IEnumerable <CommandData> commands)
        {
            FieldMap fieldMap = new FieldMap();

            using SyncSession session = new SyncSession(this.Options);

            foreach (CommandData commandData in commands.NotNull())
            {
                Command command = new Command(commandData, fieldMap);

                if (string.IsNullOrWhiteSpace(commandData.CommandText))
                {
                    continue;
                }

                foreach (IDataReader reader in session.Execute(command))
                {
                    TableIdentity      tableInfo = TableIdentity.FromRecord(reader);
                    FieldData[]        fields    = command.GetHeading(tableInfo);
                    MetadataIdentity[] metadata  = fields.Select(f => f?.Attribute).ToArray();

                    var binder = FuncCache.GetFieldDataBinder(metadata, tableInfo);

                    if (reader.Read())
                    {
                        binder(reader, fields);
                    }
                }
            }

            foreach (FieldData fieldData in fieldMap)
            {
                fieldData.Bind();
            }
        }
Beispiel #2
0
        public async Task ExecuteAsync(IEnumerable <CommandData> commands, CancellationToken cancellationToken = default)
        {
            FieldMap fieldMap = new FieldMap();

            await using AsyncSession session = new AsyncSession(this.Options);

            foreach (CommandData commandData in commands.NotNull())
            {
                Command command = new Command(commandData, fieldMap);

                if (string.IsNullOrWhiteSpace(commandData.CommandText))
                {
                    continue;
                }

                await foreach (DbDataReader dataReader in session.ExecuteAsync(command, cancellationToken).ConfigureAwait(false))
                {
                    TableIdentity      tableInfo  = TableIdentity.FromRecord(dataReader);
                    FieldData[]        fields     = command.GetHeading(tableInfo);
                    MetadataIdentity[] attributes = fields.Select(f => f?.Attribute).ToArray();

                    var binder = FuncCache.GetFieldDataBinder(attributes, tableInfo);

                    if (await dataReader.ReadAsync().ConfigureAwait(false))
                    {
                        binder(dataReader, fields);
                    }
                }
            }

            foreach (FieldData fieldData in fieldMap)
            {
                fieldData.Bind();
            }
        }
Beispiel #3
0
            static async Task consumer(AdoHelper helper, DbDataReader reader)
            {
                TableIdentity tableInfo = TableIdentity.FromRecord(reader);

                FieldData[]        fields     = helper.GetHeading(tableInfo);
                MetadataIdentity[] attributes = fields.Select(f => f.Attribute).ToArray();

                var fun = FuncCache.GetFieldDataBinder(attributes, tableInfo);

                if (await reader.ReadAsync())
                {
                    fun(reader, fields);
                }
            }