Linq adding new rows to table when there is a relation table

我的梦境 提交于 2019-12-25 03:34:55

问题


this question is in relation to my previous question: Linq2Entity Getting Values from reference Table

Now i have the problem that i want to add a new entry in Table B. I tried something like this:

    ObjectQuery<A> aTable = dbConnection.A;
    ObjectQuery<B> bTable = dbConnection.B;
    var data = from d in aTable   //Reference dataset in Table A
               where d.ID == myID
               select d;

    B bData = new B()
    {
        ID = GetNewID(),
        Text = text,
        A = data.First()
    };

    dbConnection.AddToB(bData);

but this "A = d.First()" does now work... Any ideas? Thx!

来源:https://stackoverflow.com/questions/9173613/linq-adding-new-rows-to-table-when-there-is-a-relation-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!