Presenter:Scott Stanfield
The LinqDataSource control can be customized declaritively, as shown in Part 5, or through code by handling the Selecting method.
Click here to go to original video page
The following text is a software generated transcript of the video. Click on a minute link to jump to a location within the video
Minute 0
Of old I just go to talk to you about customizing your link data source with code in part five and one video read for part six is when you some use the link is forced to create queries without writing any code now we re going to customize results with just a little bit of a custom see sharp so I party got this might know our mapping file and if you already see me create one reason every video symmetry had to do it in this case it did pull all of the database files and because honestly looks chemical we hold down the control we don t zoom in and out so let s close that here s my default is PX page with nothing and it lets make it interesting by bringing in a grid view panel options should do that in design mode is here or use a little smart arrow button and on attach it to a data source to link a link data source we talked
Minute 1
Previous video and I ll pretty much choose the defaults know this happens mail the Times s empty turns out you have to compile the project first torture that was try this again necessary habitat to the link data source I know how to configure it or he don t have it and I ll choose the products table only while the defaults there now we have come a lot here and we pull out the columns were not using just make the crew smaller for the screen so this removes light for months now I ve say that he just T shirts working on bringing up the web browser cricket zone about 77 rows so want to do is modify this link data source by hooking into an event that it throws so bring the properties with all to enter switch to a lightning bolt
Minute 2
Undergo selecting the welcome mat and they get to override a form and I m notified when I win the late data sources in the being asked to find in this case to grid view so let s rattled a code how great an instance of my Northwind data contacts as my TV okay and lets it go here and pull the roof I want to wool do is constrain this query to only return the categories of products that are in beverages and seafood noticed is roaming up so we ll create a synthetic category list catalyst equals news coming purchases and seafood kind and salutes create a brand new query P and the these products where he catalyst
Minute 3
Pains contains anything that s in key category to category for this is just one way you d expect of a query under the covers can do some car correlated subquery with a category name matches when those two and see if the select fees now will take the result of a query stick in the result return value or the argument is passed and right here in this link is for select parks he will set eat out result equals or query and shot so I would expect to see fewer results and sure enough we have his hands full category one and eight now behind the scenes was going on offering the SQL query profile which have been running in the background the last query we just executed right here so it s its card at decoder you can see her beverages and seafood are funny all the products and is joined to
Minute 4
Table or your categories based on the that the two players really are to read as the but you can see can what s going on here and it s the point isn t not really understand exact SQL Cisco remote list looks like roughly come back to it so this is really cool watches her not to touch the query underlying query and Morgan touch the source code for go to the grid view and enable paging and sorting that set save it to run this again saw sort by product name and go to page 2 so you can see it s working on page to the square shown 10 runs I go back to the trace you look at the query that was executed to hear the bottom to bit more complex there is DC food and beverages but look at all this other stuff and what it s doing is
Minute 5
On the way we do paging in SQL SQL Server there s this row number concept and you can select over and do a combination techniques here too to do an efficient server side paging but what s what s really nice about this is that you can see a continue and continue to do a declarative level programming by modifying my grid view and essential all we did hear her say allow paging equals true instead of the wizard by the code behind the scenes still worked giving another example lets go in and try to query on how bout of our cuticles Frankie and products what s to I ll all keep that same contains query because that overall limits number of lines were going to get back what went not
Minute 6
Coming from the sky VI emu s visual sorts of VI emulator which I used to have memorized pretty well because him so working with it I like you think you have a keyboard type of outgoing amounts see countless contains everything from product name thoughts and can have a structured outfit is that it category or ago product name type can do a time and then this is this is the key for a minute to create a new selection of on his face or a new and new on the color projections for ticker results in only going to return a specific set of columns in this case I get a product name and about the unit price and will do a calculations of the number of older
Minute 7
Her details account animal to gross gross revenue equal to the order details and I ll stick in a to land a function of these quantity times you price it in this category I think it did on this exact same thing in parts one or three of the video series so the noble but more was going on oil and show you is that you run this and I m not expecting it to work the reason why you go such an expected work because to this auto generate columns falsely to change the truth of the reason why is it we ve created really to a new set of columns that the grid view doesn t know about what a drag grid he wanted down a timely data source it pre populated these columns well in these columns anymore because of what dynamically generate
Minute 8
Mappings with its origin or columns so if that worked the not even close the window and runner should read this before product ID Elian the return productivity my dad well that s unfortunate because it would not work but anyway but I fixed it up here ago so we re getting just these four gods for new columns about the two of them are calculated it turns out I knew that product ID because that s the key sitcom and without bad as you can see a second half before the inquiry s linkage source but overall you seen that we ve been able to programmatically modify the link data source without nothing more than on writing just tiny bit code right here so you can see this are pretty powerful mechanism what s really good about the whole architecture is the fact that
Minute 9
Even though back here in this code it looks like when we do this and this will create the query here return to result the execution of his grace action deferred until it s actually down to the data grid and that s what allows link to do the extra add ons of the paging and sorting mechanism so everything comes together in a deferred mechanism allows this query is very into generating right when it s actually needed and that s your late data source modified with code role
Tuesday, May 27, 2008
Video: How Do I: LINQ to SQL: Custom LinqDataSource
Labels:
custom linqdatasource
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment