Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

LINQ DataContext class in depth


  • Please log in to reply
2 replies to this topic

#1 hurricanesoftwares

hurricanesoftwares

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 11 August 2008 - 04:56 AM

Introduction

Whenever someone asks me about the DataContext I always refer to it as the “brains” of Linq to SQL, why? Because it is. It is responsible for the translation of Linq to T-SQL, and the mapping of the results (rows) of that query to objects, and so much more.

If you run any codegen tool (SqlMetal, or Linq to SQL file (VS Orcas designer)) you always get a class that derives from the DataContext class. The DataContext can be equated to a database, in that it contains a series of tables (normally this is implemented as a property that returns a Table), and sprocs (methods calls that invoke underlying sprocs at the DB layer).
Note: The DataContext can also handle other SQL Server features like views, and table functions etc.
What’s so special about the DataContext class?

Most notably the DataContext takes some Linq code and generates the appropriate T-SQL statement for that query; if that query returns rows then the DataContext object will take care of mapping those rows to objects.

Read More at hurricanesoftwares.com in .net Category
  • 0

#2 whoiga

whoiga

    CC Newcomer

  • Just Joined
  • PipPip
  • 15 posts

Posted 11 August 2008 - 11:58 AM

I think more people would find your threads if they were in the C# Tutorial forum, but this is some good stuff to know. I've not yet delved into LINQ throughout my C# advances, but the time will come.
  • -1

#3 hurricanesoftwares

hurricanesoftwares

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 11 August 2008 - 11:38 PM

Thanks, how can i post this is C# Tutorial now.
  • 0




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download