Skip to content

Instantly share code, notes, and snippets.

View bleroy's full-sized avatar

Bertrand Le Roy bleroy

View GitHub Profile
@bleroy
bleroy / WeekIn.NET.20170502.md
Last active May 1, 2017 21:42
Tips for the Week in .NET
public class POCO
{
public int Answer { get; set; }
}
//...
var db = DbContext.CreateDbContext(connectionString:
"Data Source=.\\SQL;Initial Catalog=tempdb;Integrated Security=True;Pooling=true;Max Pool Size=3000;");
var ids = await db.QueryAsync("select [Answer] = object_id from sys.objects;");
var pocoArray = ids.ToObjectArray<POCO>();
@bleroy
bleroy / WeekIn.NET.20170418.md
Last active May 5, 2017 19:53
Tips for the Week in .NET
JArray largeJson;
// read asynchronously from a file
using (FileStream asyncFileStream = new FileStream(@"large.json", FileMode.Open, FileAccess.Read, FileShare.Read, 4096, true))
{
largeJson = await JArray.LoadAsync(new JsonTextReader(new StreamReader(asyncFileStream)));
}
JToken user = largeJson.SelectToken("$[?(@.name == 'Woodard Caldwell')]");
user["isActive"] = false;
@bleroy
bleroy / WeekIn.NET.20170404.md
Last active April 4, 2017 04:26
Tips for the Week in .NET
using (var browser = new BrowserSession(new SessionConfiguration
{
AppHost = "microsoft.com",
SSL = true,
Driver = typeof (SeleniumWebDriver),
Browser = Drivers.Browser.Firefox,
RetryInterval = TimeSpan.FromSeconds(0.1)
}))
{
browser.FillIn("Attachment").With(@"c:\coypu\bigfile.mp4");