Skip to content

Instantly share code, notes, and snippets.

@corruptmem
Created October 25, 2017 09:43
Show Gist options
  • Save corruptmem/f3668ffed7f26a26f0ca333add816f1a to your computer and use it in GitHub Desktop.
Save corruptmem/f3668ffed7f26a26f0ca333add816f1a to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Dapper;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Npgsql;
namespace PgsqlTest
{
[AttributeUsage(AttributeTargets.Property)]
public sealed class PgsqlColumnAttribute : Attribute
{
}
public sealed class MyModel
{
public int Id { get; set; }
[PgsqlColumn]
public string Foo { get; set; }
[PgsqlColumn]
public string Bar { get; set; }
public string Baz { get; set; }
public string Qux { get; set; }
}
public static class Program
{
public delegate string dg(MyModel model);
static async Task Main(string[] args)
{
var myModelType = typeof(MyModel);
var myModelPropInfo = myModelType.GetProperty("Baz");
var x = (Func <MyModel, string>) Delegate.CreateDelegate(typeof(Func<MyModel, string>), null, myModelPropInfo.GetMethod);
var nmm = new MyModel() {Baz = "123"};
Console.WriteLine(x(nmm));
//Console.WriteLine(myModelPropInfo);
//var conn = new NpgsqlConnection(cstr);
//await conn.OpenAsync();
//var z = conn.Query<JObject>("select '[1,2,3]'::jsonb;");
//Console.WriteLine(JsonConvert.SerializeObject(z.Single()));
//JsonConvert.DeserializeObject<List<int>>("[1,2,3]");
//var z = JObject.Parse("{\"a\": [1,2,3]}");
//Console.WriteLine(JsonConvert.SerializeObject(z));
//SqlMapper.AddTypeHandler();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment