I want to create a new model object named Movie_Type
in my ASP.NET MVC web application. What will be the differences if I define the navigation proprty of this
There are two possible ways of looking at things:
Is the result stored in memory as part of the object instance?
If you choose ICollection
, the result will be stored in memory - this may not be a good idea if the data set is very large or if you don't always need to get the data. On the other hand, when you store the data in memory, you will be able to modify the data set from your program.
Can you refine the query that gets sent to the SQL server?
This means that you would be able to use LINQ over the returned property and the additional LINQ operators would be translated to SQL - if you don't choose this option, additional LINQ processing will run in memory.
If you want to store data in memory, then you can use ICollection
. If you want to be able to refine the query, then you need to use IQueryable
. Here is a summary table:
| | Refine query | Don't change query |
|-----------------|--------------|--------------------|
| In-memory | N/A | ICollection |
| Lazy execution | IQueryable | IEnumerable |