tags:

views:

25

answers:

1

Hi all,

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 have 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?

A: 

Check the IsForeignKey and CanBeNull attributes for the association properties, these can prevent null from being inserted.

Devart