Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Comparing Two Custom Lists
    primarykey
    data
    text
    <p>I have run into a situation where I need to compare two different lists to each other and I am wondering what the best method is for doing this? I thought something like this would work but it doesn't and I can't figure out why. The Linq query is returning records it shouldn't. This is my first run at trying to figure something like this out so it is undoubtedly messy.</p> <pre><code> private static List&lt;ColumnDefinition&gt; FindTableStructureUpdates(List&lt;ColumnDefinition&gt; colDefs, List&lt;ColumnDefinition&gt; tblCols) { List&lt;ColumnDefinition&gt; ColsToUpdate = new List&lt;ColumnDefinition&gt;(); for (int i = 0; i &lt; colDefs.Count; ++i) { string colDefName = colDefs[i].ColName; string colDefDataType = colDefs[i].ColType; string colDefAttribute = colDefs[i].ColAttributes; var query = from tbl in tblCols where tbl.ColName != colDefName &amp;&amp; tbl.ColType != colDefDataType &amp;&amp; tbl.ColAttributes != colDefAttribute select new { colDefName, colDefDataType, colDefAttribute }; if (query.Count() &gt; 0) { foreach (var item in query) { ColsToUpdate.Add(new ColumnDefinition(item.colDefName, item.colDefDataType, item.colDefAttribute)); } } } return ColsToUpdate; </code></pre> <p>Any suggestions would be great.</p> <p>Thanks.</p> <p>IEquatable Implementation??</p> <pre><code> #region IEquatable&lt;ColumnDefinition&gt; Members public bool Equals(ColumnDefinition other) { if (this.ColName.Equals(other.ColName) &amp;&amp; this.ColType.Equals(other.ColType) &amp;&amp; this.ColAttributes.Equals(other.ColAttributes)) return true; return false; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload