Click here to Skip to main content
15,887,328 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am using entity lamda expression to retrieve the data.
Now my one table has other 5 child entities.

What I have tried:

I am using .Include to retrive child entity data.
But i don`t want to retrive all data of child entities.
I want only 2-3 columns from all 5 child entities.
Can any one please help me is that possible?
Posted
Updated 9-Oct-17 13:21pm

1 solution

The best option I have found is to use a ViewModel.
A ViewModel can be used to specify a subset of the table fields and can be populated from your controller

Try the following links for additional information and tutorials;
Part 3: Views and ViewModels | Microsoft Docs[^]
Generic ViewModels in MVC[^]
How to Use ViewModel in Asp.Net MVC with Example - Tutlane[^]

Kind Regards
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900