Don't call one of your types Object that is a seriously bad idea; you will regret it... pick a different name... (or System etc) Are you sure the error isn't actually on the line above ( dataContext. Objects etc)? Unfortunately, you don't show any of the code relating to dataContext (for example, could it have become null ), and you don't indicate if (for example) you have added any partial methods to the data-context or entity, or have any events.
I would expect the problem to be in one of those areas.
Don't call one of your types Object - that is a seriously bad idea; you will regret it... pick a different name... (or System, etc). Are you sure the error isn't actually on the line above (_dataContext.Objects. Etc)?
Unfortunately, you don't show any of the code relating to _dataContext (for example, could it have become null), and you don't indicate if (for example) you have added any partial methods to the data-context or entity, or have any events. I would expect the problem to be in one of those areas.
1 Ah, but Marc, using names like that is excellent code obfuscation. No need for any pesky post-compilation obfuscators that way. Characters with accents and dots that are not prominent in coding fonts can be used to make it nearly impossible to detect... :) namespace System { public class objẹct { } } – KristoferA - URL1 Oct 7 '09 at 6:33 @KristoferA- more like an excellent way to turn your code into a entry on daily WTF.
@Marc- +1 for highlighting what a bad idea this is! – RichardOD Oct 7 '09 at 6:51 @RichardOD I was being sarcastic... :) – KristoferA - URL1 Oct 7 '09 at 7:20 This code occurs in my "repository" and in the constructor of it I have it create an instance of the DataContext from my DBML: private DataClassesDataContext _dataContext; public SQLServerMMRepository() { _dataContext = new DataClassesDataContext(); } The error thrown appears on the line: _dataContext.SubmitChanges(); not: _dataContext. UserRelationshipInstances.
InsertOnSubmit(result); I hear you on the capital Object thing I'm doing but I don't think that's the problem here. Why would my datacontext become "not a reference" after repeated calls? – vealer Oct 7 '09 at 14:47 I still don't have this resolved.
Any thoughts? What I think my problem is is that I want to to transform, convert, cast, whatever the DBML Objects returned into DIFFERENT classes and have those classes also have extension methods that pull different views from the database. Creating an instance of my repository and of the business objects seems to make the DataContext choke.
Any ideas on architecture for me? – vealer 1 Oct3 at 23:45.
I've been tearing hair out for a couple of hours now. I thought it was because the result.Name value can be null but I don't think that anymore. It seems like somehow the dataContext is getting closed?
But in Debug Mode I check the status of the connection and it's "Open" after the error occurs. I'm using the repository pattern and ASP.NET MVC. The result object (new Object()) is an instance of a LINQ DBML auto-generated class that also has a partial class that I created with a single extension method attached.
I don't see how the extension to the class could be causing the problem. I'm out of ideas. Thanks for any help you can provide!
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.