Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Everything that <a href="https://stackoverflow.com/questions/5410339/linq-equivalent-of-except/5410520#5410520">BrokenGlass</a> and <a href="https://stackoverflow.com/questions/5410339/linq-equivalent-of-except/5410437#5410437">pst</a> have said is correct, but it seems there's still some confusion, stemming from the fact that these DevExpress methods return a <code>List&lt;object&gt;</code>, where <code>object</code> is:</p> <blockquote> <p>An object which is an array of field values (if several field names are passed via the fieldNames parameter) or a direct field value (if a single field name is passed via the fieldNames parameter). (<a href="http://documentation.devexpress.com/#AspNet/DevExpressWebASPxGridViewASPxGridView_GetRowValuestopic" rel="nofollow noreferrer">Source Link</a>)</p> </blockquote> <p>So, since you're passing multiple field names, code like this should work:</p> <pre><code>// Get the current values var currentRowValues = m_ASPxGridView.GetCurrentPageRowValues("ID", "SID") // Cast each object to an array of objects .Cast&lt;object[]&gt;() // Project the two members of the array into an anonymous type .Select(x =&gt; new { ID = x[0].ToString(), SID = x[1].ToString() }); var selectedRowValues = m_ASPxGridView.GetSelectedFieldValues("ID", "SID") // Cast each object to an array of objects .Cast&lt;object[]&gt;() // Project the two members of the array into an anonymous type .Select(x =&gt; new { ID = x[0].ToString(), SID = x[1].ToString() }); // Compare the two collections to get the unselected row values var unselected = currentRowValues.Except(selectedRowValues); </code></pre> <p>As we've been discussing, .NET won't know how to compare the two collections if they're of type <code>object</code>. However, it should work if they've been projected (using <code>Select</code>) to the same anonymous type -- I think by default it will use value-type equality.</p> <p><strong>Edit:</strong> According to Jon Skeet from <strong><a href="http://rads.stackoverflow.com/amzn/click/1935182471" rel="nofollow noreferrer">C# in Depth</a></strong>:</p> <blockquote> <p>Within any given assembly, the compiler treats two anonymous object initializers as the same type if there are the same number of properties, with the same names and types, and they appear in the same order.</p> <p>...</p> <p>Equality between two instances of the same anonymous type is determined in the natural manner, comparing each property value in turn using the property type's <code>Equals</code> method.</p> </blockquote> <p>So, if I'm reading it right, the above code should do exactly what you're asking. Please let me know if I'm not ;-)</p>
 

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