Data Modeling. Data Context

3.1. DataContext

3.1.1. What does the DataContext class do?

            The DataContext class handles the communication between relational database and LINQ and holds a database connection.

The DataContext class uses metadata to generate SQL code. The DataContext also calls commands and tracks changes in the entity class in the database.

 

Example:

 

    [Database(Name = "AdventureWorks")]

    public class AdventureDBContext : DataContext

    {

        public AdventureDBContext(string connString) : base(connString) { }       

    }

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s