I am coding a MVC 5 internet application, and have a question in regards to using IQueryable.
If I retrieve a set of DbSet objects as an IQueryable, and I do not reference some of the properties in each DbSet object, are the values for these properties retrieved when using an IQueryable? Is this the advantage of using IQueryable as opposed to IEnumerable?
I am trying to determine the most efficient way of retrieving values from many DbSet objects where I am not referencing each property in each DbSet object.
Thanks in advance.
EDIT
How about in this situation:
If I have a model as follows:
public class TestModel
{
[Key]
public long Id { get; set; }
public string name { get; set; }
public string value { get; set; }
}
And I retrieve a DbSet of the above object as follows:
IQueryable<TestModel> testModels = await db.testModels(t => t.name.Equals("Test"));
And I iterate through this above IQueryable, retrieving the name
property, are the Id
and value
values ever retrieved from the database?
EDIT2
How about in this situation:
If I retrieve some TestModels as an IQueryable, and then iterate through them, then call the exact same code where the IQueryable has the same name, are two transactions made to the database?
>` not a `Task>`. The code you say you have won't compile.
– Servy Mar 31 '15 at 14:32