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

Possible bug in bulk updating documentation #146

Closed
frankhale opened this issue Jun 14, 2012 · 4 comments
Closed

Possible bug in bulk updating documentation #146

frankhale opened this issue Jun 14, 2012 · 4 comments

Comments

@frankhale
Copy link

I believe I've found a bug in your documentation dealing with bulk updating. I had to change:

var drinks = table.All("WHERE CategoryID = 8");

to

var drinks = table.All("WHERE CategoryID = 8").ToArray();

Because 'drinks' would not reflect the updates made in the foreach loop prior to calling Save.

I also removed two other extraneous ToArray() calls.

Here is the listing with the change:

var table = new Products();
//OH NO YOU DIDN't just pass in an integer inline without a parameter! 
//I think I might have... yes
var drinks = table.All("WHERE CategoryID = 8").ToArray();
//what we get back here is an IEnumerable < ExpandoObject > - we can go to town
foreach(var item in drinks){
    //turn them into Haack Snacks
    item.CategoryID = 12;
}
//Let's update these in bulk, in a transaction shall we?
table.Save(drinks);
@robconery
Copy link
Contributor

Thanks Frank - just so I'm clear: is this a bug that didn't work for you?

@frankhale
Copy link
Author

I tried the code that you had but it didn't work for me. After debugging I noticed that the array being passed into Save was not updated with the values set in the foreach loop.

@deevus
Copy link

deevus commented Jul 18, 2012

This issue happens for me also. Same fix as well.

@robconery
Copy link
Contributor

I believe the docs now correctly deal with ToArray().

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

No branches or pull requests

3 participants