HI,
I have two lists are tab1 and tab2 with same properties are called ABUId,User,BuildingId,UserFolio and BuildingName.
Here I need to get data which available in tab1 and which not available in tab2.here Consider only BuildingId and User data.
please refer below source code..
Note:- One BuildingId can mapped with multiple user.So combine these both things and need to select correct one which is in tab1 and if that not in tab2.
var tab1 = listBank; var tab2 = DataTable1.AsEnumerable().Select(dr => new Bank { ABUId = "0", User = dr.Field<String>("User"), BuildingId = dr.Field<String>("BuildingId"), UserFolio = dr.Field<String>("UserFolio"), BuildingName = dr.Field<String>("BuildingName") }).ToList(); //Here I need to select which is available in tab1 and if that not available in tab2 var NeedToDelete = ? var finalRec = NeedToDelete.Where(x => !x.User.Equals("JOHN", StringComparison.InvariantCultureIgnoreCase)).Select(x => x).ToList(); if (finalRec != null) { foreach (Bank bank in finalRec) { //For my Further calculations } }
Thanks in Advance..!