Are you getting the, "" exception? The problem is that linq2sql wants to check to make sure it should modify the column before it actually modifies it. I usually don't care as much and am perfectly happy updating the entire row so I put the
UpdateCheck = UpdateCheck.Never named parameter in my
[Column(UpdateCheck = UpdateCheck.Never)]
Then, when I want to save the item, I just do this:
Table<TEntity> da = MyDataContext.Context.GetTable<TEntity>(); if (entity.Id > 0) da.Attach(entity, true); else da.InsertOnSubmit(entity); da.Context.SubmitChanges();
I think you may be running into the default Optimistic Concurreny behavior in LINQ to SQL (and I believe that LINQ to Entities work the same way).
Unless told otherwise, just before you update a row, it issues a SELECT statement against the previous values of all columns in the row to see if someone else modified them while you kept them in memory.
However, it sounds like it doesn't know how to compare two Binary instances.
If this is the case, you have two options:
- Use a more explicit version of Optimistic Concurrency by identifying the row version based on a designated timestamp row (preferred)
- Disable Optimistic Concurrency
Here's the documentation for Optimistic Concurrency for LINQ to SQL.
Just step back a second - how are you comparing these variables?
Are you computing a hash for the images? Comparing the hashes is much better than comparing the images byte for byte.
- linq2sql image saving problems
- LINQ Source Code Available
- .NET 4 Code Contracts: "requires unproven: source != null"
- creating Linq to sqlite dbml from DbLinq source code
- source code for LINQ 101 samples
- LINQ2SQL Any(), NOT EXISTS Problems
- Problems with converting a C# code to VB.net
- List or Array of String Contain specific word in Html Source Code
- c# Linq or code to extract groups from a single list of source data
- Saving image to database as varbinary, arraylength (part 2)
- Convert string to int in one line of code using LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Value cannot be null. Parameter name: source
- Linq code to select one item
- C# - code to order by a property using the property name as a string
- How do I find the text within a div in the source of a web page using C#
- Roslyn failed to compile code
- Entity-framework code is slow when using Include() many times
- The data source does not support server-side data paging
- How are people unit testing code that uses Linq to SQL
- Entity Framework, Code First and Full Text Search
- What does this C# code with an "arrow" mean and how is it called?
- How to resolve Value cannot be null. Parameter name: source in linq?
- The source contains no DataRows
- Could not find an implementation of the query pattern for source type 'System.Data.Entity.DbSet'
- How to count the number of code lines in a C# solution, without comments and empty lines, and other redundant stuff, etc?
- Is there an IEnumerable implementation that only iterates over it's source (e.g. LINQ) once?
- Entity Framework 6 Code First Custom Functions
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- How to avoid OrderBy - memory usage problems
- How to compare a string column to a number (as a decimal) in Linq
- Answer Right in Front of Me? (Generic.List requires a model item of type Generic.IEnumerable Error)
- Can't get Sum() working in Northwind example
- Getting attributes from same-named XDocument elements using LINQ
- Filling collection A according to collection B
- Get a value from XML?
- Linq where list contains one of list
- Executing a Stored Procedure from EntityFramework - Code First
- Linq, using ToLookup to project values to different named variables
- LINQ Date formatting not allowed to group by a formatted date YearMonth
- Why pass func<T> to constructor rather than T?
- The union of the intersects of the 2 set combinations of a sequence of sequences
- Get MAX date per day and return all rows with those dates
- Linq Cast<T> with System.Type
- Using LINQ Query
- CollectionAssert failed to do exact match - need best approach
- im not able to apply my LINQ SYNTAX statement to my MVC view
- C# LINQ Find List Inside Another List, Better way to code this than a foreach loop
- Updating a list by changing all its elements
- Linq query with in clause and max