Notes on things a (hopefully) useful collection of knowledge

All things


Dotnet interactive as a rails-console replacement csharp

The tool I miss most when not using ruby-on-rails (which I use at my day-job) is the rails console. My main use for the console is to write queries in the same ORM language as the rest of my application. For example, I might drop into the rails console to see the raw output of a query like Course.where('start_date < DateTime.now - 1.year'). Or, if I need to create some fake data, I could drop into another console and run something like Course.last.update(start_date: DateTime.now - 2.year). Both of these would be easy enough to do in SQL, but I find it more convenient to use the application’s ORM and have access to any helper functions that I’ve already written.

Recently, I’ve tried to approximate this workflow using dotnet interactive, and I’ll describe that setup below. The finished result can be found here(github).

Notebook example

Read More…

Experiments & Architectural Process architecture

It sometimes takes working on an application with a bad architectural design to realize that you never want to work on such a project again. But, how does a programmer make sure their application doesn’t become that project?


Configure Await csharp

Reading through a asp.net core project, I came across number of calls that looked like this:

int affectedRows = await this._context
    .SaveChangesAsync()
    .ConfigureAwait(false); // ME: what does this do?
return affectedRows;

I dug into what this was actually doing by reading this blog:

  • await uses a custom callback strategy based on the calling context
  • ConfigureAwait(false) ignores the custom strategy.