DapperAOT icon indicating copy to clipboard operation
DapperAOT copied to clipboard

DbString - analyzer and runtime

Open mgravell opened this issue 9 months ago • 2 comments

DbString is a Dapper type that allows metadata to be conveyed for string types.

However:

  • it is allocatey
  • it isn't touched by AOT today
  • what it achieves is the same as DbValue]

Suggestions:

  1. we need to verify that [DbValue] allows the size and type to be conveyed into DbParameter
  2. we should emit a warning to use [DbValue] instead
  3. we should probably treat DbString as a recognized type, and configure things correctly
  4. for this last, I would propose (if any DbString are encountered) writing a helper method into the output (we have some prior art that copies entire files into the output; that would be fine) with a method that takes a DbParameter and DbString (global:: qualified) and does the right things:
  • if the entire DbString is null, just set Value to DbNull
  • set the size if appropriate
  • set the type if appropriate
  • set the value using AsValue, or a (object)value.Value ?? DbNull if easier

The reason we can't put this into the library is that we can't ref Dapper directly because of the Dapper/Dapper.StrongName duality - hence we need to implement it in codegen

mgravell avatar Nov 21 '23 19:11 mgravell