Skip to content

Instantly share code, notes, and snippets.

View smitty-codes's full-sized avatar

Chris Smith smitty-codes

  • San Diego, CA
View GitHub Profile
@smitty-codes
smitty-codes / CSharpAvroSchemaless.cs
Last active May 15, 2020 22:11
Apache.Avro schemaless files
View CSharpAvroSchemaless.cs
// Invoice class generated from a avro protocol file (.avpr) using the nuget package Apache.Avro.Tools
Invoice invoice = new Invoice();
invoice.invoiceno = 123;
// ...(more invoice properties set here)
// set destination
string filePath = String.Format(@"C:\AvroInvoices\{0}.avro", invoice.invoiceNo);
// write avro schemaless file - logic adapted from https://stackoverflow.com/q/36793657/194872
SpecificDatumWriter<Invoice> writer = new SpecificDatumWriter<Invoice>(Invoice._SCHEMA);