I've several tables including the 'combining' in many-to-many relationship. I want to make now Insert operation.
I heard about DeferredLoadingEnabled in linq2sql and I know it's connected with this topic, but I don't quite know how it works?
For example
[ClientTable]: ClientId, ClientName, Phone, Age
[CityTable]: CityID, CityName, Country
[ClientCityTable]: ClientCityID, ClientID, CityID
Could someone show it at this simple example or provide some nice link?
It has absolutely nothing to do with inserting.
Deffered loading means that Linq-2-sql will only go the database as soon as you actually use the linked tables.
In your example, if you load a [ClientCity] the Cityname will not be loaded untill you actually use it.
So if you do:
The CityTable entity will not be loaded until you do something like:
Only at that time, the CityTable is loaded from the db.
This can be great if you only occassionaly need the city but it can lead to N+1 queries as soon as you loop to all your CityTables
There are plenty of links around. E.g: http://msdn.microsoft.com/en-us/library/bb399393.aspx
or http://www.west-wind.com/weblog/posts/2009/Oct/12/LINQ-to-SQL-Lazy-Loading-and-Prefetching