IDbConnection is an interface that is defined in the System.Data namespace and allows a class that
inherits from this interface to implement a Connection class, containing a unique session with a data
source. This interface takes a little more effort because classes that inherit from the IDbConnection
interface must also implement all inherited members. The trick is that the application doesn??™t create
an instance of IDbConnection directly; instead, the application should create an instance of a class that
inherits from IDbConnection. In most cases, you are much better off instantiating an instance of the
DataContext and passing a string containing the necessary connection information.
The DataContext has several useful public methods, including CreateDatabase and DeleteDatabase, as
well as CreateQuery, ExecuteQuery, GetQueryText, and SubmitChanges.
The CreateDatabase and DeleteDatabase methods do exactly as their names imply. CreateDatabase
creates a database with the database name taken either from the connection string, the Database attribute,
the name of the file (if the DataContext has been created using a file), or the name of the DataContext
inheriting class if a strongly typed DataContext is used.
Pages:
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360