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

Cannot use array parameter in SqlBuilder #10

Closed
maxtoroq opened this issue Sep 2, 2013 · 7 comments
Closed

Cannot use array parameter in SqlBuilder #10

maxtoroq opened this issue Sep 2, 2013 · 7 comments
Assignees
Labels
Milestone

Comments

@maxtoroq
Copy link
Owner

maxtoroq commented Sep 2, 2013

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 } })
   ...
colin-young added a commit to colin-young/DbExtensions that referenced this issue Dec 10, 2013
@maxtoroq maxtoroq added this to the v4.4.0 milestone Mar 9, 2014
@maxtoroq maxtoroq self-assigned this Mar 9, 2014
@maxtoroq
Copy link
Owner Author

maxtoroq commented Mar 10, 2014

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
Copy link

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
Copy link
Owner Author

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

@Gillardo
Copy link

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

@maxtoroq
Copy link
Owner Author

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

@Gillardo
Copy link

Same code as at the top of here #39

@maxtoroq
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants