Member-only story

Database in c#— how does I do again?

Russell Hammett Jr. (Kritner)
4 min readJan 5, 2019

--

Photo by Kevin Ku on Unsplash

It’s been a fair amount of time since I’ve done anything in the database, as at my job I’m working strictly in c# — no database, no front-end. With the government shut down (again! well oiled machine!) I’m not working at the moment, so onto learning on stuff! I wanted to do something with a database, and I’ve gone done and forgotten how to work with them it’s been so long!

I’ve used EF previously, but in this case I wanted to go a bit old-school. I threw together a little abstraction, which… seems… to work…? Maybe I can improve on this as I go, or if nothing else help someone else with it, or myself down the line. Feedback appreciated! :)

A few things are needed for working with a db connection:

  • Connection string — the thing that specifies where and how to connect to the database
  • DB Connection — the actual database connection
  • DB Command — the command(s) to run against the database (include parameters and returns)
  • There’s probably more, but that should be sufficient for my need

Connection string

There’s a fair amount to connection strings — keeping them in the code, in configuration files, in environment variables, probably more. In my case I wanted to store them in a configuration file that…

--

--

Russell Hammett Jr. (Kritner)
Russell Hammett Jr. (Kritner)

Written by Russell Hammett Jr. (Kritner)

Just a boring Application Developer/Dad. I enjoy gaming, learning new technologies, reading, and potentially other stuff. That’s about it.

No responses yet