I have a typeed dataset that includes table animals. In animals I have two columns named ID and name.
In that typed dataset, I have created a dataset named Dataset in which the value is already present. (I get them from the database)
And then I have created a second dataset named Additional Dataset which contains values which I read from the CVS file. The current Dataset may also contain rows in this CV file
Example of current dataset
ID NAME 1 Harry 2 Olga 3 Robert
Example of an additional dataset
ID NAME 1 Harry 2 Olga 3 Robert 4 Danny 5 Excel
Now I want a new table which is the only value that Duplicate, so I would like to get the following in a separate data table
ID name 4 Danny 5 axle
How can I get this? I only seem to get people to copy.
Thanks in advance! Private Forecasting Zero Comparerows (DataTable table1, DataTable table2) {foreach (DataRow row1 in row 1.) {foreach (line color row 2. 2) in table 2. {Var array1 = row1.ItemArray; Var array2 = row2.ItemArray; If (! Array1.SequenceEqual (array2)) {NotInDataset.docent.Rows.Add (array1); }}}}
What I have now is, it filters the one which is equal and adds it to the dataset, I want to achieve it but nothing like them But remove them but when I use rows. It does not work properly
A given "record" in this archive? And does that type apply equality logic?
If not, you can apply for that type: Something like this:
class MyObjectComparer: IEqualityComparer & lt; MyObject & gt; {Public Balance Equals (MyObact X, MyObact Y) {If (Object References Ecloss (X, Y)) returns true; If (Object Referred Ecloss (X, Blank)) Object. Reference Aqualls (Y, Blank)) False Return; Return x.id == y.ID & amp; Amp; X.Name == y.Name; } Public intoshosh (MyObject object) {if (Object References Ecloss (OBJ, empty)) 0; Intimate Hash Object ID = Obj.Id.GetHashcode (); Int hashObjectName = obj.Name == tap? 0: obj.Name.GetHashCode (); Return hash object ID ^ hash objectname; }}
Once the similarity argument exists, you can create your filtered lists with a few simple enumerable extensions. For example, to get items in the second list which are not in the first list:
var filteredItems = secondList.Except (first list, new MyObjectComparer ());
Repeat the argument to get items from the first list, which are not in the other. And if both of you want to apply the argument, then you can add the result. Something like this:
var filteredFirst = firstList.Except (second list, new MyObjectComparer ()); Var filteredSecond = secondList.Except (first list, new MyObjectComparer ()); Var Results = First List. Concat (second list);
No comments:
Post a Comment