Possible bug in bulk updating documentation #146

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

Comments

Projects
None yet
3 participants
@frankhale

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

This comment has been minimized.

Show comment Hide comment
@robconery

robconery Jun 20, 2012

Contributor

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

Contributor

robconery commented Jun 20, 2012

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

@frankhale

This comment has been minimized.

Show comment Hide comment
@frankhale

frankhale Jun 20, 2012

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.

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

This comment has been minimized.

Show comment Hide comment
@deevus

deevus Jul 18, 2012

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

deevus commented Jul 18, 2012

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

@robconery

This comment has been minimized.

Show comment Hide comment
@robconery

robconery Jul 19, 2012

Contributor

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

Contributor

robconery commented Jul 19, 2012

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

@robconery robconery closed this Jul 19, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment