Linq to SQL, Repository, IList and Persist All

Posted by Dr. Zim on Stack Overflow See other posts from Stack Overflow or by Dr. Zim
Published on 2010-06-01T05:44:30Z Indexed on 2010/06/01 5:53 UTC
Read the original article Hit count: 712

This discusses a repository which returns IList that also uses Linq to SQL as a DAL.

Once you do a .ToList(), IQueryable object is gone once you exit the Repository. This means that I need to send the objects back in to the Repo methods .Create(Model model), .Update(Model model), and .Delete(int ID).

Assuming that is correct, how do you do the PersistAll()? For example, if you did the following, how would you code that in the repository?

  1. Changed a single string property in the object
  2. Called .Update(object);
  3. Changed a different string property in the object
  4. Called .Update(object);
  5. Called .PersistAll(), which would update the database with both changed strings.

How would you associate the objects in the Repository parameters with the objects in the Linq to Sql data context, especially over multiple calls?

I am sure this is a standard thing. Links to examples on the web would be great!

© Stack Overflow or respective owner

Related posts about c#

Related posts about linq-to-sql