I'm using EntityFramework to link my C#/WPF project to a SQL Server database. I have an object that has navigational properties to other types of objects (so linking to other tables in the DB).
If I create a new object for one of these navigational properties, and add it to the root object, what is the best way to get this added to the DB without having to check all of the existing properties and compare them to this new object?
MyTable obj = (from myTableObject in db.MyTable select myTableObject).FirstOrDefault();
obj.FirstNavProperties.Add(new FirstNavProperty());
db.Entry(obj).State = EntityState.Modified;
Will the above code add the new FirstNavProperty?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…