开发者

linq to sql - Inserting a class with null reference

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜