c# - Excel Data using LinQ Intersecting -


my intersect in linq somehow dont seem work. have 2 excel sheets. fetch using linqtoexcel , (linqtoexcel not support visitsubqueryexpression have work).

  list<boardsheet> sourcetest = (from t in boards[0]                         t["board"] == boardname                         select new circuitset                              {                                  id = string.format(t["id"]),                                  data = string.format(t["data"]),                                  ctrltype = string.format(t["ctrltype"]),                                  sys = string.format(t["sys"]),                                  code = string.format(t["code"])                              }                         ).tolist<boardsheet>();             list<boardsheet> targettest = (from t in boards[0]                                           t["board"] == boardname                                           select new circuitset                                           {                                               id = string.format(t["id"]),                                               data = string.format(t["data"]),                                               ctrltype = string.format(t["ctrltype"]),                                               sys = string.format(t["sys"]),                                               code = string.format(t["code"])                                           }                        ).tolist<boardsheet>();             ienumerable<boardsheet> board = sourcetest.intersect(targettest); 

board's count returns 0. when iterate thro field values of sourcetest , targetset see common field values.

these instances of reference types. intersect using defaultcomparer reference types, referenceequals. since sourcetest has no common instances targettest, no results found.

you create comparer, or join this:

list<circuitset> results = (   s in sourcetest   join t in targettest   on s.id equals t.id   s.data == t.data && s.controltype == t.controltype ...   select s ).tolist(); 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -