From the course: LINQPad Essential Training

Use the DataContext

- [Instructor] Remember that when we created the database connection LINQPad create a data context. Each of the tables shown here is represented by a class. So let's use one of these tables in my editor. So I'll add a new query. I'll choose a C# statements. I'll choose my active connection. And now I should be able to work with these tables. Let's start with shippers. That's a small table. So I'll type in shippers. As I get IntelliSense, I get a dropdown list of items. Let's try that again. I'll do a shippers, press tab to finish typing, and then I'll do dot dump. And then I'll execute the query. I get back a table, the shippers table, three rows and three columns. This is nice. I don't have to open a connection and instantiate the shipper's class. It's ready to use. Well, let's try this again with a different table. Let's work with orders, We execute the query. Once again, I get back table full of information and it says at the top, there is the first 1000 items. So it's capped at 1000 and this is changeable, but by default, it caps it at 1000 rows. Now you can change this by going to this arrow and choosing view all rows in grid. Now it's using the grid view, and this gives me 1078 rows. So I can see all the data now. Plus the benefits we get from the grid is I can sort by clicking on the column headers, and it's also editable. So I can click on an order and then click on edit data, make the changes to this data and then save it back to the database.

Contents