Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add context to ToEntity
  • Loading branch information
petero-dk committed Oct 13, 2022
commit 29d42b2422c99b9eb4d886bd635a6ae1901b464c
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ internal static class TableEntityDynamic
public static TableEntity ToEntity<T>(T model, IStorageContext context) where T : new()
{
if (context as StorageContext == null)
throw new Exception("Invalid interface implemnetation");
throw new Exception("Invalid interface implementation");
else
return TableEntityDynamic.ToEntity<T>(model, (context as StorageContext).GetEntityMapper<T>());
return TableEntityDynamic.ToEntity<T>(model, (context as StorageContext).GetEntityMapper<T>(), context);
}

public static TableEntity ToEntity<T>(T model, StorageEntityMapper entityMapper) where T: new()
public static TableEntity ToEntity<T>(T model, StorageEntityMapper entityMapper, IStorageContext context) where T: new()
{
var builder = new TableEntityBuilder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public partial class StorageContext : IStorageContext
foreach (var model in models)
{
// convert the model to a dynamic entity
var t = TableEntityDynamic.ToEntity<T>(model, entityMapper);
var t = TableEntityDynamic.ToEntity<T>(model, entityMapper, this);

// lookup the partitionkey list
if (!partionKeyDictionary.ContainsKey(t.PartitionKey))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ public partial class StorageContext : IStorageContext
switch (storaeOperationType)
{
case nStoreOperation.insertOperation:
tableTransactions.Add(new TableTransactionAction(TableTransactionActionType.Add, TableEntityDynamic.ToEntity<T>(model, entityMapper)));
tableTransactions.Add(new TableTransactionAction(TableTransactionActionType.Add, TableEntityDynamic.ToEntity<T>(model, entityMapper, this)));
break;
case nStoreOperation.insertOrReplaceOperation:
tableTransactions.Add(new TableTransactionAction(TableTransactionActionType.UpsertReplace, TableEntityDynamic.ToEntity<T>(model, entityMapper)));
tableTransactions.Add(new TableTransactionAction(TableTransactionActionType.UpsertReplace, TableEntityDynamic.ToEntity<T>(model, entityMapper, this)));
break;
case nStoreOperation.mergeOperation:
tableTransactions.Add(new TableTransactionAction(TableTransactionActionType.UpdateMerge, TableEntityDynamic.ToEntity<T>(model, entityMapper)));
tableTransactions.Add(new TableTransactionAction(TableTransactionActionType.UpdateMerge, TableEntityDynamic.ToEntity<T>(model, entityMapper, this)));
break;
case nStoreOperation.mergeOrInserOperation:
tableTransactions.Add(new TableTransactionAction(TableTransactionActionType.UpsertMerge, TableEntityDynamic.ToEntity<T>(model, entityMapper)));
tableTransactions.Add(new TableTransactionAction(TableTransactionActionType.UpsertMerge, TableEntityDynamic.ToEntity<T>(model, entityMapper, this)));
break;
case nStoreOperation.delete:
tableTransactions.Add(new TableTransactionAction(TableTransactionActionType.Delete, TableEntityDynamic.ToEntity<T>(model, entityMapper)));
tableTransactions.Add(new TableTransactionAction(TableTransactionActionType.Delete, TableEntityDynamic.ToEntity<T>(model, entityMapper, this)));
break;
}

Expand Down