❔ How to deal with property’s that need data from a database?
I have a Blazor page where I want to display a Company’s rating which is the average of its location ratings. The problem is, I only store the locationIds on the company, not all the data. The best, botched solution I’ve come up with is doing company.Rating = company.GetRating() on initialization (I need the mongo service from the Blazor page to even get it); I can’t remove the Rating property because you can put as async method in html.
I feel like a better solution might lie in Lazy initialization or something. I really don’t know though, hence why I’m here.
I’m also currently “cluttering” the db of Companies with a Rating property that is always 0 (I get it on demand)
1 Reply
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.