Linq object Persistence

Posts   
 
    
dpanet
User
Posts: 14
Joined: 31-Oct-2006
# Posted on: 12-Apr-2008 20:35:08   

I've been playing around with the new Linq2LLBL code for the past week, and I have been wondering , how can I presist "Linqed" object?. I can't seems to cast the var collection to LLBL Entity Collection. Am I missing something, or the Linq2LLBL is meant for querying entities only?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39797
Joined: 17-Aug-2003
# Posted on: 13-Apr-2008 10:38:13   

(please post linq to llblgen pro posts in the forum for linq to llblgen pro : http://www.llblgen.com/TinyForum/Threads.aspx?ForumID=40 )

You can cast the query to ILLBLGenProQuery simple_smile

ILLBLGenProQuery q = (ILLBLGenProQuery)(from c in metaData.Customer select c);

ILLBLGenProQuery has an execute method which returns an entitycollection. (you can also enumerate it to execute it)

If you don't want to cast, you can also do: var q = // query

List<SomeEntity> results = q.ToList();

and then when you want to save them: EntityCollection<SomeEntity> toSave = new EntityCollection<SomeEntity>(); toSave.AddRange(results);

Frans Bouma | Lead developer LLBLGen Pro