Marten: Bulk Insert Exception when Document type configured with Optimistic Concurrency

Created on 14 Nov 2016  路  3Comments  路  Source: JasperFx/marten

System.ArgumentNullException was unhandled by user code
HResult=-2147467261
Message=Value cannot be null.
Parameter name: expressions
ParamName=expressions
Source=System.Core
StackTrace:
at System.Linq.Expressions.Expression.RequiresCanRead(Expression expression, String paramName)
at System.Linq.Expressions.Expression.RequiresCanRead(IEnumerable1 items, String paramName) at System.Linq.Expressions.Expression.Block(IEnumerable1 variables, IEnumerable1 expressions) at System.Linq.Expressions.Expression.Block(IEnumerable1 expressions)
at Marten.Schema.BulkLoading.BulkLoader1..ctor(ISerializer serializer, DocumentMapping mapping, IdAssignment1 assignment)
at Marten.Schema.DocumentSchema.b__19_0T
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory)
at Marten.Schema.DocumentSchema.BulkLoaderForT
at Marten.DocumentStore.bulkInsertDocumentsT
at Marten.DocumentStore.BulkInsertT
at CustomerManager.MainWindowViewModel.BulkInsert() in D:\ps\marten2\poc\m2\x\CustomerManager\MainWindowViewModel.cs:line 203
InnerException:

    private void BulkInsert()
    {
        var randomCustomers = GenerateRandomCustomers();

        App.Store.BulkInsert(randomCustomers, batchSize: 50);
    }

    private Customer[] GenerateRandomCustomers()
    {
        return Enumerable.Range(1, 100)
            .Select(x => new Customer {FirstName = "Sarah", LastName = x.ToString(), Age = x}).ToArray();
    }

Document type class:

[UseOptimisticConcurrency]
public class Customer : INotifyPropertyChanged
{
    private int _id;
    private string _firstName;
    private string _lastName;

    public int? Age { get; set; }

    public int Id
    {
        get { return _id; }
        set
        {
            _id = value;
            OnPropertyChanged();
        }
    }

    public string FirstName
    {
        get { return _firstName; }
        set
        {
            _firstName = value;
            OnPropertyChanged();
        }
    }

    public string LastName
    {
        get { return _lastName; }
        set
        {
            _lastName = value;
            OnPropertyChanged();
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}
bug

All 3 comments

@jason-roberts I'll take a look at this later today, thank you for the repro steps.

@jason-roberts I've got a local test that reproduces it.

Got it. The fix will be in v1.2.3 later today. This was clearly a permutation that we missed in testing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mhabibal13 picture mhabibal13  路  5Comments

mhov picture mhov  路  5Comments

lahma picture lahma  路  4Comments

tonykaralis picture tonykaralis  路  7Comments

jeremydmiller picture jeremydmiller  路  6Comments