how to compare two entity objects in c# to update

The solution for “how to compare two entity objects in c# to update” can be found here. The following code will assist you in solving the problem.

public class ProductNumberEqualityComparer : IEqualityComparer
{
public int GetHashCode(Product obj)
{
return (obj == null) ? 0 : obj.ProductNumber.GetHashCode();
}

public bool Equals(Product x, Product y)
{
if (ReferenceEquals(x, y)) return true;
if (x == null || y == null) return false;
return x.ProductNumber == y.ProductNumber;
}
}

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in