如何获取仅包含字符串名称的 Set Linq 实体
好的,我有 linq 实体的字符串名称。
string table = "Person";
我有数据上下文,并且有一个名为 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();
谢谢
Okay so I have the string name of the linq entity.
string table = "Person";
I have the datacontext and there's an entity or database table called Person.
I'd like to be about to somehow using the string of the table name create a new Person entity and set all the attributes.
I really don't have much code for this example but let me try and write something.
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();
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这种方式获取数据
Try This way to get data