Is there a way to create an instance of a linq class without it being included in the next Submit?
like this:
Customer customer = new Customer();
Context.SubmitChanges(); // customer is not added.
I ge开发者_如何学运维t an error back saying that some values can not be null because constraints in the database, even if i dont have Context.Contacts.InsertOnSubmit(contact);
between the lines. I thought that as long as i did not call the InsertOnSubmit
I could use the Customer class generated by the dbml as a storage or anything else... Any ideas on what I might be doing wrong, or am I trying to break the rules here?
I would suspect that you have attached that object to another in some sort of assignment. It isn't exactly obvious, but that actually causes it to be included in the submit.
you can use the entity Customer
as you want in your code but you have to consider if you assign it to another entity that uses customer
or added to the datacontext
you have and then called SubmitChanges
, you will get this error as long as there are null values in your customer
entity that not allowing null in the actual customer
database table
精彩评论