none
Can I safely manipulate the results of an EF query w/o affecting database after assigning to array/list? RRS feed

  • Question

  • WHAT I HAVE:

    Visual Basic 2010, .NET 4.0, Entity Framework 4.0, SQL Expresss

    MY PROBLEM:

    Sometimes after acquiring a full or partial list of entries from an entity (say, using LINQ), one needs to perform changes or manipulations (like sorting) to the results without affecting the database from which they were taken. I wonder: If I assign the results of a LINQ query on an entity to an array/list (using .ToArray/.ToList), can I then manipulate the contents of the array/list without affecting the original entity? Say, if I did--

    ItemList As List(Of EntityType) = (From e In Entity ...).ToList

    --can I then manipulate list ItemList's contents without affecting Entity? If not, what steps must I take to get a safe "isolated" list? (i.e., using a For Each loop to manually copy the query results into an array/list)


    Robert Gustafson



    Monday, March 3, 2014 11:00 PM