maxtoroq / DbExtensions

Data-access framework with a strong focus on query composition, granularity and code aesthetics.
https://maxtoroq.github.io/DbExtensions/
Apache License 2.0
227 stars 41 forks source link

Cannot use array parameter in SqlBuilder #10

Closed maxtoroq closed 10 years ago

maxtoroq commented 11 years ago

NOTE: In v6, this is no longer an issue. For more information see SqlBuilder Tutorial: Lists.

e.g.

byte[] data = GetImageData();

db.Affect(SQL
   .UPDATE("images")
   .SET("image = {0}", data)
   ...

Need to workaround parameter expansion, like this:

db.Affect(SQL
   .UPDATE("images")
   .SET("image = {0}", new object[] { new object[] { data } })
   ...
maxtoroq commented 10 years ago

Added SQL.Param method to workaround this issue, e.g.:

byte[] imageData = GetImageData();

var update = SQL
    .UPDATE("images")
    .SET("content = {0}", SQL.Param(imageData))
    .WHERE("id = {0}", id);
Gillardo commented 7 years ago

Cannot find SQL.param in latest code ?? Has it been removed? I am having trouble adding the byte[] array

ArgumentException: No mapping exists from object type System.Int64[] to a known managed provider native type.

maxtoroq commented 7 years ago

SQL.Param was dropped in v6. Arrays are no longer special. To expand an array into a list you must call SQL.List.

Gillardo commented 7 years ago

And this also applies to byte[] when the field is a concurrency field?

maxtoroq commented 7 years ago

No, it shouldn't. Perhaps if you show me some code I can help.

Gillardo commented 7 years ago

Same code as at the top of here #39

maxtoroq commented 7 years ago

Looks like a provider issue. If System.Int64[] is the type of the parameter, looks like the provider is getting the same type but for some reason not liking it.