colDiffUpdate和colDiffTarget有不同的值,如何将两个列表的差异添加到colType中?
假设每个列表都有不同的值。
public List<columnTypes> colType = new List<columnTypes>();
public List<coldiffTypes> colDiffUpdated = new List<coldiffTypes>();
public List<coldiffTypesTarget> colDiffTarget = new List<coldiffTypesTarget>();
这是我存储值的类
public class columnTypes
{
public string tblName { get; set; }
public string colName { get; set; }
public int maxLength { get; set; }
public string maxLengthStr { get; set; }
public bool isUnique { get; set; }
public bool isKey { get; set; }
public System.Type dataType { get; set; }
public bool isNullable { get; set; }
public bool isAutoIncrement { get; set; }
public string dataTypeName { get; set; }
public int numericPrecision { get; set; }
public int numericScale { get; set; }
}
public class coldiffTypes
{
public string tblName { get; set; }
public string colName { get; set; }
public int maxLength { get; set; }
public string maxLengthStr { get; set; }
public bool isUnique { get; set; }
public bool isKey { get; set; }
public System.Type dataType { get; set; }
public bool isNullable { get; set; }
public bool isAutoIncrement { get; set; }
public string dataTypeName { get; set; }
public int numericPrecision { get; set; }
public int numericScale { get; set; }
}
public class coldiffTypesTarget
{
public string tblName { get; set; }
public string colName { get; set; }
public int maxLength { get; set; }
public string maxLengthStr { get; set; }
public bool isUnique { get; set; }
public bool isKey { get; set; }
public System.Type dataType { get; set; }
public bool isNullable { get; set; }
public bool isAutoIncrement { get; set; }
public string dataTypeName { get; set; }
public int numericPrecision { get; set; }
public int numericScale { get; set; }
}
类看起来具有相同的属性,如果是这样,只需实现一个类 IEqualityComparer 并比较该类的 colDiffUpdated 和 colDiffTarget 列表的每个值