I am creating graphic application and where the user can import the graphic data from a SQL Sever database. This application should be capable of handling at least 100,000+ entities. The idea to load the data faster is to load the visual data while opening the database file and non-visual data will be loaded on demand. So, the problem which I am facing is with the data loading from database using Entity Framework.
Each entity has a visual and a non-visual data associated and following is an example of one of the entity:
class Polyline
{
Guid ID {get; set;}
PolylineGeometry PGeometry {get; set;}
PolylineAttribData PAttribData {get; set;}
}
class PolylineGeometry
{
List<Point3D> PointCollection {get; set;}
}
class PolylineAttribData
{
Image ImageData {get; set;}
}
My context class is as follows:
class GeometryData : DbContext
{
DbSet<Polyline> Polylines {get; set;}
}
So, when we create the database context or the geometry data initially only the ID is loaded into polyline and PGeometry & PAttribData is not loaded. So, how do I load this data?
Thank You,
Pankaj
I think you must set Navigation Properties (refering to other entities) as virtual.
Then, wether you use lazy loading : the related entities will be loaded “on demand”, as far as your context is not disposed.
Or you can load them explicitely when needed, using
Load()You can find a good article about lazy, eager, explicit loading, pros and cons here:
http://msdn.microsoft.com/en-us/magazine/hh205756.aspx