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

ObjectReader for AsyncEnumerable #100

Open
cmeyertons opened this issue Sep 29, 2022 · 7 comments
Open

ObjectReader for AsyncEnumerable #100

cmeyertons opened this issue Sep 29, 2022 · 7 comments

Comments

@cmeyertons
Copy link

Any plans for supporting an AsyncEnumerable you can send to SqlBulkCopy.WriteToServerAsync?

Are you accepting contributions? Would be more than happy to help out.

Generally thinking,

  1. Refactor shared bits from ObjectReader
  2. new AsyncObjectReader than accepts IasyncEnumerable instead of Ienumerable
  3. For AsyncObjectReader either make Read throw not implemented to force zero sync-over-async or using System.Linq.Async’s ToEnumerable extension. This would add a new dependency, so would require some thought.
@DerPeit
Copy link

DerPeit commented Oct 26, 2022

To me it seems that @mgravell already implemented this in PR #94.

/cc @mgravell @erwan-joly Is there any particular reason why this is not being merged?

@Dean-NC
Copy link

Dean-NC commented Mar 12, 2024

I could use this also. @mgravell Is your branch safe for us to use, or will you be merging it soon? Thanks.

@Dean-NC
Copy link

Dean-NC commented Mar 18, 2024

I compiled the async branch and it's working fine so far. I'm planning to use it in a new application that has an IAsyncEnumerable.

@mgravell
Copy link
Owner

Dapper.AOT has a fully sync+async AOT implementation of the relevant API here

@Dean-NC
Copy link

Dean-NC commented Mar 18, 2024

@mgravell Thanks for letting me know. I've used Dapper exclusively in my projects for the last 6 years, and use ObjectReader for bulk-copy. All of my projects are now on .NET 8. I knew about Dapper.AOT but have not checked on its progress in a while, and didn't know it had the DbDataReader feature. I'll switch to Dapper.AOT and test it.

@mgravell
Copy link
Owner

@Dean-NC
Copy link

Dean-NC commented Mar 19, 2024

Thanks. I had a difficult time with the TypeAccessorInterceptorGenerator "Not generating any files".
I'm using VS 17.8.6/.NET SDK 8.0.101/Dapper 2.1.37 (DateOnly)/Dapper.AOT 1.0.31
It's a class library. I stripped it down to nothing but 1 model class, and 1 class that had 1 method which called TypeAccessor.CreateDataReader and had [module: DapperAOT]. It still wouldn't generate the accessor. Hovering the mouse over CreateDataReader showed that it knew the type for the accessor: TypeAccessor<MyModel>. Setting build output to diagnostic mode didn't show any reason/clue.

After fiddling with it for hours, closing/re-starting VS numerous times, it finally generated. I never determined why it wouldn't before. It would be good if there was a way to know why. I bulk-loaded 2 models to 2 tables, all good.

I too could use inherited class support as mentioned in: DapperLib/DapperAOT#93
I see it's merged, so I'll just wait for the release.

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

No branches or pull requests

4 participants