在绑定c#windows phone之前操纵数据

时间:2014-11-05 09:07:36

标签: c# xaml windows-phone-8

我希望在将数据转换为列表并将长列表选择器绑定到它之前操纵数据库中的数据 我有以下代码从我的数据库中获取所需的数据

var tdr =
  from p in ctx.Transactions
  join c in ctx.Type on p.Type equals c.Id
  where p.Date > DateTime.Today.AddDays(-1 * ra) && c.Type1.Equals(ty)
  orderby p.Date descending
  select new { Id = p.Id
             , amont = p.Amont
             , type = p.Type
             , des = p.Des
             , dated =p.Date
             , Aid=p.Acc 
             };  

我想在绑定之前使用函数来更改某些值

list32.ItemsSource = tdr.ToList();  

我尝试将查询更改为类似的内容但它没有工作

select new { Id = p.Id
           , amont = p.Amont
           , type = p.Type
           , des = p.Des
           , ***dated =somefunction(p.Date)***
           , Aid=p.Acc };   

任何帮助表示赞赏 感谢

1 个答案:

答案 0 :(得分:0)

做你想做的事应该没问题 这是一个例子:

void Main()
{
    var i = Enumerable.Range(3,4);


    i.Select (x => new { sq = x*x
                       , cu = MyMethod(x)
                       }            
             );
}

// Define other methods and classes here
public int MyMethod(int anInt){
    return anInt*anInt*anInt;
}

这将导致:

sq     cu
---------
9      27 
16     64 
25     125 
36     216 
86     432