I'm using the entity framework code first CTP4.
Is it possible to lazy load non navigation properties like you can in NH 3.
A common example would be having a table containing a binary column. I only want to retrieve this column's data when I explicitly ask for that property in my code e.g. image.ImageData
Thanks Ben
Lazy loading means delaying the loading of related data, until you specifically request for it. When using POCO entity types, lazy loading is achieved by creating instances of derived proxy types and then overriding virtual properties to add the loading hook.
Lazy loading is delaying the loading of related data, until you specifically request for it. It is the opposite of eager loading. For example, the Student entity contains the StudentAddress entity.
Entity Framework supports three ways to load related data - eager loading, lazy loading and explicit loading.
Ugly workaround:
public static void Main()
{
IEnumerable<MyTable> table;
using (Entities context = new Entities())
{
var buffer =
context.MyTable
.Select(myTable => new
{
Id = myTable.Id,
OtherColumn = myTable.OtherColumn
})
.ToArray();
table = buffer
.Select(t => new MyTable
{
Id = t.Id,
OtherColumn = t.OtherColumn
});
}
}
This will not select the rest of the fields.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With