Linq to Object vs. Linq to LLBLGen Pro

Posts   
 
    
EdL
User
Posts: 51
Joined: 01-Mar-2010
# Posted on: 27-Jul-2010 22:46:04   

May be a dumb question but I'm full of them...

What are the advantages of using Linq to LLBLGen Pro directly vs calling up a collection of entities, converting it to an array and using standard Linq to Object? (Keeping in mind that the collection will likely already be filtered.)

And... what magic is going on behind the scenes to populate the LinqMetaData sequences? I'm concerned about performance if I touch a data entity with millions of entries.

Both of these seem to work...

//=================================================

        // Linq to Object test... start
        // ... Cast Collection as Array
        BookCollection books = new BookCollection();
        books.GetMulti(null);  // not recommended for large data table
        BookEntity[] _books = books.ToArray();

       var query =
           from book in _books
                select new { book.Title, book.Isbn, book.Price};

        //Linq to Object test... end

        //Linq to LLBL Gen Pro... start
        LinqMetaData metaData = new LinqMetaData();
        var q = from b in metaData.Book
                select new { b.Title, b.Isbn, b.Price };
        //Linq to LLBL Gen Pro... end

       //Win Display... (toggle as needed)
        dataGridView1.DataSource = q.ToList();

//===============================================

Thanks All,

Ed

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Jul-2010 05:00:44   

Hi Ed,

LINQ2LLBL is written in top of LLBLGen Pro framework classes so you can fetch anything in almost every way in both LLBLGen normal fetch and in LINQ2LL. So they both are kind of equivalent. Now with LINQ2Objects you can query in-memory objects. You can achieve the same if you use DynamicLists, or EntityCollections and then Linq2Objects, or just Linq2Llbl. So it's up to you.

David Elizondo | LLBLGen Support Team