https://github.com/halomakes/bigquerymapping
Source generator for working with BigQuery Storage API
https://github.com/halomakes/bigquerymapping
bigquery csharp google
Last synced: about 1 month ago
JSON representation
Source generator for working with BigQuery Storage API
- Host: GitHub
- URL: https://github.com/halomakes/bigquerymapping
- Owner: halomakes
- License: unlicense
- Created: 2022-11-08T19:48:28.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-05T16:01:15.000Z (about 3 years ago)
- Last Synced: 2025-03-03T05:36:14.760Z (over 1 year ago)
- Topics: bigquery, csharp, google
- Language: C#
- Homepage:
- Size: 69.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BigQueryMapper
Source generator utility for converting [BigQueryRow](https://cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryRow)s to your DTO.
## Usage
**Install NuGet packages**
```bash
dotnet add package BigQueryMapping
dotnet add package BigQueryMapping.Generators
```
**Apply attribute to your partial class**
Any property with an accessible setter will be included in mapping. You can specify a column name using a [ColumnAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.schema.columnattribute).
```csharp
using BigQueryMapping
[BigQueryMapped]
public partial class MyRowDto
{
public string SomeId { get; set; }
[Column("some_RiDiCuLoUs_name")]
public string SensibleName { get; set; }
}
```
The souce generator will implement `IBigQueryGenerated` which has a static method `FromBigQueryRow(BigQueryRow row)` that you can use to get your DTO out.
```csharp
var rows = await _bigQuery.ExecuteQueryAsync(sql, parameters, cancellationToken, new());
foreach (var row in rows)
{
yield return MyRowDto.From(row);
}
```