I have a list.
ViewBag.Meters = db.Query("SELECT * FROM Meters");
And an Id
3
How do I get Meters.Name from ViewBag.Meters, where Id = 3
As simple as possible, so that my view code is neat.
(My view currently shows only foriegn keys (ids), rather than its actual name)
If I wanted to do what you were doing I would create a simple utils function such as
Then inside the view just place a using for the namespace of the Utils class and then call the function
I have an enourmous Utility class that provides all kinds of flexibility when needing to return data in a clean way. Hopefully this is as efficient as I believe it to be.
Without more specifics its hard for me to tell if that would suite your application, elaborate more and I’d be glad to help.