I am using linq to sql for a quick project of mine (if I understood correctly, linq to sql is dead... right?).
Anyhows, problem occurs in the following situation: I've got a class (table) that references other table. I don't load all tables that the first table is related to.
When I try inserting the object, which doesn't hav开发者_如何学Goe some of its refernces populated (that hold a null value) I get a null exception. How do I insert that object without needing to connect each and every one of the table it's referenced to?
Check the IsForeignKey and CanBeNull attributes for the association properties, these can prevent null from being inserted.
精彩评论