>> Hello I'm Bill.
>> My name is Mika.
>> Thanks for watching our previous series with
Scott and Kendra on object-oriented programming C#.
This series is all about LINQ. So what is LINQ?
>> Yeah. So LINQ, it's in the name,
it stands for Language Integrated Query.
The cool thing about LINQ is once you know LINQ,
you can use it for any data structure.
So you can use it for XML documentation,
arrays, SQL databases. It's pretty sweet.
>> Collections, whatever things out for Microsoft.
Others can use it, right?
>> Yes. Cool.
>> All right. So let's look at this using
Try.NET which is a tool that we built
that helps you explore different libraries in LINQ.
So in the description, you're going to see a LINQ to
our dotnet/try-samples repo which is the one I'm showing here.
Then in the README,
there is the installation instructions to go
ahead and get started with the.NET Core SDK,
and something called dotnet try which is a.NET global tool.
All the instructions are right here.
>> Right. So first, you need.NET Core SDK.
Then once you have that, you can go ahead and clone
that dotnet/try-samples off this GitHub repository.
>> I've already done that. So we're going
to start with the 101 LINQ Samples,
and then you just have to run a tool called dotnet which
you learned about in the earlier series and then do dotnet try.
That's going to start up a new browser window for me
with all of these wonderful LINQ Samples.
Once it loads up the browser,
we're going to get a new local host window on our space,
and there we have a 101 LINQ Samples and our friendly.NET bot.
We're not going to run all these. These are crazy.
>> Yeah. LINQ is powerful.
So let's start with one of the most common queries.
>> All right.
>> Click the Restriction operators LINQ.
>> All right. So restriction operators, the way our keyword.
So I get this window and I've got a ''Run'' button.
So now when I click ''Run'',
I get this other Window that
shows here's the results from our query.
So this query if we look at,
it's looking for lower numbers from num in numbers like you said
just like SQL in some ways where num is less than 5.
That's that restriction operator
for a where and then we select the number.
>> Yes. So let's change that to a list.
>> Right. So we said we could do this with anything.
So I'm going to change that numbers to a new list of int.
We'd have to change it on this side.
That was one of the things we learned about
earlier in our object-oriented.
That's the only change you have to make.
>> Yeah. So you don't have to change the query at all.
>> Yeah.
>> It just works pretty well.
>> Then we'll just run it again, and once again.
There we go. All right.
So let's look at a couple of others here.
>> So let's look at
the properties of an object and the input sequence.
>> Okay. So if I take this pretty next one,
we've got a list of products.
So that's some object-orientated collection that we're building.
I'm looking at with that where clause here
on anything where there's nothing in stock.
So that should print everything that we've sold out.
Those were the popular ones.
There, it's just looking at
same sequence and it's printing
out everything about that particular product.
So what else can we do with this where method?
>> Let's look at the last page which
shows the syntax for a where clause.
>> Okay.
>> Yeah.
>> This one does look different.
>> Yeah. It's using a where method instead of the where keyword.
>> That's right. So this one uses a where method.
It actually does the same thing
that we saw in these other ones that
we were doing with this where clause and a keyword.
What's different is the language compiler
translates one into the other
and there's slightly different feature here.
If you look this where clause or this where method,
we've got two different arguments.
One is that index that says,
it's this position of that element in the sequence.
So if we run this one,
what we're going to see is,
in addition to the strings up above that 0,
1, 2, 3 with the letters,
it also knows the corresponding number
the number 0 and the number 1.
It is printing out any words that are shorter than the value.
So like the number 6 printed out has
fewer letters than six, and so on and so forth.
That's everything with the where method.
>> Great. So let's look at
that projections operator LINQ right there.
>> Right there? All right. Now around the select,
we saw some of these,
but I'm going to just do one quick.
So if we look I've got one here where we're
taking things are numbers and are mapping from one to another.
So our first select
just grabbed everything from our input sequence.
Here you can see I'm taking something from a numbers collection.
When I'm selecting is the corresponding string from another array.
So select lets us project into some other collection.
That's what we see in a lot of quick spot every query.
We will see some a where to filter something and
some select to have some output sequence.
>> So that was an intro to LINQ,
and we also showed you how to use the our Try.NET tool ,
and we also shows you all of the 101 LINQ examples.
Next, we're going to talk about the LINQ query syntax.
>> See you then.