corrections for batch updates to work / treating enum values as strings in DB, and making All() remember it was enumerated #85

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants

-got .Save working...passing collection into params objects[] was putting entire list into object[1] element preventing batch operations from working properly.
-have .All doing a .ToList<> at the end of it because enumerating the 'raw' IEnumerable that Query is returning seems to 'forget' it has been enumerated.
-treating Enums as string for the database(rather than integers). this follows in line with Linq2Sql behavior

Contributor

robconery commented Sep 19, 2011

Thanks for taking the time to do ... whatever you did but I can't tell what you did and moreover the diff is no help. Can you please explain things for me?

ok. corrected the format and updated the file. few things here.

  1. the batch update example on the home page for Massive does not work. The Save method would fail because an array being passed into a params style parameter list would be pushed into the first item in the corresponding object array. this would make the code fail that would build commands from incoming input.
  2. Massive was treating Enum types as integers in the db, however for clarity i changed that to treat enums as strings.
  3. if sql server was set to auto-create a primary key, then the insert statement would fail due to this db constraint as it would instead try to insert the pk itself.
  4. revisiting the existing batch update example, for some reason the elements returned from the call to All() would not actually remember their updated values. trace the examples in the loop and you will see what i mean. to correct this, i force the Enumerable results of All into a ToList() call which allows the result set to be worked with and hold changes made.
Owner

erolnicki commented on Massive.cs in f0aa3dc Sep 20, 2011

improved this to check if the primary key associated with the object is at a 'default' state (and therefore not a real primary key)

Owner

erolnicki commented on Massive.cs in f0aa3dc Sep 20, 2011

when a list is passed into a method with a params style parameter 'list', the incoming list/array/enumerable is pushed into the object[0] element of the parameter 'things'. this complicates things and is one of 2 reasons why the batch update example on the homepage of Massive was not working.

Owner

erolnicki commented on Massive.cs in f0aa3dc Sep 20, 2011

treating Enum types as strings rather than integers. more intuitive when working with DB data.

Owner

erolnicki commented on Massive.cs in f0aa3dc Sep 20, 2011

returning results as .ToList(). for some reason the results are not malleable otherwise.

Owner

erolnicki commented on Massive.cs in f0aa3dc Sep 20, 2011

pulled the multiple GetType() calls out into this line. trading 1 more line of code for some efficiency gains.

Contributor

robconery commented Oct 27, 2011

Going to close this off - it's a bit out of date. If you want to do a pull request in the future that would be grand

@robconery robconery closed this Oct 27, 2011

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