【发布时间】:2013-05-08 18:04:26
【问题描述】:
我在互联网上搜索了一段时间,但找不到我真正需要的东西。我的问题是我有两个 linq 语句,我计划将它们放在 UNION 中,以便将它们合并到一组列表中,但我想删除那些重复的值。具体来说,这里是一个场景:
query 1 = "this is a test","Yes", "This is a remark"
"this is a test2","No", "This is the second remark"
query 2 = "this is a test","",""
"this is a test2","",""
"this is a test3","",""
"this is a test4","",""
现在我想要发生的事情是这样的:
"this is a test","Yes", "This is a remark"
"this is a test2","No", "This is the second remark",
"this is a test3","",""
"this is a test4","",""
如何在 LINQ 中执行此操作?提前致谢!
【问题讨论】:
-
你试过 .Distinct() 吗?
-
是的先生..试过了但没有效果..
-
查询的返回结果是什么?
-
"this is a test","Yes", "This is a remark" "this is a test2","No", "This is the second remark", "this is a test3" ,"","" "这是一个测试4","","" 这是我所期待的,先生