Database ExtensionsHas Changes Method
This extension method is used to see if a data context has any unsaved changes.
Definition
Namespace: EWSoftware.EntityFramework
Assembly: EWSoftware.EntityFramework (in EWSoftware.EntityFramework.dll) Version: 2025.11.12.0
True if the data context's change set has any inserted, updated, or deleted items waiting to be submitted, false if not.
Assembly: EWSoftware.EntityFramework (in EWSoftware.EntityFramework.dll) Version: 2025.11.12.0
C#
public static bool HasChanges(
this DbContext dataContext
)VB
<ExtensionAttribute>
Public Shared Function HasChanges (
dataContext As DbContext
) As BooleanC++
public:
[ExtensionAttribute]
static bool HasChanges(
DbContext^ dataContext
)F#
[<ExtensionAttribute>]
static member HasChanges :
dataContext : DbContext -> bool Parameters
- dataContext DbContext
- The data context to check
Return Value
BooleanTrue if the data context's change set has any inserted, updated, or deleted items waiting to be submitted, false if not.
Usage Note
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).Example
C#
if(dataContext.HasChanges())
dataContext.SaveChanges();