Man, .NET Core 5 be mean and CLEEEAAAN
I’m working on a dynamic “About” type page for this ASP .NET Core 5 blog project and while browsing some bootstrap components for inspiration, saw this card layout and though, you know, I really do dislike having that obnoxious “About me!” page where it’s entirely self centric. What about a page that lists out all of the contributing authors with a tiny bio, a notice about their last activity on the site, and a link to all the published posts they’ve made.
I started with just putting two placeholders down in the raw html page, which looked like this
I then got to work filling in the blanks!
First thing was first, figuring out EntityFrameworkCore. I’d already been able to do basic queries that let’s me iterate through entire tables and query for singular objects. That’s vital bedrock information but nowhere near optimal.
After some playing around, this page provided some vital clues to where I was going wrong: https://docs.microsoft.com/en-us/ef/core/querying/related-data/eager
After I had added a few more fields for the banner, the avatar, the bio, and the position title, and filled out my seeder class, the end result is this glorious masterpiece
More can be done with this page. Indeed there could be some condition that if there’s so few then expand the cards out to fill out the page a bit more. But i like the terse data driven approach to this, it feels deliberate, it feels intentional and clean to me.
For brevity I’m going to share what the source code looks like
First, the route controller:
Second, the Models:
and finally, the Razor template:












