c# - Linq Order By With Different Method -
looking way linq order by; let me explain:
i have 4 records. like
1. 233 2. 4232 3. 12 4. 21
and order them specify first element. example; first element 12 then.
1. 12 2. 21 3. 233 4. 4232
another example; first element 4232 then
1. 4232 2. 12 3. 21 4. 233
i hope expalin clearly; how can it?
current data provider code:
public static list<tbl_okey_tableplayer> playersonthetable(int okeytableid) { using (var dbcontext = new db_oyun()) { iqueryable<tbl_okey_tableplayer> okeytableplayer = dbcontext.tbl_okey_tableplayer.where(a => a.okeytableid == okeytableid); iqueryable<tbl_okey_tableplayer> rows = okeytableplayer; return rows.tolist(); } } var playersonthetable = dataprovider.playersonthetable(okeytableid) .orderby(x => x.okeytableplayerchairnumber) .tolist();
this example assumes want 4232 @ first element:
int[] ints = { 12, 233, 4232, 21 }; var firstint = ints.where(x => x == 4232); // number want first value var orderedints = ints.orderby(x => x).except(firstint); var customordered = firstint.concat(orderedints);
note naively assumes where
method finds element in ints
sequence.
Comments
Post a Comment