linq の初心者です。1 つのシナリオで立ち往生しています。つまり、
ユーザー入力に基づいて検索結果を並べ替える必要があります。
ユーザー入力は姓、名、役職です。入力3のドロップダウンがあり、選択した値に基づいて結果をソートする必要があります。
私は試した
order = Request["orders"].Split(',');
var param = order[0];
var p1 = typeof(Test).GetProperty(param);
param = order[1];
var p2 = typeof(Test).GetProperty(param);
param = order[2];
var p3 = typeof(Test).GetProperty(param);
model.Test = (from tests in model.Test
select tests).
OrderBy(x => p1.GetValue(x, null)).
ThenBy(x => p2.GetValue(x, null)).
ThenBy(x => p3.GetValue(x, null));
しかし、うまくいきません。
こんなqryが欲しい
from tests in model.Test
select tests).OrderBy(x => x.lastname).
ThenBy(x => x.firstname).ThenBy(x => x.Title);
order[0]== lastname but how can i use it in the place of OrderBy(x => x.order[0])..?
前もって感謝します。