问题
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