Presenter:Mike Taulty
In previous VB9 sessions we've explored various features that facilitate LINQ. In this session we'll try and look at how LINQ actually works with those features to add extensible querying support into the language.
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
Hello and welcome to Scotland at its session is one of a series of short videos were to invite owners looking out on Disney s official studio net framework minus m Tolkien I work in the developer and platform group in Microsoft in the UK and this is one of a series of videos about Visual Basic nine exchanges coming in the future of the language under the banner of language integrated query or link with looked at a lot of different features and VB 9 and what I found it in this video is just piece them together to show how some of them come together to enable the single language integrated query and sign the official studio 2005 and I have them a preview of the link technologies and all gunners build a simple classical person person has a first name and last name and an age simple properties and in model here always got he is an explicitly tight list of people so that explicitly tight
Minute 1
To be talked about in the previous session and object initialises to create three entries in that list for three people is as simple as that now because this was project was created as a link project have got the CTP with the compiler I can go ahead and do some links style querying of the state in which it is very simple syntax here and explore more complete syntax and subsequent sessions but here I want to say is perhaps we can declare ourselves something of first names are as declare that is i e innumerable offspring would try to be explicit at the moment are to say that equal to from p in people with weapons select he got first name and will likely be some sort at the formatting of that but we can do is that so declare name as strange and was safer each would have put us in one liners with us do it here
Minute 2
Featuring the string of first names but a and console write line that name would only name of their animal sellers got a runner and we get the expected results know that the recession is really not to look too much into these language features because you look to them before and is not the surgical and didn t dwell greatly on the link syntax here because I thought about that in subsequent sessions illustrated to work out how the language features in the foot that NCB nine make this kind of syntax possible how is this actually working how does this from p and people select either a first name I should translate into some code that we can execute so let s start by breaking authority to as with resolution of interior describes the properties on the project will grab the references and play with the incident known
Minute 3
Faces somebody remove some of these I don t think after using at the moment was just as any others really to remove sundown here as well so shamelesslyis a lot imported by default handlers go ahead and build and noticeably an interesting error we get the selectors method is not a member of the list of person so clearly DVD compiler is trying to take this select clause at using here and turn it into a method on the datatype that the using here which is list of person and no such method exists on list of person now we know from previous sessions that we could make an ethical select that he had to exist honest person by the
Minute 4
Extension effort to let go ahead and build an extension at to put up with a solution will add a new class and here will call this my extensions and will put this into acold my extensions drop in class and their annual are never actually discuss to say that it is an extension on class in Sudan and fix thehere and would have been extension method on here so that public shared function will call they select which is the key word were to give it people and list of person and will have a return a listed string and by the go ahead of answer that this is an extension as well
Minute 5
Buffalo orders will return nothing but a six and I stress let s go back to module and must go ahead and import my extensions my extensions and is revealed in their notice were getting a different error the compiler seems to find select method on extension so is mapping this syntax little select method on extension from the looks of it has got the wrong list of parameters such an interesting week in which we passed and essentially the thing that we wanted to extend by the compiler is not happy without one something else so lucky or with any original code and would guess that the compiler is probably interested in having some kind of method which should take a person and produce a string
Minute 6
Connolly Waller doing him a transforming person objects into the strength so it s about a extension of us take a stab in the dark and have a public delicate function colour converter it takes MP has person and returns of strength and let s guess that the second parameter here to a select method should be common vows converter so not only do we take BM as converter rather not only do we take the list we take a function that can do a conversion for us and that s good built and were in business so we can see that we just build a method that satisfies the link syntax in this specific case will make this ordinary physical on for what would it so much discomfort and more code and hear what would we do perhaps what we do is dim and names of the list of strain
Minute 7
Was a freak show but so if he known as person in the people then we can go and goal names add what we had here were political conversion route to lives of p and are finally return names first unlike code we consider that s working with the interesting thing get about that is whether this conversion routing come from that glance took a break point he Impreza five as if we can then get rid of that window and a step in working the step to hear as their stepping in going on there but clearly the compiler is calling us with a conversion routine that somehow goes from a person to a string it is interesting and if we discover that the bid of reflecting from second with
Minute 8
Deceiver in module the compiler has generated anonymous method for as we never saw this and if you look at it you consider what it does goes from a person to a string by returning person Thursday and there is the reason why we couldn t step into that function so that s managed in the compiler generated that for advisers having to do any work whatsoever so what we built so far is really nice and useful if we are dealing with persons and strings but were little as 34 in and so if we go back to nodule here we have full well into the night and I didn t have to say that this was a list of person at all and that would be fine and I didn t have to say I wanted to select first man last night I could have said that what I wanted to select a new type with the first name on the last day minute and with the go ahead in safer reach in article
Minute 9
F first is now bad neighbours at cause results of each article and results we can go ahead arrived out first name and last man if some are really just using Ireland knowledge all anonymous types if you like never that we ve got is that the extension has rebuilt to select deals with persons and strains it doesn t deal with whatever their state ideas and whatever the state attack is and so on and so forth to Hagley Garland demerits I thought we built work is essential we can do is we can change our function here delegate the score converter will really call converter that
Minute 10
With them converter off will call its see and be thought that it was going to pass they seemed to the slim Scot CSCE and listen this routine will return D so converted a swiftly narrow size converter that was if we can generate excellent method so other in a select that it will have again off see comedy all of it is all that will pass and Aaron and income in less surrealist see would like to pass the converter of sea comedy and will do it the go ahead return but it are reviews of this tip is used by innumerable and said it was bit more generic footpaths and innumerable of steel return and innumerable or 50 so it is slowly
Minute 11
Do now sadly missing up in a particular case at call this converted will create a list of Dean and 23 she less than intriguing in the income and must go ahead and is too converted ads musical the conversion routine with entry analyst return converted holiday forgot are right that I compile an we can compile a thought we just don t mistake converter is merely generic rather going from a person to string it goes from any taxi to any currently without how it is that became a celebrity in and edit generic rather than taking a list of people returning a list of strains in outtakes and I numeral collection of sea and uses the conversion routine to governors
Minute 12
Today to return the nine numeral collection of day and specifically in the method we could use a list in order to be innumerable so they go back and is run code at this point we should go to see that we get our first error last names for on here but the centre will be done as it taken an array of anonymous type because of elements into it with on a select to create a new anonymous type and gives back a list of those things analogous to that list and enumerating appointments in their but important thing is that we used our own select method which we wrote generically over here to do that so hopefully at the moment you get an idea of how select can be made to work until in terms of the language features we seen earlier and also that the Internet namespace is reflex where select is identified from s concrete select is not the only operator we have in link is just one of a number we do not overtly vital where laws are so
Minute 13
People aged bigger than 18 and if we look at the way we are right now we re back to what we had before we don t have currently on implementation daywear method so let s go ahead as if we can build aware method to that accent of a glance fan of delicate 20th function at all the selection is kindly on grammar tries again going to take the see and where to return ebullient so as a selection function does some object has some criteria let s go ahead and build another extension method sewers have public share function where will price rises again run to have an article incoming as I innumerable of sea and also the return valley from this will be
Minute 14
I innumerable of sea should go ahead and done bodies onto online here e that function although to do here is the real go ahead and create ourselves as others am going as list of sea eagles knew this was seen as return at the end of the function Anas gopher each would offer each ban this is going to be entry and see in incoming we need to decide whether to add it to the outgoing lesson arts in the 19 second parameters which are clearly missed out we also need a selection that all the selector as selection of sing to admit that as well as one of the device okay if so
Minute 15
It are all entry then what will do is add that to the outgoing list of Premier the function was returning a growing list A Z you go through the incoming lists even much as a criterion of those return as the outgoing list and we now try to build awareness of social and see if we can compile always a logical extension attributes on others go ahead and add an extension attributes to insist that fixes a problem for us is just part of thehas built so now we can see if the gun run buses on the right at the first mention of applied wherefores and we get joined Jim because Joe and Jim are those over the age of 18 and hopefully you can now see how the select method is being implemented had
Minute 16
Their method is being implemented you know that feeding is creating anonymous functions of these things here and passing them to methods are essential letters to make that work and that this is compulsory name spaces so in my case you re currently using my own extensions here but if I wonder I can stop time of playing around if you like and try to deconstruct the whole thing I thought that using the standard ones come with link to get rid of the simple statement that it causes Knoxville to compile and we add in the import system and query the sequence rebuild and when her back using the standard link implementations of wear and select and also as it happens they also have implications in things like group by and so on and so force which I build all of us in the session is trying to illustrate how these things come together solely to regret this and that in the future you know how it works and you don t feel as any kind of magic going on justice and rivalry soon in the session
Minute 17
Purpose of the session was really to try and bring together some of the other language features that we ve discussed previously things like anonymous types implicit tightening extension methods and so on in VB 9 to talk about how they come together to make the language integrated query feature work so what what is it that underpins link in the surgery went out and showed how we could build our own select method unaware methods to go ahead and carry on building more of those kind of things to implement that link pattern and we showed how those collects extension methods to get into something extra like that work but ultimately we could see how we could build our own versions of those things know that we could build one can understand handsomely at article 1 already we certainly don t think I select them where they were cast functions by the VB compiler and the VB compiler is magically created these functions that the selection that did the work laws and so on and so forth so
Minute 18
Again the purpose of assessing minister was that a link in VB 9 is not magic you can understand how it works it s not rocket science and that is very nearly magic so the effect is magical but it s not on my something that you can t understand where can you go to a more information on the VB 9 and language integrated query over the site of an MSDN insulin there on the screen and off that site you ll find a document that talks about the changes in the VB 9 language that forthcoming about the cities are not finished yet things could change and if you feedback on this particular session feel free to mail me on his mind upholds the Microsoft com the councillors and council watching the session and abstract
Click here to go to original video page
Wednesday, July 23, 2008
Video: VB9 - Pieces of LINQ
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment