在绑定c#windowsphone之前操作数据

本文关键字:操作 操作数 数据 绑定 c#windowsphone | 更新日期: 2023-09-27 18:29:08

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

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 };   

感谢您的帮助
感谢

在绑定c#windowsphone之前操作数据

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

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