I need to compare to List's of Gu45Entity
List<Gu45Entity> Gu45EntityItemsFromDb = DataBaseModel.Instance.Gu45DocumentStore.Include(x => x.EGu45.Gu45).ToList();
List<Gu45Entity> temp = Gu45EntityItemsFormService.Except(Gu45EntityItemsFromDb).ToList();
If I understand correctly I need to implement IEqualityComparer<T>
For every class. But how in my case should be implemented GetHashCode
for example to Gu45
. Id
should not include in the comparison because it's random number generated by database.
public class Gu45 : IEqualityComparer<Gu45>
{
[Key]
public int Id { get; set; }
public Branch Branch { get; set; }
public Direction Direction { get; set; }
public Org Org { get; set; }
public Wagons Wagons { get; set; }
public string Num { get; set; }
public string Date { get; set; }
public string Esr_mount { get; set; }
public string Esr_mount_name { get; set; }
public string Rw_mount_name { get; set; }
public string Delivery_time { get; set; }
public string Taking_time { get; set; }
public string Sign { get; set; }
public bool Equals(Gu45 x, Gu45 y)
{
throw new NotImplementedException();
}
public int GetHashCode(Gu45 obj)
{
throw new NotImplementedException();
}
}
Classes:
Gu45Entity:
public class Gu45Entity
{
[Key]
public int Id { get; set; }
public EGu45 EGu45 { get; set; }
}
Egu45:
public class EGu45
{
[Key]
public int Id { get; set; }
public Gu45 Gu45 { get; set; }
public string Signature { get; set; }
public string DocState { get; set; }
}
Gu45:
public class Gu45
{
[Key]
public int Id { get; set; }
public Branch Branch { get; set; }
public Direction Direction { get; set; }
public Org Org { get; set; }
public Wagons Wagons { get; set; }
public string Num { get; set; }
public string Date { get; set; }
public string Esr_mount { get; set; }
public string Esr_mount_name { get; set; }
public string Rw_mount_name { get; set; }
public string Delivery_time { get; set; }
public string Taking_time { get; set; }
public string Sign { get; set; }
}
Branch:
public class Branch
{
[Key]
public int Id { get; set; }
public string Code { get; set; }
public string Name { get; set; }
}
Wagons:
public class Wagons
{
[Key]
public int Id { get; set; }
public Wagon Wagon { get; set; }
}
Direction,Branch,Org,... and others.