Skip to content

Instantly share code, notes, and snippets.

View jgsierra's full-sized avatar
🏠
Working from home

jgsierra

🏠
Working from home
View GitHub Profile
@jgsierra
jgsierra / Program.cs
Created September 10, 2019 13:40 — forked from DanielSWolf/Program.cs
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
using System;
using System.Threading;
static class Program {
static void Main() {
Console.Write("Performing some task... ");
using (var progress = new ProgressBar()) {
for (int i = 0; i <= 100; i++) {
progress.Report((double) i / 100);
@jgsierra
jgsierra / SQL-To-DataTable.cs
Created September 10, 2019 14:19 — forked from hanssens/SQL-To-DataTable.cs
[C#] SQL Query to Databable to CSV
// Simple example for
// 1.) Read a sql server query to datatable;
// 2.) Export it to .csv
class Program
{
static void Main(string[] args)
{
var connectionString = @"data source=bla bla bla";
var selectQuery = "select * from my-table;";
@jgsierra
jgsierra / ReflectionUtilities.cs
Created September 10, 2019 14:25 — forked from riyadparvez/ReflectionUtilities.cs
Reflection utilities for C#. Get all fields, constructors, methods and properties
/// <summary>
/// Utilties for reflection
/// </summary>
public static class ReflectionUtils
{
/// <summary>
/// Get all the fields of a class
/// </summary>
/// <param name="type">Type object of that class</param>
/// <returns></returns>
@jgsierra
jgsierra / GenericAsyncRepository.cs
Created September 10, 2019 15:27 — forked from george2giga/GenericAsyncRepository.cs
Async generic Repository
public class BaseRepository<T> : IBaseRepository<T> where T : class
{
protected DbContext _context;
/// <summary>
/// The contructor requires an open DataContext to work with
/// </summary>
/// <param name="context">An open DataContext</param>
public BaseRepository(DbContext context)
{
@jgsierra
jgsierra / Class1.cs
Created September 10, 2019 15:46
Async
public static async Task TareaAsync()
{
var piedra = Task.Run(() =>
{
Thread.Sleep(3000);
});
var papel = Task.Run(() =>
{
Thread.Sleep(3000);
});