Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在明细表的实体3.5中插入行?_C#_Entity Framework - Fatal编程技术网

C# 如何在明细表的实体3.5中插入行?

C# 如何在明细表的实体3.5中插入行?,c#,entity-framework,C#,Entity Framework,我在VisualStudio2008和Entity 3.5中开发了一个简单的应用程序。在我的数据库中,我有一个主表和一个详细表 在实体4或更高版本中,我们可以访问详细信息表中的主密钥,如下所示: tabl2.masterkey=..... 但在实体3.5中,这不可用。如何在明细表中插入行 Table2 t2 = new Table2(); T2.TableId1 // this property is unavailable 此语法适用于实体4或更高版本,但不适用于实体3.5。 Tabl

我在VisualStudio2008和Entity 3.5中开发了一个简单的应用程序。在我的数据库中,我有一个主表和一个详细表

在实体4或更高版本中,我们可以访问详细信息表中的主密钥,如下所示:

tabl2.masterkey=.....
但在实体3.5中,这不可用。如何在明细表中插入行

Table2  t2 = new Table2();
T2.TableId1 // this property is unavailable 
此语法适用于实体4或更高版本,但不适用于实体3.5。

Table1 t1 = new Table1();
Table2 t2 = new Table2();
t1.add(t2);

说到T2.TableId1,我认为您必须知道引用的关系名或字段名。。检查t2的属性,我想,你会在那里找到一些t1参考。

你的意思可能是
t1.Table2s.Add(t2)