Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class User
- {
- public string Name { get; set; }
- public string Surname { get; set; }
- public int Age { get; set; }
- public string Country { get; set; }
- // This comparer will be used to find records that exist or don't exist.
- public class KeyFieldComparer : IEqualityComparer<Person>
- {
- public bool Equals(User u1, User u2)
- {
- return u1.Name == u2.Name && u1.Surname == u2.Surname;
- }
- public int GetHashCode(User u)
- {
- return u.Name.GetHashCode() ^ u.Surname.GetHashCode();
- }
- }
- }
- List<User> csvList;
- List<User> oracleList;
- // This will filter users that are in the CSV file that don't already exist in oracle.
- var newUsers = csvList.Except(oracleList, new User.KeyFieldComparer());
- foreach (var newUser in newUsers)
- InsertNewUser(newUser);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement