我有一個問題,除去2列表刪除重複的對象後,比較表2列出
public class Pump
{
public int PumpID { get; set; }
public string PumpName { get; set; }
public string LogicalNumber { get; set; }
}
public void LoadPump()
{
var pumps = _pumpRepository.GetAll(); // 2 Pump
var pumpsActive = _pumpRepository.GetAllActive(); // 1 Pump Active (Pump 1)
//i try like this
List<Pump> pumpsNonActive = pumps.Except(pumpsActive).ToList(); // Result 2
//if like this
List<Pump> pumpsNonActive = pumpsActive.Except(pumps).ToList(); // Result 1 (Pump 1)
}
我想只得到1結果pumpsNonActive(結果=泵2)重複的對象。任何人都可以幫助我:/
你'Pump'類具有覆蓋'Equals'和'GetHashCode'方法。 – MarcinJuraszek 2013-03-26 11:16:02
您的存儲庫如何實現?你如何管理DbContext? – 2013-03-26 11:20:35