-
LinQ and Lambda
can any one explain about this topic...
what's the difference between them and which one is the best
and which time or which situations want to use them
some commands are equal i think not sure....
really confused :eek2:
please help
Thanks............
-
Re: LinQ and Lambda
well, they are two different kinds of functionality... so the differences are vast... and I wouldn't say one is better over the other.
They are just simply two features of VB that arrived together. Where you're probably mixing the two, is that functional LINQ uses the lambda feature... but they are not necessarily married to each other.
LINQ is basically a selection syntax command that allows you to pull data out of objects, databases, or other data stores. the format, with some exceptions is very similar to SQL, you have a from clause, a select clause, you can do joins and even aggregates.
there are two styles, select LINQ, which as I mentioned looks a lot loke SQL, and functional LINQ which makes heavy use of lambdas. I find this works best when extracting data from datasets and performing calculations on it.
Lambdas on the other hand are inline defined functions. Whaaa? Yeah I know... it's a way of declaring a function and using it, and then throwing it away. They can be simple, or somewhat complex, but generally they are light-weight and quick. Let's say I had a typed dataset that had a column I needed to up date and I'm updating all the rows to thesame value, I could create a function that took the table as a parameter, loop through it, set the column and then be done... now let's say I need to do that on multiple data tables... would seem silly to create all these different functions that basically do the same thing except take a different datatable type.... especially if it never gets called again.... so the idea is you can use an inline function that will do that for you.... simply call the foreach extension method of the datatable, and give it a lambda function that updates the field for you...
-tg
-
Re: LinQ and Lambda
Thank you so much.........