0

I've read about ways to synch my SQL database with my C# code, and it looks like the DataContext object is the way I'm going to go.

After having read up on what it can do, I find myself still slightly confused on its exact capabilities. For instance, once set up, does the DataContext linked to my SQL database contain a property for each table? And does that table object then contain a list of items, each of which holds the data for each table entry?

In addition, I'm not sure how to instruct it to generate me the code (since I've read that it does generate the necessary objects). How is this achieved?

0

3 Answers 3

3

The Gu (Scott Guthrie) has an excellent article series about Linq to Sql that introduces this concept: http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx

Good luck!

Sign up to request clarification or add additional context in comments.

Comments

1
"does the DataContext linked to my SQL database contain a property for each table"
 YES you will be able to accesss all the table and properties, 
 that you have used in your datacontext (.dbml) file

Anyway, please read this article about LINQ TO SQL. Also there are some good video tutorial about ASP.NET 3.5 LINQ TO SQL

Hope this help

Comments

0

What have you tried so far?

There are two ways to generate the code:

  • In Visual Studio, on your project, add a new item of type "LINQ to SQL classes". Then drag-and-drop the tables you want in your project onto the drawing space. This is the most simple, but there is no support for refreshing the model if you change the database.
  • Use the commandline tool SqlMetal.exe to generate the classes.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.