Skip to content

Commit e298009

Browse files
author
electricessence
committed
2 parents fa4f9de + 1defba8 commit e298009

1 file changed

Lines changed: 46 additions & 5 deletions

File tree

README.md

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The provided expressive command classes allow for an expressive means to append
1212

1313
Extensions are provied to create commands from connection factories.
1414

15-
### Example
15+
##### Example
1616

1717
```cs
1818
var result = connectionFactory
@@ -26,6 +26,8 @@ var result = connectionFactory
2626

2727
## Asynchronous
2828

29+
End-to-end asynchronous methods suffixed with `Async`.
30+
2931
When using the SQL Client, asychronous methods are available as well as `.ToTargetBlockAsync<T>(target)` and `.AsSourceBlockAsync<T>()` Dataflow methods.
3032

3133
## Extensions
@@ -49,14 +51,53 @@ var myResult = await cmd.ToListAsync(transform);
4951

5052
In order to keep connection open time to a minimum, some methods cache data before closing the connection and then subsequently applying the transformations as needed.
5153

52-
#### `Results<T>()`
54+
#### `Results<T>()` and `ResultsAsync<T>()`
55+
56+
Queues all the data. Then using the provided type `T` entity, the data is coerced by which properties intersect with the ones available to the ```IDataReader```.
57+
58+
Optionally a field to column override map can be passed as a parameter. If a column is set as `null` then that field is ignored (not applied to the model).
5359

54-
Synchronously queries (pulls all the data). Then using the provided type `T` entity, the data is coerced by which properties intersect with the ones available to the ```IDataReader```.
60+
##### Examples
5561

56-
#### `Retrieve()`
62+
If all the columns in the database map exactly to a field: (A column that has no associated field/property is ignored.)
63+
```cs
64+
var people = cmd.Results<Person>();
65+
```
5766

58-
Synchronously queries (pulls all the data). Returns a `QueryResult<Queue<object[]>>` containing the requested data and column mappings. The `.AsDequeueingMappedEnumerable()` extension will iteratively convert the results to dictionaries for ease of access.
67+
If the database fields don't map exactly:
68+
69+
```cs
70+
var people = cmd.Results<Person>(
71+
(Field:"FirstName", Column:"first_name"),
72+
(Field:"LastName", Column:"last_name")));
73+
```
74+
or
75+
```cs
76+
var people = cmd.Results<Person>(
77+
("FirstName", "first_name"),
78+
("LastName", "last_name"));
79+
```
80+
or
81+
```cs
82+
var people = cmd.Results<Person>(new Dictionary<string,string>{
83+
{"FirstName", "first_name"},
84+
{"LastName", "last_name"});
85+
```
86+
87+
#### `Retrieve()` and `RetrieveAsync()`
88+
89+
Queues all the data. Returns a `QueryResult<Queue<object[]>>` containing the requested data and column information. The `.AsDequeueingMappedEnumerable()` extension will iteratively convert the results to dictionaries for ease of access.
5990

6091
#### `AsSourceBlockAsync<T>()`
6192

6293
(Fully asynchronous.) Retuns a Dataflow source block. Then asynchronously buffers and transforms the results allowing for any possible Dataflow configuration. The source block is marked as complete when there are no more results. If the block is somehow marked as complete externally, the flow of data will stop and the connection will close.
94+
95+
### `AsSourceBlockAsync<T>()` versus `ResultsAsync<T>`
96+
97+
Depending on the level of asynchrony in your application, you may want to avoid too much buffering of data.
98+
99+
`AsSourceBlockAsync<T>()` is fully asynchronous from end-to-end and can keep total buffering to a minimum by consuming (receiving) results as fast as possible, but may incur additional latency between reads.
100+
101+
`ResultsAsync<T>()` is fully asynchronous from end-to-end but returns an `IEnumerable<T>` that although has fully buffered the all the data into memory, has deferred the transformation until enumerated. This way, the asynchronous data pipeline is fully complete before synchronously transforming the data.
102+
103+
Both methods ultimately are using a `Queue<object[]>` or `ConcurrentQueue<object[]>` (Dataflow) to buffer the data, but `ResultsAsync<T>()` buffers the entire data set before dequeuing and transforming the results.

0 commit comments

Comments
 (0)