2014-07-15 86 views
-2

我嘗試你賽義德任何事情,但我不能做我的工作 其我的代碼訂購LINQ的加入

Func<Dead, Object> orderByFunc = null; 
    orderByFunc = Dead => Dead.Last_Name; 
    var query = from ded in searchDead 
        join ask in Asker on ded.Family_Number equals ask.Family_Number 
        orderby orderByFunc 
        select ask; 
    Functions.searchAsker = query.AsQueryable<Asker>(); 
+1

什麼* *正是你嘗試過用什麼方式這是不是爲你工作?沒有具體說明,你會放鬆自己再次收到相同的建議,浪費每個人的時間。 –

+0

可能的重複[如何使用動態字符串參數執行OrderBy?](http://stackoverflow.com/questions/2728340/how-can-i-do-an-orderby-with-a-dynamic-string - 參數) –

+0

我想創建字符串順序fild –

回答

0
string order = "Last Name"; 
var propertyorder = null 
switch (order) 
{ 
    case "Last Name": 
     propertyorder = ded.Last_Name; 
     break; 
    case "First Name": 
     propertyorder = ded.First_Name 
     break; 
    default: 
     propertyorder = ded.Last_Name; 
     break; 
} 

    var query = from ded in Dead 
    join ask in Asker on ded.Family_Number equals ask.Family_Number 
    orderby (propertyorder) 
    select ask; 
+0

其不工作MW –