Is there a secret to using LINQ to SQL to add records when the object has relationships?

Try the following. Replace this in your class declaration: public class Stream { private EntitySet _StreamEntry; private EntitySet _Stream2FieldTypes; } with this: public class Stream { private EntitySet _StreamEntry = new EntitySet(); private EntitySet _Stream2FieldTypes = new EntitySet(); }.

Woah... no way! – quakkels Oct 6 '10 at 20:35 YES! Thanks a ton!

– quakkels Oct 6 '10 at 20:36 Amazing! I've been trying to figure this out since Monday! – quakkels Oct 6 '10 at 20:37 You're welcome =) – Francisco Oct 6 '10 at 20:49.

I am working in LINQ to SQL, ASP.NET MVC, and C#. I have a repository called genesisRepository to connect to the database. I have a table represented in an object called Stream.

I have a test action in my controller for creating new records inside my Stream table. I get a null reference error when I execute the ActionResult StreamTest(). GenesisRepository is not null.

StreamTable is not null, and the newly create object stream is also obviously not null. The only thing I can think of that would be null are the EntitySet properties which define the foreign relationships. I can create a new record using streamTable.Context.

ExecuteCommand("INSERT INTO genesis.dbo. Stream (StreamName, StreamUrl) VALUES ('Name', 'url');");.

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.

Related Questions