-1
用於插入數據
A
回答
0
String SchooID = getNewID();
Schools schl = new Schools();
schl.school_reference = SchooID;
schl.school_name = "Ananda Collage";
schl.StudentReference.Value = cecbContext.Students.First(i => i.stud_name == "Josh");
cecbContext.AddToSchools(schl);
cecbContext.SaveChanges();
我以這種方式找到了答案。這對我成功了。非常感謝您的幫助夥伴
0
數據嘗試使用此方法添加學生:
Student student = new Student(){studId="", Name="", Age=""};
myEntities.Students.AddObject(student);
myEntities.SaveChanges();
添加學校:
School school = new School(){classId="", Year = year, sName=""};
myEntities.Schools.AddObject(school);
myEntities.SaveChanges();
我希望這會有所幫助。
+1
其實我需要添加數據到學校表?其中有學生表的參考? – Gayashan 2013-03-26 14:49:10
相關問題
- 1. 實體關係圖:</p> <pre><code>Table A) Table B) Table C) - ID - ID - ID1 - Name - xxx - ID2 - Address - yyy - zzz - ... - ... </code></pre> <p>我有兩個問題:</p> <p>1)在<code>Table A)</code>,<code>ID</code>是我的主鍵,主鍵和外鍵
- 2. 「<<<<<<< HEAD」模板
- 3. fstream error:'wrf <<「中的'operator <<'不匹配''插入''|
- 4. 重載C++插入運算符(<<)
- 5. 的Rails搞亂我的代碼以「<<<<<<< HEAD」
- 6. git「<<<<<<< HEAD」
- 7. Heredoc <<<或<<?
- 8. 如何轉換成HashMap(Java)的<table><tr> ...</tr></table>?
- 9. 什麼是我的檔案中的「<<<<<<< head」?
- 10. C代碼格式<<
- 11. Preg_match_all - 搶<table></table>
- 12. Overloading << C++
- 13. operator <<:std :: cout << i <<(i << 1);
- 14. 存儲PGT和PGTIOU CAS生成
- 15. <往前往IDictionary <StudentType,IList <Student>>?>學生類型列表<Student>>?
- 16. PHP表達<<< EOB
- 17. Git在我的源代碼中插入了很多<<<<<錯誤消息
- 18. << <<超載
- 19. 導軌:</p> <p>我有一個僱員,誰<code>has many</code>技能<code>through</code> employeeskillsets:有三種模式
- 20. 如何使用我用下面的代碼首先從<code>category entity</code>檢索<code>category Id</code>並將其綁定到<code>dropdownlist</code>是<code>DropDownlistCategory</code>。現在我想插入<code>category ID</code>從下拉列表產品asp.net實體數據模型
- 21. github增加<<<<<<< HEAD
- 22. JavaScript和DOM:爲什麼「<table>」+ =「<tr></td></tr>」+ =「</ table」不起作用?
- 23. < - ,[[< - ,$ < - 和:=與環境
- 24. C++ ostream << Operator
- 25. C++ wstringstream << NULL
- 26. THREE.Camera.prototype.lookAt</ <() -</ <是什麼意思?
- 27. <%$,<%@,<%=,<%#...這是怎麼回事?
- 28. 反應表顯示我使用<code>aslagle:reactive-table</code></p> <p>文檔兩個鍵
- 29. 使用>>,>,> |,||,| <,<,<<,<<
- 30. ASP.NET <%#與<%
您的數據庫設計看起來不太好。你在「學校」表中有「sName」嗎? – Dilshod 2013-03-26 14:38:12
你是說'sName'與'Student'中的'Name'鏈接? – Joetjah 2013-03-26 14:55:14