I had the same problem and it turned out the issue was due to overriding Equals on the mapped class. My Equals method was only comparing the primary key field which was an identity field. Of course when the objects are new, all identities are 0.So when InsertAllOnSubmit was called, it thought that all new objects were the same and basically ignored every one but the first.
Not quite sure why the 2nd variation doesn't work, however, shouldn't the last one be: dbc.Property. InsertallOnSubmit(properties); dbc.SubmitChanges(); Edit For the second loop try: foreach (Property prop in properties) { var newProp = new Property(); newProp = prop; dbc.Property. InsertOnSubmit(newProp); } dbc.SubmitChanges(); For the last solution try: dbc.Property.
InsertAllOnSubmit(properties.ToList()); dbc.SubmitChanges().
Yeah, of course. Copy&Paste error on the last example :) – Michael Barth Jul 2 '09 at 14:16 Do you get any errors? – James Jul 2 '09 at 14:24 No errors.
I've added two screenshots to my original post. As you can see, with the first method all properties get IDs (the numbers in squared brackets ). On the second screenshot, only the first property gets an ID.
I have absolutely no idea what's wrong since the provided code is the only thing that's different in both screenshots! – Michael Barth Jul 2 '09 at 14:33 Possible bug in the LINQ code? – James Jul 2 '09 at 14:36 Maybe that's it... I couldn't find anything else that's wrong.
– Michael Barth 6 May8 at 5:58.
I am having the same problem. I wonder if it is related to . Net3.5 SP1 because I'm sure this was working before.
But I'm not sure the problem is precisely correlated with the SP1 upgrade.
Then that's two of us using . NET 3.5 with SP1 where it doesn't work, maybe three: stackoverflow. Com/questions/1171111/… – Michael Barth Aug 19 '09 at 5:58.
As other users are having the same strange behaviour, I've reported the issue as a bug to Microsoft: https://connect.microsoft. Com/VisualStudio/feedback/ViewFeedback. Aspx?
FeedbackID=483711.
1 Alas, I could not reproduce the bug at home and the ticket was closed as the Linq team couldn't reproduce it either. :/ – Michael Barth Dec 8 '09 at 23:03.
I encountered this problem a few minutes ago. My issue was that the list I sent to InsertAllOnSubmit() was full of objects that originated from a single instance of mappedClass. I was modifying the members depending on the instance of the view model I wanted to add to the database and then re-adding the instance to the list.
Seems like a newbie mistake but it could be something to check on if anyone is still having this problem!
My Equals method was only comparing the primary key field which was an identity field. Of course when the objects are new, all identities are 0. So when InsertAllOnSubmit was called, it thought that all new objects were the same and basically ignored every one but the first.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.