Note that there are some explanatory texts on larger screens.

plurals
  1. POLINQ join and orderby issues
    primarykey
    data
    text
    <p>OK, I've been banging my head against this for a few days, and after studying LINQ I think I am on the right track. But I have a SQL brain and that is sometimes hard to translate to C#.</p> <p>I have two arrays, one sorted alphabetically, and the other ordered by ID. I need to order the second array alphabetically. The IDs are the joining factor. I.E. A.ID = P.ID.</p> <p>Here are my arrays and example values;</p> <pre><code>private IGenericListItem[] _priceLevels = new IGenericListItem[0]; _priceLevels is in the form of {ID, Name} {3, A} {8, B} {4, C} {7, D} {5, E} {9, F} {1, G} </code></pre> <p><strong>Edit:</strong> updated this to show _assignmentControls contains a sub array. I didn't make it so excuse the insanity. It actually contains a copy of _priceLevels...</p> <pre><code>protected ArrayList _assignmentControls = new ArrayList(); _assignmentControls is in the form of {ID, LastPrice, NewPrice, _priceLevels[]} {1, 1.00, 2.00, _priceLevels} {2, 1.00, 2.00, _priceLevels} {3, 1.00, 2.00, _priceLevels} {4, 1.00, 2.00, _priceLevels} </code></pre> <p>Part of the problem as that I'm trying to compare/join an ArrayList and an IGenericListItem.</p> <pre><code>In SQL I would do something like this; SELECT A.* FROM _assignmentControls A JOIN _priceLevels P ON A.ID = P.ID ORDER BY P.Name </code></pre> <p>This Returns me an _assignmentControls table sorted by the values in _priceLevels.</p> <p>In C# LINQ I got this far, but can't seem to get it right;</p> <pre><code> var sortedList = from a in _assignmentControls join p in _priceLevels on a equals p.ID orderby p.Name select _assignmentControls; </code></pre> <p>I am getting red squigglies under join and orderby and the p in p.Name is red. And A) it doesn't work. B) I'm not sure it will return sortedList as a sorted version of _assignmentControls sorted by _priceLevels.Name.</p> <p>EDIT: When I hover over "join" I get "The type arguments for the method 'IEnumerable System.Linq.Enumerable.Join(this Enumerable,IEnumerable, Func,Func....'cannot be infered from the query. I am researching that now.</p> <p>Thanks for looking!</p>
    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.
 

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