1
나는 내 데이터베이스에 List<Item> A
을 가지고 있는데, 나는 외부에서 List<Item> B
을 얻었습니다. 그리고 나는 리스트 A와 B가 같은 속성을 갖기를 원합니다.Linq 제외 특정 필드로 비교
List<Item> A
{ ID : 1, Name: "Tool A" , Status : 1, Price : 100 }
{ ID : 2, Name: "Tool B" , Status : 2, Price : 200 }
{ ID : 3, Name: "Tool C" , Status : 3, Price : 300 }
{ ID : 4, Name: "Tool D" , Status : 4, Price : 400 }
{ ID : 5, Name: "Tool E" , Status : 5, Price : 500 }
List<Item> B
{ ID : 1, Name: null , Status : 1, Price : 100 }
{ ID : 2, Name: null , Status : 2, Price : 200 }
{ ID : 3, Name: null , Status : 3000, Price : 300 }
{ ID : 4, Name: null , Status : 4, Price : 40000 }
{ ID : 5, Name: null , Status : 5, Price : 500 }
나는 "이름"속성의
{ ID : 3, Name: "Tool C", Status : 3000, Price : 300 }
{ ID : 4, Name: "Tool D", Status : 4, Price : 40000 }
값 것이다 데이터베이스에 업데이트 된 데이터를 저장 그들이 List<Item> B
내가 생각에 널 (null)에도 불구하고 List<Item> A
출신하려면 이런 식으로 뭔가 이상한 결과가 나옵니다.
var ChagnedList = A.AsEnumerable()
.Where(aa => B.Any(bb => aa.Status != bb.Status || aa.Price != bb.Price))