none
Instantiate L2S DataClassesDataContext - does it really load the whole database? RRS feed

  • Question

  • I have created a DataClassesDataContext.dbml mapping all the tables and stored procedures in my database. When I instantiate the DataClassesDataContext object, it seems to load all the records from the database into the object.  Is this really what is happening?

    I have set a watch on the object and then viewed it during a debug session of my process. In the watch, I can view each of the tables and see that the Results View contains an object for each of the records in the database.

    I expect this to be a very large database, so I don't want this behaviour.

    I am using ...
        Visual Studio 2008 SP1
        SQL Server 2008 Express

    Thanks,
    John

    Friday, January 8, 2010 11:56 AM

Answers


  • When you view a table from the debugger, it needs to load the entire table since that is what you are asking to look at.  The tables are not loaded when the data context itself is created, and if you build queries on those tables, those queries will only run on demand and pull only from the tables you ask for.
    • Marked as answer by John T. Angle Friday, January 8, 2010 1:57 PM
    Friday, January 8, 2010 1:00 PM

All replies


  • When you view a table from the debugger, it needs to load the entire table since that is what you are asking to look at.  The tables are not loaded when the data context itself is created, and if you build queries on those tables, those queries will only run on demand and pull only from the tables you ask for.
    • Marked as answer by John T. Angle Friday, January 8, 2010 1:57 PM
    Friday, January 8, 2010 1:00 PM
  • Thanks very much.
    Friday, January 8, 2010 1:58 PM