This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Reflection; | |
var x = GetParser<Thing>(); | |
var y = GetParser<int>(); | |
static IParser<T> GetParser<T>() | |
{ | |
// specialize for T == Thing | |
if (typeof(T) == typeof(Thing)) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Include nupkgs: Sylvan.Data, Sylvan.Data.Csv | |
using Sylvan.Data; | |
using Sylvan.Data.Csv; | |
int count = 10000000;// controls how many records to write | |
const string file = "dump.csv"; | |
// "invert" the WriteCsvToStream code into a readable stream. | |
using Stream stream = new InvertedStream((stream) => WriteCsvToStream(stream, count)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Data.SqlClient; | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var dbStr = args[0]; | |
var srcTz = args[1]; | |
var dstTz = args[2]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Npgsql; | |
using NpgsqlTypes; | |
using Sylvan.Data.Csv; | |
using System.Collections.ObjectModel; | |
using System.Data.Common; | |
class Program | |
{ | |
static async Task Main() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CsvHelper; | |
using nietras.SeparatedValues; | |
using RecordParser.Extensions; | |
using Sylvan.Data; | |
using Sylvan.Data.Csv; | |
using System.Globalization; | |
using System.Runtime.CompilerServices; | |
var tw = new StringWriter(); | |
tw.WriteLine("A,B,C,D"); |
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AA | |
AAH | |
AAHED | |
AAHING | |
AAHS | |
AAL | |
AALII | |
AALIIS | |
AALS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Threading; | |
using System.Threading.Tasks; | |
sealed class MacOSTextReader : TextReader | |
{ | |
readonly TextReader inner; | |
public MacOSTextReader(TextReader inner) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is a reworking of the CsvFileResult code posted to the CSharp Reddit: | |
// https://www.reddit.com/r/csharp/comments/12sip6r/oom_on_custom_fileresult_streaming_from_queryable/ | |
using Microsoft.AspNetCore.Mvc; | |
using System.Reflection; | |
public class CSVFileResult<T> : FileResult where T : class | |
{ | |
private readonly IQueryable<T> _data; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A C# solution to the PowerShell Excel->JSON conversion described in this blog post: | |
// https://devblogs.microsoft.com/powershell-community/convert-specific-table-of-excel-sheet-to-json/ | |
// Using the Sylvan data libaries. | |
using Sylvan.Data; | |
using Sylvan.Data.Excel; | |
if (args.Length != 3) | |
{ | |
Console.WriteLine("Args: file sheet \"class name\""); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C# 11 and .NET 6+ | |
using Sylvan.Data; // 0.2.12-B0001 | |
using Sylvan.Data.Csv; // 1.2.7 | |
// the schema for the csv data below. | |
var schema = | |
new Schema.Builder() | |
// ID is required! | |
.Add<int>("Id") |
NewerOlder