コード例 #1
0
ファイル: QueryHandler.cs プロジェクト: mephistoc/jerrycurl
        public IEnumerable <QueryReader> Enumerate(IEnumerable <QueryData> queries)
        {
            if (queries == null)
            {
                throw new ArgumentNullException(nameof(queries));
            }

            if (this.Options.Schemas == null)
            {
                throw new InvalidOperationException("No schema builder found.");
            }

            using AdoConnection connection = new AdoConnection(this.Options);

            foreach (QueryData queryData in queries.NotNull())
            {
                AdoHelper helper = new AdoHelper(queryData);

                if (string.IsNullOrWhiteSpace(queryData.QueryText))
                {
                    continue;
                }

                foreach (IDataReader reader in connection.Execute(helper))
                {
                    yield return(new QueryReader(reader, this.Options.Schemas));
                }
            }
        }
コード例 #2
0
ファイル: QueryHandler.cs プロジェクト: mephistoc/jerrycurl
        public IList <TItem> List <TItem>(IEnumerable <QueryData> queries)
        {
            if (queries == null)
            {
                throw new ArgumentNullException(nameof(queries));
            }

            if (this.Options.Schemas == null)
            {
                throw new InvalidOperationException("No schema store found.");
            }

            ResultAdapter <TItem> adapter = new ResultAdapter <TItem>(this.Options.Schemas);

            using (AdoConnection connection = new AdoConnection(this.Options))
            {
                foreach (QueryData queryData in queries.NotNull())
                {
                    AdoHelper helper = new AdoHelper(queryData);

                    if (string.IsNullOrWhiteSpace(queryData.QueryText))
                    {
                        continue;
                    }

                    foreach (IDataReader dataReader in connection.Execute(helper))
                    {
                        adapter.AddResult(dataReader);
                    }
                }
            }

            return(adapter.ToList());
        }
コード例 #3
0
ファイル: CommandHandler.cs プロジェクト: mephistoc/jerrycurl
        public void Execute(IEnumerable <CommandData> commands)
        {
            FieldMap fieldMap = new FieldMap();

            using (AdoConnection connection = new AdoConnection(this.Options))
            {
                foreach (CommandData commandData in commands.NotNull())
                {
                    AdoHelper helper = new AdoHelper(commandData, fieldMap);

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

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

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

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

            foreach (FieldData fieldData in fieldMap)
            {
                fieldData.Bind();
            }
        }