DapperLib / DapperAOT

Build time tools in the flavor of Dapper
Other
349 stars 19 forks source link

DbString - analyzer and runtime #89

Closed mgravell closed 1 week ago

mgravell commented 8 months ago

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

However:

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:

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

DeagleGross commented 3 months ago

questions: 1) what does it mean "[DbValue] allows the size and type to be conveyed into DbParameter" (I can see both of them have System.Data.DbType member + DbParameter can handle strings (which DbString are))? Why is DbParameter in the context here? 2) where is the code that copies entire files into the output?

mgravell commented 3 months ago
  1. when passing some member .Foo into the DB, we do that via a parameter; by default we can only guess as to the type and other properties - but sometimes the details matter, so this tribute allows the .Size and .DbType of the parameter object to be controlled more explicitly

2 do you mean this? https://github.com/DapperLib/DapperAOT/blob/main/src/Dapper.AOT.Analyzers/CodeAnalysis/Writers/InterceptorsLocationAttributeWriter.cs#L24