Skip to content

PostgreSQL BulkUpdate action thowing: System.ArgumentNullException: Value cannot be null. (Parameter 'key') #97

@eymenkhater

Description

@eymenkhater

Hello there!
Trying to execute BulkUpdate action but getting the following error:

fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request.
System.Exception: An error occured while retrieving the InformationSchemaTable information. See the inner exception for details.
---> System.ArgumentNullException: Value cannot be null. (Parameter 'key')
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value)
at System.Linq.Enumerable.ToDictionary[TSource,TKey](List1 source, Func2 keySelector, IEqualityComparer1 comparer) at System.Linq.Enumerable.ToDictionary[TSource,TKey](IEnumerable1 source, Func2 keySelector, IEqualityComparer1 comparer)
at .(Boolean , String[] )
at .()
at Z.BulkOperations.BulkOperation.()
--- End of inner exception stack trace ---
at Z.BulkOperations.BulkOperation.()
at Z.BulkOperations.BulkOperation.Execute()
at Z.BulkOperations.BulkOperation.BulkUpdate()
at Z.Dapper.Plus.DapperPlusAction.Execute()
at Z.Dapper.Plus.DapperPlusActionSet1.AddAction(String mapperKey, DapperPlusActionKind actionKind, TEntity item) at Z.Dapper.Plus.DapperPlusActionSet1.DapperPlusActionSetBuilder(DapperPlusContext context, IDbConnection connection, IDbTransaction transaction, String mapperKey, DapperPlusActionKind actionKind, TEntity item, Func2[] selectors) at Z.Dapper.Plus.DapperPlusActionSet1..ctor(DapperPlusContext context, IDbConnection connection, String mapperKey, DapperPlusActionKind actionKind, TEntity item, Func2[] selectors) at Z.Dapper.Plus.DapperPlusExtensions.BulkUpdate[T](IDbConnection connection, String mapperKey, T item, Func2[] selectors)
at Z.Dapper.Plus.DapperPlusExtensions.BulkUpdate[T](IDbConnection connection, T item, Func`2[] selectors)

The method

   public async Task<bool> BulkUpdateAsync(List<ProductItemStock> productItemStocks)
    {
        DapperPlusManager.Entity<ProductItemStock>().Table("ProductItemStocks").Identity(q => q.Id).Ignore(q => q.StoragePath);
        using (var connection = await _postgreSQLDbConnectionFactory.CreateAsync())
        {
            connection.BulkUpdate(productItemStocks);
        }
        return true;
    }

Details of object

public abstract class _Domain<TKey> : IDomain<TKey>
{
    public TKey Id { get; set; }
    public bool IsDeleted { get; set; }
}

public class ProductItemStock : _Domain<int>
{
    public ProductItemStock() { }
    public ProductItemStock(int productItemId, int storagePathId, int stock)
    {
        this.ProductItemId = productItemId;
        this.StoragePathId = storagePathId;
        this.Stock = stock;
    }
    public int ProductItemId { get; set; }
    public int StoragePathId { get; set; }
    public int Stock { get; set; }
    public int ReservedStock { get; set; }
    public StoragePath StoragePath { get; set; }
  }

I tried the update action with Dapper.Contrib and was able to successfully update.

The object values:

Screen Shot 2021-07-29 at 18 30 03

Packages which I using:
Z.Dapper.Plus version 4.0.9
Npgsql version 5.0.7

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions