Issue Details (XML | Word | Printable)

Key: DNET-400
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Jiri Cincura
Reporter: Dennis
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
.NET Data provider

Optimistic concurrency doesn't works: no OptimisticConcurrencyException is thrown

Created: 16/Nov/11 12:04 PM   Updated: 18/Jul/17 10:29 AM
Component/s: Entity Framework
Affects Version/s: 2.6.5
Fix Version/s: None

Environment: Entity Framework 4.1 (Code First), Firebird 2.5.1
Issue Links:
Duplicate
 


 Description  « Hide
How to reproduce the bug:

1) Create POCO entity class:

public class TestEntity
{
    public int Id { get; private set; }
    public string Name { get; set; }
    public long? ObjectVersion { get; private set; }
}

2) Configure this class with code first.

2.1) "Id" must be an identity property:

Property(obj => obj.Id)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

2.2) "ObjectVersion" must be a computed concurrency token:

Property(obj => obj.ObjectVersion)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed)
.HasColumnName("ObjectVersion")
.IsConcurrencyToken(true);

3) Create Firebird database:
3.1) one table, corresponding to the entity type;
3.2) the sequence to generate values for "Id" column and the trigger (before insert) to set values of "Id" column;
3.3) the sequence to generate values for "ObjectVersion" column and the trigger (before insert/update) to set values of "ObjectVersion" column;

4) Run test:
4.1) create first instance of the context, load any TestEntity entity from the database;
4.2) create second instance of the context, load [b]the same[/b] TestEntity entity from the database;
4.3) change "Name" property of entity, loaded via first instance of the context and save changes. "ObjectVersion" property will be incremented.
4.4) change "Name" property of entity, loaded via second instance of the context and save changes. "ObjectVersion" property will be set to null. No OptimisticConcurrencyException will be thrown, although it must be.

Remark: changing the type of "ObjectVersion" property to non-nullable Int64 brings to an exception, but this is materialization-related exception (trying to assign null to a non-nullable property). To throw OptimisticConcurrencyException, this query:

EXECUTE BLOCK (
p0 BLOB SUB_TYPE TEXT = @p0, p1 INT = @p1, p2 BIGINT = @p2)
RETURNS (
"ObjectVersion" BIGINT)
AS BEGIN
UPDATE "TestEntity"
SET "Name" = :p0
WHERE (("Id" = :p1) and ("ObjectVersion" = :p2))
RETURNING "ObjectVersion" INTO :"ObjectVersion";
SUSPEND;
END

must set correctly rows affected.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.