从1个查询结果复制到某个特定属性上的另一个查询结果

时间:2014-01-05 15:20:54

标签: c# linq windows-phone

我有这个功能:

public void copy(string abc)
{
var query_1 = from Book s in BookDB.Books where (s.Author == abc && s.AuthorCV != "") select s;
var query_2 = from Book x in BookDB.Books where (x.Author == abc && x.AuthorCV == "") select x;
}

我的问题是如何在query_2中将AuthorCV从query_1复制到AuthorCV ...请帮帮我

1 个答案:

答案 0 :(得分:-1)

尝试将两个查询都转换为Book,然后从另一个中复制,然后保留第二个:

Book book1 = (Book)query_1;
Book book2 = (Book)query_2;
book2.AuthorCV=book1.AuthorCV;

然后坚持book2保存更改。