What is the life-cycle of the data-context? Is it the same data-context, or a new one each time? (it should probably be the latter).
If you re-use a data-context, it is obliged to always give you back the same object when ever it seems the same identity. So if it has previously given you the version with 9, it'll keep giving you back that reference even when the underlying data changes.
At the moment, this still does a round-trip; to avoid the round-trip, you need to use:
var obj = ctx.SomeTable.Single(x=>x.Id == id);
i.e. if it already has the object with
Id == id in the local identity cache, it won't perform a databae query at all.
any other construct will do a round trip. There is a fix in 4.0 so that
.Where(x=>x.Id == id).Single() will avoid the round-trip, which should have with query syntax, i.e.
var obj = (from x in ctx.SomeTable where x.Id == id select x).Single();
Are you updating using one DataContenxt while the one you later query from is still alive?
If yes this is the respones you should expect.
If you created a new DataContenxt after the update or the update and the read are being done on the same DataContext you shoud get the right response.
- LINQ Source Code Available
- creating Linq to sqlite dbml from DbLinq source code
- source code for LINQ 101 samples
- c# Linq or code to extract groups from a single list of source data
- Convert string to int in one line of code using LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Linq code to select one item
- How are people unit testing code that uses Linq to SQL
- Strange LINQ To Entities Exception
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- Syntax to execute code block inside Linq query?
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- Best open source LINQ provider
- Linq functions give strange compile error when ambiguous use of IEnumerable - possible workarounds?
- Strange LINQ Exception (Index out of bounds)
- Is there a good source that gives an overview of linq optimizations?
- Does this LINQ code perform multiple lookups on the original data?
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
- LINQ WHERE method alters source collection
- Rewriting a LINQ Expression query to enable caching SQL Execution Plan
- Where can I view LINQ source code?
- Strange behavior of MongoDB LINQ provider for fields called "id"
- Suggestions for designing complex LINQ code
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- Left outer join using LINQ -- understanding the code
- Strange null reference exception in LINQ query with EF
- How to pass LinQ Expressions from F# to C# code
- How to reuse a linq expression for 'Where' when using multiple source tables
- Linq caching data values - major concurrency problem?
- Avoiding code repetition when using LINQ
- Problems trying to use GroupBy with multiple properties using the LINQ Method Syntax
- Subquery with linq
- Printing out the results of my linq query
- Replicating a SQL WITH statement query in Linq to Entities
- Find Date Overlapping in DataTable Using Linq C#
- how to get the value using linq query C#
- How do I use LINQ to obtain a unique list of properties from a list of objects?
- Unit Testing Entity Framework
- Union on empty Enumerable
- calling Expression.Call
- Sort in-memory list by another in-memory list
- Linq to XML Converter
- How is managed the iteration here?
- How to use LINQ remove a subset of list with certain criteria?
- Using a strongly typed method as an argument without specifying parameters
- Creating object from a list by grouping on repeated information
- Not getting Distinct Items when using Linq to List?
- DateDiff alternative in Linq
- linq query to list that adds position of result
- How does IN SQL looks in C# linq