0
好吧,所以我有linq實體的字符串名稱。如何獲得設置Linq實體只有字符串名稱
string table = "Person";
我有datacontext,有一個名爲Person的實體或數據庫表。
我想要以某種方式使用表名的字符串創建一個新的Person實體並設置所有屬性。
我真的沒有太多的代碼爲這個例子,但讓我嘗試寫東西。
MetaTable table = SetTable(); //Gets the metatable of the entity
string tableName = table.TableName; //"Person"
//Stuck there
//...
//What I'd like to do
//Somehow get Person then
Person p = new Person();
p.Name = "Joe";
db.Person.InsertOnSubmit(p);
db.SubmitChanges();
感謝
對不起,這是絕對清楚你在什麼。 「SetTable」是做什麼的?第1行中的「實體」是什麼?這裏有什麼更大的圖片? – 2012-02-13 23:26:00
第一行通過元數據獲取Person表名。 – 2012-02-20 20:31:01