I'm still digging in and learning .NET, and was wondering if someone can point me in the right direction on something?
Right now, in my Controller, I've got a number of hard-coded calls to some tables within my app's database. Something sort of like this:
if (suppliedTableName == "TableStuff") { var model = await _appDbContext.TableStuff.ToListAsync(); return View(view, model); } if (suppliedTableName== "MyRandomStuff") { var model = await _appDbContext.MyRandomStuff.ToListAsync(); return View(view, model); } if (suppliedTableName== "MySettings") { var model = await _appDbContext.MySettings.ToListAsync(); return View(view, model); }
I'm wondering if there's a way to make it more dynamic? Something more like this:
var model = await _appDbContext.VariableSuppliedToControllerWhenCalled.ToListAsync(); return View(view, model);
Can someone give me a nudge in the right direction?
Thanks! And I have to take a quick minute and let all of you know that I appreciate everyone that has helped me in the past - not sure where I'd be without all of you!