Click here to Skip to main content
15,355,133 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi got a project that used LinqToSQL for database access and is now being converted to Entity Framework Core. Most conversions are ok but have come across this one that I am having trouble with...what happens if you have a db conflict on save. The existing code is:
VB
Catch cex As ChangeConflictException
                        Dim sb As StringBuilder = New StringBuilder
                        For Each o As ObjectChangeConflict In ldb.ChangeConflicts
                            Dim metatable As Mapping.MetaTable = ldb.Mapping.GetTable(o.Object.GetType())
                            sb.AppendFormat("Table name: {0}", metatable.TableName)
                            sb.AppendLine()
                            For Each col As MemberChangeConflict In o.MemberConflicts
                                sb.AppendFormat("Column name : {0}", col.Member.Name)
                                sb.AppendLine()
                                sb.AppendFormat("Original value : {0}", col.OriginalValue.ToString())
                                sb.AppendLine()
                                sb.AppendFormat("Current value : {0}", col.CurrentValue.ToString())
                                sb.AppendLine()
                                sb.AppendFormat("Database value : {0}", col.DatabaseValue.ToString())
                                sb.AppendLine()
                                sb.AppendLine()
                            Next
                            o.Resolve(RefreshMode.KeepChanges)
                            errorOccurredFlag = True
                        Next

the errors are coming up on :
ldb.ChangeConflicts and
ldb.Mapping
which don't exist in the EF dbContext.

Is this still the correct way to record the errors?

What I have tried:

looking up Mapping & changeconflicts in entity framework core but all references apply to system.data.linq
Posted
Updated 17-Feb-22 5:42am
Comments
Gerry Schmitz 16-Feb-22 22:30pm
   
You're not showing anything useful; like the dbContext / entity definitions.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900