Results 1 to 3 of 3

Thread: LinQ and Lambda

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    60

    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
    please help
    Thanks............

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    60

    Re: LinQ and Lambda

    Thank you so much.........

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width