mgravell / fast-member

Automatically exported from code.google.com/p/fast-member
Apache License 2.0
1.02k stars 137 forks source link

ObjectReader for AsyncEnumerable #100

Open cmeyertons opened 1 year ago

cmeyertons commented 1 year ago

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 commented 1 year ago

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 commented 6 months ago

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

Dean-NC commented 5 months ago

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 commented 5 months ago

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

Dean-NC commented 5 months ago

@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 commented 5 months ago

see https://aot.dapperlib.dev/bulkcopy

Dean-NC commented 5 months ago

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: https://github.com/DapperLib/DapperAOT/issues/93 I see it's merged, so I'll just wait for the release.