Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dapper.Contrib 1.50.0 -> 1.50.4 broke InsertAsync(IEnumerable) #930

Closed
snebjorn opened this issue Jan 30, 2018 · 3 comments · Fixed by #948
Closed

Dapper.Contrib 1.50.0 -> 1.50.4 broke InsertAsync(IEnumerable) #930

snebjorn opened this issue Jan 30, 2018 · 3 comments · Fixed by #948

Comments

@snebjorn
Copy link

I can't quite pinpoint what is going on. But when I update Dapper.Contrib from 1.50.0 to 1.50.4 I get this exception

System.InvalidOperationException : An enumerable sequence of parameters (arrays, lists, etc) is not allowed in this context
at Dapper.SqlMapper.GetCacheInfo(Identity identity, Object exampleParameters, Boolean addToCache) in ...\dapper\Dapper\SqlMapper.cs:line 1686

When calling await _connection.InsertAsync(listOfEntities);.

Anyone else getting this?

My Dapper version is 1.50.4. It works with this version combo:

  • Dapper v1.50.4
  • Dapper.Contrib v1.50.0
@snebjorn snebjorn changed the title Dapper.Contrib 1.50.0 -> 1.50.4 broke InsertAsync<T>(IEnumerable<T>) Dapper.Contrib 1.50.0 -> 1.50.4 broke InsertAsync(IEnumerable) Jan 30, 2018
@d-franklin
Copy link

It's this line that's causing the issue.

https://github.com/StackExchange/Dapper/blob/a213b2aeee66ac0bff327ff19e70516fb629abe3/Dapper.Contrib/SqlMapperExtensions.Async.cs#L133

@bdrupieski
Copy link
Contributor

What are you trying to insert? What does that type look like?

@snebjorn
Copy link
Author

snebjorn commented Feb 13, 2018

This doesn't throw

var list = new List<object>();
await _connection.InsertAsync(list);

This throws

var list = new List<object>().AsEnumerable();
await _connection.InsertAsync(list); // throws

Hmm perhaps I should mention that I made my own adapter around Dapper.Contrib. But it only forwards the call.

// _connection here is of type IDbConnection where as in the above is using my adapter interface.
public Task<int> InsertAsync<T>(T entityToInsert) where T : class => _connection.InsertAsync(entityToInsert);

public Task<int> InsertAsync<T>(IEnumerable<T> entitiesToInsert) where T : class => _connection.InsertAsync(entitiesToInsert);

It shouldn't interferer with Dapper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants