For optimistic concurrency I tried your example at viewtopic.php?f=3&t=38310&p=136147&hilit=xmin#p136147.
The examples throws a NotSupportedException at ctx1.SaveChanges() here:
Code: Select all
using (var ctx1 = new MyContext())
using (var ctx2 = new MyContext())
{
var item1 = ctx1.MyClasses.Where(t => t.FStringField == "text").FirstOrDefault();
var item2 = ctx2.MyClasses.Where(t => t.FStringField == "text").FirstOrDefault();
item1.FStringField = "text_mod";
item2.FStringField = "text_mod";
ctx1.SaveChanges(); // <-- NotSupportedException is thrown.
ctx2.SaveChanges();
}
When I change DatabaseGeneratedOption.Computed to DatabaseGeneratedOption.Identity it runs, but the call to SaveChanges() doesn't change item1.xmin to the new value from the database.
Is there any way to use optimistic concurrency with dotConnect for PostgreSQL and EFCore?
The complete NotSupportedException is:
System.NotSupportedException
HResult=0x80131515
Message=Specified method is not supported.
Source=Devart.Data.PostgreSql.Entity.EFCore
StackTrace:
at Devart.Data.PostgreSql.Entity.m.a(StringBuilder A_0, Int32 A_1)
at Microsoft.EntityFrameworkCore.Update.UpdateSqlGenerator.AppendWhereAffectedClause(StringBuilder commandStringBuilder, IReadOnlyList`1 operations)
at Microsoft.EntityFrameworkCore.Update.UpdateSqlGenerator.AppendSelectAffectedCommand(StringBuilder commandStringBuilder, String name, String schema, IReadOnlyList`1 readOperations, IReadOnlyList`1 conditionOperations, Int32 commandPosition)
at Microsoft.EntityFrameworkCore.Update.UpdateSqlGenerator.AppendUpdateOperation(StringBuilder commandStringBuilder, ModificationCommand command, Int32 commandPosition)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.UpdateCachedCommandText(Int32 commandPosition)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.GetCommandText()
at Devart.Common.Entity.cu.CreateStoreCommand()
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(DbContext _, ValueTuple`2 parameters)
at Microsoft.EntityFrameworkCore.Storage.Internal.NoopExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IReadOnlyList`1 entries)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IReadOnlyList`1 entriesToSave)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges()
at EFCoreTest.Program.Main(String[] args)