UnitOfWorkWrapper provides a strongly-typed interface around dynamically-created UnitOfWork instances. It implements both IUnitOfWorkWrapper and IUnitofWork interfaces with:
Safe property access - All property get/set operations are wrapped in try-catch
Event forwarding - Forwards events from underlying UnitOfWork via reflection
Oracle Forms compatibility - Navigation methods (MoveFirst, MoveNext, etc.)
Validation support - Integration with validation framework
Undo/Redo - Full undo/redo capability
Virtual loading - Support for large datasets with paging
Properties
Property
Type
Description
IsInListMode
bool
Gets/sets whether the UOW is in list mode
IsDirty
bool
True if there are unsaved changes
DataSource
IDataSource
The underlying data source
DatasourceName
string
Name of the data source
EntityName
string
Name of the entity/table
EntityType
Type
The entity CLR type
PrimaryKey
string
Primary key field name
GuidKey
string
GUID key field name (if applicable)
Units
dynamic
The collection of entities
CurrentItem
dynamic
Current record (Oracle Forms compatible)
CurrentIndex
int
Current position (Oracle Forms compatible)
Count
int
Total record count
PageIndex
int
Current page index
PageSize
int
Records per page (default: 10)
InsertedKeys
Dictionary<int,string>
Keys of inserted records
UpdatedKeys
Dictionary<int,string>
Keys of updated records
DeletedKeys
Dictionary<int,string>
Keys of deleted records
DeletedUnits
List<dynamic>
Deleted entity instances
CommitOrder
CommitOrder
Order of operations during commit (DeletesFirst, InsertsFirst, AsTracked)
IsIdentity
bool
Whether primary key is auto-increment
IsLogging
bool
Enable operation logging
UpdateLog
Dictionary<DateTime,EntityUpdateInsertLog>
Audit log of changes
Events
All events are forwarded from the underlying UnitOfWork via reflection:
// Batch update with progress
var result = await wrapper.CommitBatchAsync(
batchSize: 100,
progress: new Progress<CommitBatchProgress>(p =>
Console.WriteLine($"Batch {p.CurrentBatch}/{p.TotalBatches}")),
ct: cancellationToken);
Error Handling
All operations are wrapped in safe execution helpers:
GetPropertySafely - Returns default value on error
SetPropertySafely - Throws on error (setter failures are critical)
ExecuteSafely - Returns default value on error
ExecuteSafelyAsync - Returns default value on async error
ObjectDisposedException is thrown if wrapper is used after Dispose().
Usage Examples
Basic CRUD
var wrapper = UnitOfWorkFactory.CreateUnitOfWork(
typeof(Customer), editor, "MyDb", "Customers", "Id");
// Add
wrapper.New();
wrapper.CurrentItem.Name = "John";
await wrapper.InsertAsync(wrapper.CurrentItem);
// Update
wrapper.MoveFirst();
wrapper.CurrentItem.Name = "Jane";
await wrapper.UpdateAsync(wrapper.CurrentItem);
// Commit
var result = await wrapper.Commit();
if (result.Flag == Errors.Ok)
Console.WriteLine("Success");