DatabaseExtensionsSubmitChangesAsyncTEntity(DbContext, CancellationToken) Method
Namespace: EWSoftware.EntityFrameworkAssembly: EWSoftware.EntityFramework (in EWSoftware.EntityFramework.dll) Version: 2025.11.12.0
public static Task SubmitChangesAsync<TEntity>(
this DbContext dataContext,
CancellationToken cancellationToken = default
)
where TEntity : class, INotifyPropertyChanged
<ExtensionAttribute>
Public Shared Function SubmitChangesAsync(Of TEntity As {Class, INotifyPropertyChanged}) (
dataContext As DbContext,
Optional cancellationToken As CancellationToken = Nothing
) As Task
public:
[ExtensionAttribute]
generic<typename TEntity>
where TEntity : ref class, INotifyPropertyChanged
static Task^ SubmitChangesAsync(
DbContext^ dataContext,
CancellationToken cancellationToken = CancellationToken()
)
[<ExtensionAttribute>]
static member SubmitChangesAsync :
dataContext : DbContext *
?cancellationToken : CancellationToken
(* Defaults:
let _cancellationToken = defaultArg cancellationToken new CancellationToken()
*)
-> Task when 'TEntity : not struct and INotifyPropertyChanged
- dataContext DbContext
- The data context to use for the operations
- cancellationToken CancellationToken (Optional)
- An optional cancellation token
- TEntity
- The entity type for which to submit changes
TaskA task representing the asynchronous operation.In Visual Basic and C#, you can call this method as an instance method on any object of type
DbContext. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
This will get the changed entities from the data context's change tracker and submit them
accordingly. The state of the entities is also updated to reflect that they are in an unchanged
state after being added or updated or detached if deleted. If the connection is not in an open
state, it is opened temporarily while performing the actions.
if(dataContext.HasChanges())
await dataContext.SubmitChangesAsync<Account>();