I am currently programming game which is using C# connected with Entity Framework.
I have a lot of relationships with tables which are main models used in game. Because of that i have to use a lot of navigational properties of those models.
When i create my viewModel i have code similar to this :
Avatar = new ImageViewModel(company.Entity.ImgUrl);
CountryName = company.Region.Country.Entity.Name;
RegionName = company.Region.Name;
Name = company.Entity.Name;
Money = MoneyViewModel.GetMoney(company.Entity.Wallet);
OwnerName = company.Owner.Name;
OwnerID = company.OwnerID;
Naturally it ends up firing multiple queries when i want to access navigational proprties.
I addressed this problem by using Include in my Controller before passing model to the view model constructor. this is heavily consuming my time because in the end i need to recursively check which navigational properties are needed in my view models and include them manualy in first query.
My question is : Is this code design apropriate? If not then what is correct approach to this kind of problem?
Personally i feel that it will be cumbersome in long term.